new menu start
[carveJwlIkooP6JGAAIwe30JlM.git] / entity.h
1 #ifndef ENTITY_H
2 #define ENTITY_H
3
4 #include "model.h"
5
6 typedef struct ent_spawn ent_spawn;
7 typedef struct ent_light ent_light;
8 typedef struct ent_gate ent_gate;
9 typedef struct ent_route_node ent_route_node;
10 typedef struct ent_path_index ent_path_index;
11 typedef struct ent_checkpoint ent_checkpoint;
12 typedef struct ent_route ent_route;
13 typedef struct ent_water ent_water;
14 typedef struct ent_audio_clip ent_audio_clip;
15 typedef struct volume_particles volume_particles;
16 typedef struct volume_trigger volume_trigger;
17 typedef struct ent_volume ent_volume;
18 typedef struct ent_audio ent_audio;
19 typedef struct ent_marker ent_marker;
20 typedef struct ent_traffic ent_traffic;
21 typedef struct ent_font ent_font;
22 typedef struct ent_font_variant ent_font_variant;
23 typedef struct ent_glyph ent_glyph;
24 typedef struct ent_skateshop ent_skateshop;
25 typedef struct ent_camera ent_camera;
26 typedef struct ent_swspreview ent_swspreview;
27
28 enum entity_alias{
29 k_ent_none = 0,
30 k_ent_gate = 1,
31 k_ent_spawn = 2,
32 k_ent_route_node = 3,
33 k_ent_route = 4,
34 k_ent_water = 5,
35 k_ent_volume = 6,
36 k_ent_audio = 7,
37 k_ent_marker = 8,
38 k_ent_font = 9,
39 k_ent_font_variant= 10,
40 k_ent_traffic = 11,
41 k_ent_skateshop = 12,
42 k_ent_camera = 13,
43 k_ent_swspreview = 14,
44 k_ent_menuitem = 15
45 };
46
47 static u32 mdl_entity_id_type( u32 entity_id )
48 {
49 return (entity_id & 0xffff0000) >> 16;
50 }
51
52 static u32 mdl_entity_id_id( u32 entity_id )
53 {
54 return entity_id & 0x0000ffff;
55 }
56
57 static u32 mdl_entity_id( u32 type, u32 index )
58 {
59 return (type & 0xfffff)<<16 | (index & 0xfffff);
60 }
61
62 enum entity_function{
63 k_ent_function_trigger,
64 k_ent_function_particle_spawn
65 };
66
67 struct ent_spawn{
68 mdl_transform transform;
69 u32 pstr_name;
70 };
71
72 enum light_type{
73 k_light_type_point = 0,
74 k_light_type_spot = 1
75 };
76
77 struct ent_light{
78 mdl_transform transform;
79 u32 daytime,
80 type;
81
82 v4f colour;
83 float angle,
84 range;
85
86 m4x3f inverse_world;
87 v2f angle_sin_cos;
88 };
89
90 enum gate_type{
91 k_gate_type_unlinked = 0,
92 k_gate_type_teleport = 1,
93 k_gate_type_nonlocal_unlinked = 2,
94 k_gate_type_nonlocel = 3
95 };
96
97 struct ent_gate{
98 u32 type,
99 target;
100
101 v3f dimensions,
102 co[2];
103
104 v4f q[2];
105
106 /* runtime */
107 m4x3f to_world, transport;
108
109 union{
110 u32 timing_version;
111
112 struct{
113 u8 ref_count;
114 };
115 };
116
117 double timing_time;
118 u16 routes[4]; /* routes that pass through this gate */
119 u8 route_count;
120 };
121
122 struct ent_route_node{
123 v3f co;
124 u8 ref_count, ref_total;
125 };
126
127 struct ent_path_index{
128 u16 index;
129 };
130
131 struct ent_checkpoint{
132 u16 gate_index,
133 path_start,
134 path_count;
135 };
136
137 struct ent_route{
138
139 union{
140 mdl_transform transform;
141 u32 official_track_id;
142 };
143
144 u32 pstr_name;
145 u16 checkpoints_start,
146 checkpoints_count;
147
148 v4f colour;
149
150 /* runtime */
151 u16 active_checkpoint,
152 valid_checkpoints;
153
154 float factive;
155 m4x3f board_transform;
156 mdl_submesh sm;
157 double timing_base;
158 };
159
160 struct ent_water{
161 mdl_transform transform;
162 float max_dist;
163 u32 reserved0, reserved1;
164 };
165
166 struct ent_audio_clip{
167 union{
168 mdl_file file;
169 audio_clip clip;
170 };
171
172 float probability;
173 };
174
175 struct volume_particles{
176 u32 blank, blank2;
177 };
178
179 struct volume_trigger{
180 u32 event, blank;
181 };
182
183 enum volume_subtype{
184 k_volume_subtype_trigger,
185 k_volume_subtype_particle
186 };
187
188 struct ent_volume{
189 mdl_transform transform;
190 m4x3f to_world, to_local;
191 u32 type;
192
193 u32 target;
194
195 union{
196 volume_trigger trigger;
197 volume_particles particles;
198 };
199 };
200
201 struct ent_audio{
202 mdl_transform transform;
203 u32 flags,
204 clip_start,
205 clip_count;
206 float volume, crossfade;
207 u32 behaviour,
208 group,
209 probability_curve,
210 max_channels;
211 };
212
213 struct ent_marker{
214 mdl_transform transform;
215 u32 pstr_alias;
216 };
217
218 struct ent_skateshop{
219 mdl_transform transform;
220 u32 id_display,
221 id_info,
222 id_rack,
223 id_camera;
224 };
225
226 struct ent_swspreview{
227 u32 id_camera, id_display, id_display1;
228 };
229
230 struct ent_traffic{
231 mdl_transform transform;
232 u32 submesh_start,
233 submesh_count,
234 start_node,
235 node_count;
236 float speed,
237 t;
238 u32 index; /* into the path */
239 };
240
241 struct ent_camera{
242 mdl_transform transform;
243 float fov;
244 };
245
246 enum ent_menuitem_type{
247 k_ent_menuitem_type_visual = 0,
248 k_ent_menuitem_type_event_button = 1,
249 k_ent_menuitem_type_page_button = 2,
250 k_ent_menuitem_type_toggle = 3,
251 k_ent_menuitem_type_slider = 4,
252 k_ent_menuitem_type_page = 5
253 };
254
255 typedef struct ent_menuitem ent_menuitem;
256 struct ent_menuitem{
257 u32 type, groups,
258 id_links[4]; /* ent_menuitem */
259
260 mdl_transform transform;
261 u32 submesh_start, submesh_count;
262
263 union{
264 struct{
265 u32 id_min, /* ent_marker */
266 id_max, /* . */
267 id_handle, /* ent_menuitem */
268 pstr_data;
269 }
270 slider;
271
272 struct{
273 u32 pstr;
274 }
275 button;
276
277 struct{
278 u32 id_check, /* ent_menuitem */
279 pstr_data;
280 }
281 checkmark;
282
283 struct{
284 u32 pstr_name,
285 id_entrypoint, /* ent_menuitem */
286 id_viewpoint; /* ent_camera */
287 }
288 page;
289 };
290 };
291
292 VG_STATIC ent_marker *ent_find_marker( mdl_context *mdl,
293 mdl_array_ptr *arr, const char *alias )
294 {
295 for( u32 i=0; i<mdl_arrcount(arr); i++ ){
296 ent_marker *marker = mdl_arritm( arr, i );
297
298 if( !strcmp( mdl_pstr( mdl, marker->pstr_alias ), alias ) ){
299 return marker;
300 }
301 }
302
303 return NULL;
304 }
305
306 enum channel_behaviour{
307 k_channel_behaviour_unlimited = 0,
308 k_channel_behaviour_discard_if_full = 1,
309 k_channel_behaviour_crossfade_if_full = 2
310 };
311
312 enum probability_curve{
313 k_probability_curve_constant = 0,
314 k_probability_curve_wildlife_day = 1,
315 k_probability_curve_wildlife_night = 2
316 };
317
318 struct ent_font{
319 u32 alias,
320 variant_start,
321 variant_count,
322 glyph_start,
323 glyph_count,
324 glyph_utf32_base;
325 };
326
327 struct ent_font_variant{
328 u32 name,
329 material_id;
330 };
331
332 struct ent_glyph{
333 v2f size;
334 u32 indice_start,
335 indice_count;
336 };
337
338
339 typedef struct ent_call ent_call;
340 struct ent_call{
341 u32 id, function;
342 void *data;
343 };
344
345 #include "world.h"
346
347 #endif /* ENTITY_H */