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 "editor/dialogs/obj_win.hh"
|
---|
10 | #include "obj3d.hh"
|
---|
11 | #include "math/pi.hh"
|
---|
12 | #include "image/image.hh"
|
---|
13 | #include "draw_context.hh"
|
---|
14 | #include "window/win_evt.hh"
|
---|
15 | #include "device/kernel.hh"
|
---|
16 | #include "image/color.hh"
|
---|
17 | #include "g1_object.hh"
|
---|
18 | #include "remove_man.hh"
|
---|
19 | #include "g1_render.hh"
|
---|
20 | #include "r1_api.hh"
|
---|
21 | #include "editor/e_state.hh"
|
---|
22 | #include "editor/mode/e_object.hh"
|
---|
23 | #include "resources.hh"
|
---|
24 | #include "window/style.hh"
|
---|
25 | #include "app/app.hh"
|
---|
26 | #include "lisp/li_class.hh"
|
---|
27 |
|
---|
28 | void g1_3d_object_window::do_idle()
|
---|
29 | {
|
---|
30 | if (object.valid())
|
---|
31 | {
|
---|
32 | if (!context_help_window.get())
|
---|
33 | {
|
---|
34 | i4_graphical_style_class *style=i4_current_app->get_style();
|
---|
35 | i4_const_str help_str=i4gets((char *)object->name(),i4_F);
|
---|
36 | if (!help_str.null())
|
---|
37 | context_help_window=style->create_quick_context_help(x(), y()+height()+5, help_str);
|
---|
38 | else
|
---|
39 | context_help_window=style->create_quick_context_help(x(), y()+height()+5,
|
---|
40 | i4_const_str((char *)object->name()));
|
---|
41 | }
|
---|
42 | }
|
---|
43 |
|
---|
44 | }
|
---|
45 |
|
---|
46 | void g1_3d_object_window::set_object_type(g1_object_type type,
|
---|
47 | w16 _array_index)
|
---|
48 | {
|
---|
49 | if (object.valid())
|
---|
50 | {
|
---|
51 | object->request_remove();
|
---|
52 | g1_remove_man.process_requests();
|
---|
53 | object=0;
|
---|
54 | }
|
---|
55 |
|
---|
56 | if (type>=0)
|
---|
57 | {
|
---|
58 | object=g1_create_object(type);
|
---|
59 | if (object.valid())
|
---|
60 | {
|
---|
61 | object->x=object->lx=object->y=object->ly=object->h=object->lh=0;
|
---|
62 | object->player_num=g1_edit_state.current_team;
|
---|
63 | }
|
---|
64 | }
|
---|
65 |
|
---|
66 | object_type=type;
|
---|
67 | array_index=_array_index;
|
---|
68 | request_redraw(i4_F);
|
---|
69 | }
|
---|
70 |
|
---|
71 | g1_3d_object_window::g1_3d_object_window(w16 w, w16 h,
|
---|
72 | g1_object_type obj_type,
|
---|
73 | w16 _array_index,
|
---|
74 | g1_3d_pick_window::camera_struct &camera,
|
---|
75 | i4_image_class *active_back,
|
---|
76 | i4_image_class *passive_back,
|
---|
77 | i4_event_reaction_class *reaction)
|
---|
78 | : g1_3d_pick_window(w,h,
|
---|
79 | active_back, passive_back,
|
---|
80 | camera,
|
---|
81 | reaction)
|
---|
82 | {
|
---|
83 | object=0;
|
---|
84 | set_object_type(obj_type, _array_index);
|
---|
85 | }
|
---|
86 |
|
---|
87 |
|
---|
88 | void g1_3d_object_window_ambient(i4_transform_class *object_to_world,
|
---|
89 | i4_float &ar, i4_float &ag, i4_float &ab)
|
---|
90 | {
|
---|
91 | ar = 1.0;
|
---|
92 | ag = 1.0;
|
---|
93 | ab = 1.0;
|
---|
94 | }
|
---|
95 |
|
---|
96 |
|
---|
97 | void g1_3d_object_window::draw_object(g1_draw_context_class *context)
|
---|
98 | {
|
---|
99 | if (object.valid())
|
---|
100 | {
|
---|
101 | r1_render_api_class *render_api=g1_render.r_api;
|
---|
102 |
|
---|
103 | i4_transform_class spare_transform;
|
---|
104 | object->world_transform = &spare_transform;
|
---|
105 |
|
---|
106 | object->player_num=g1_edit_state.current_team;
|
---|
107 | object->calc_world_transform(g1_render.frame_ratio);
|
---|
108 |
|
---|
109 | //setup an ambient function that returns 1.0
|
---|
110 | g1_get_ambient_function_type last_ambient_func = g1_render.get_ambient;
|
---|
111 | g1_render.get_ambient = g1_3d_object_window_ambient;
|
---|
112 |
|
---|
113 | g1_render.r_api->clear_area(0,0, width()-1, height()-1, 0, g1_far_z_range());
|
---|
114 |
|
---|
115 |
|
---|
116 | li_class_context c(object->vars);
|
---|
117 | object->draw(context);
|
---|
118 |
|
---|
119 | //put the old ambient function back
|
---|
120 | g1_render.get_ambient = last_ambient_func;
|
---|
121 |
|
---|
122 |
|
---|
123 | }
|
---|
124 | else
|
---|
125 | local_image->clear(0, *context->context);
|
---|
126 | }
|
---|
127 |
|
---|
128 | i4_bool g1_3d_object_window::selected()
|
---|
129 | {
|
---|
130 | return (i4_bool)(g1_e_object.get_object_type() == object_type);
|
---|
131 | }
|
---|
132 |
|
---|
133 | void g1_3d_object_window::do_press()
|
---|
134 | {
|
---|
135 | if (object_type>=0 && g1_object_type_array[object_type])
|
---|
136 | {
|
---|
137 | g1_edit_state.hide_focus();
|
---|
138 |
|
---|
139 | g1_e_object.set_object_type(object_type);
|
---|
140 |
|
---|
141 | if (strcmp(g1_edit_state.major_mode, "OBJECT"))
|
---|
142 | g1_edit_state.set_major_mode("OBJECT");
|
---|
143 |
|
---|
144 | if (g1_e_object.get_minor_mode() != g1_object_params::ADD)
|
---|
145 | g1_edit_state.set_minor_mode("OBJECT", g1_object_params::ADD);
|
---|
146 |
|
---|
147 | g1_edit_state.show_focus();
|
---|
148 | }
|
---|
149 | }
|
---|