1 | /********************************************************************** <BR>
|
---|
2 | This file is part of Crack dot Com's free source code release of
|
---|
3 | Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
|
---|
4 | information about compiling & licensing issues visit this URL</a>
|
---|
5 | <PRE> If that doesn't help, contact Jonathan Clark at
|
---|
6 | golgotha_source@usa.net (Subject should have "GOLG" in it)
|
---|
7 | ***********************************************************************/
|
---|
8 |
|
---|
9 | #include "objs/sprite.hh"
|
---|
10 | #include "error/error.hh"
|
---|
11 | #include "load3d.hh"
|
---|
12 | #include "string/string.hh"
|
---|
13 | #include "error/alert.hh"
|
---|
14 | #include "obj3d.hh"
|
---|
15 | #include "objs/sprite_id.hh"
|
---|
16 | #include "saver.hh"
|
---|
17 | #include "r1_api.hh"
|
---|
18 | #include "tmanage.hh"
|
---|
19 |
|
---|
20 | extern i4_grow_heap_class *g1_object_heap;
|
---|
21 |
|
---|
22 | g1_sprite_list_class g1_sprite_list_man;
|
---|
23 |
|
---|
24 | // todo : add a sprite loader instead of mouching the load3d
|
---|
25 | // its mooching, jonathan. -trey
|
---|
26 |
|
---|
27 | void g1_sprite_list_class::load(r1_render_api_class *tmap)
|
---|
28 | {
|
---|
29 | i4_const_str *sprites=i4_string_man.get_array("sprite_array");
|
---|
30 | w32 count;
|
---|
31 |
|
---|
32 | g1_quad_object_loader_class loader(g1_object_heap);
|
---|
33 |
|
---|
34 | for (count=0; !sprites[count].null(); count++)
|
---|
35 | {
|
---|
36 | I4_ASSERT(count<=G1_MAX_SPRITES, "increase G1_MAX_SPRITES");
|
---|
37 |
|
---|
38 | i4_str *name=i4gets("spr_fmt").sprintf(200, &sprites[count]);
|
---|
39 | i4_file_class *in_file=i4_open(*name);
|
---|
40 |
|
---|
41 |
|
---|
42 | if (!in_file)
|
---|
43 | i4_alert(i4gets("file_missing"),200,sprites+count);
|
---|
44 | else
|
---|
45 | {
|
---|
46 | g1_loader_class *fp=g1_open_save_file(in_file);
|
---|
47 | if (fp)
|
---|
48 | {
|
---|
49 | g1_quad_object_class *tmp=loader.load(fp, sprites[count], tmap->get_tmanager());
|
---|
50 | tmp->scale(0.1);
|
---|
51 |
|
---|
52 | array[count].add_x=tmp->animation[0].vertex[0].v.x;
|
---|
53 | array[count].add_y=tmp->animation[0].vertex[0].v.y;
|
---|
54 | array[count].texture = tmp->quad[0].material_ref;
|
---|
55 | array[count].texture_scale = tmp->quad[0].texture_scale;
|
---|
56 | array[count].extent = tmp->extent;
|
---|
57 |
|
---|
58 | r1_texture_handle material=tmp->quad[0].material_ref;
|
---|
59 | int alen=r1_render_api_class_instance->get_tmanager()->get_animation_length(material);
|
---|
60 | array[count].num_animation_frames = alen;
|
---|
61 |
|
---|
62 | delete fp;
|
---|
63 | }
|
---|
64 | else
|
---|
65 | i4_alert(i4gets("old_model_file"),200,sprites+count);
|
---|
66 | }
|
---|
67 | delete name;
|
---|
68 | }
|
---|
69 |
|
---|
70 | if (count!=G1_SPRITE_LAST)
|
---|
71 | {
|
---|
72 | i4_alert(i4gets("sprite_num"),100,count,G1_SPRITE_LAST);
|
---|
73 | i4_error("");
|
---|
74 | }
|
---|
75 |
|
---|
76 | i4_free(sprites);
|
---|
77 | }
|
---|