traffic
[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_index ent_index;
20 typedef struct ent_marker ent_marker;
21 typedef struct ent_traffic ent_traffic;
22 typedef struct ent_font ent_font;
23 typedef struct ent_font_variant ent_font_variant;
24 typedef struct ent_glyph ent_glyph;
25
26 enum entity_alias{
27 k_ent_none = 0,
28 k_ent_gate = 1,
29 k_ent_spawn = 2,
30 k_ent_route_node = 3,
31 k_ent_route = 4,
32 k_ent_water = 5,
33 k_ent_volume = 6,
34 k_ent_audio = 7,
35 k_ent_marker = 8,
36 k_ent_font = 9,
37 k_ent_font_variant= 10,
38 k_ent_traffic = 11
39 };
40
41 static u32 mdl_entity_id_type( u32 entity_id )
42 {
43 return (entity_id & 0xffff0000) >> 16;
44 }
45
46 static u32 mdl_entity_id_id( u32 entity_id )
47 {
48 return entity_id & 0x0000ffff;
49 }
50
51 struct ent_index{
52 u32 type,
53 index;
54 };
55
56 enum entity_function{
57 k_ent_function_trigger,
58 k_ent_function_particle_spawn
59 };
60
61 struct ent_spawn{
62 mdl_transform transform;
63 u32 pstr_name;
64 };
65
66 enum light_type{
67 k_light_type_point = 0,
68 k_light_type_spot = 1
69 };
70
71 struct ent_light{
72 mdl_transform transform;
73 u32 daytime,
74 type;
75
76 v4f colour;
77 float angle,
78 range;
79
80 m4x3f inverse_world;
81 v2f angle_sin_cos;
82 };
83
84 enum gate_type{
85 k_gate_type_unlinked = 0,
86 k_gate_type_teleport = 1,
87 k_gate_type_nonlocal_unlinked = 2,
88 k_gate_type_nonlocel = 3
89 };
90
91 struct ent_gate{
92 u32 type,
93 target;
94
95 v3f dimensions,
96 co[2];
97
98 v4f q[2];
99
100 /* runtime */
101 m4x3f to_world, transport;
102
103 union{
104 u32 timing_version;
105
106 struct{
107 u8 ref_count;
108 };
109 };
110
111 double timing_time;
112 u16 routes[4]; /* routes that pass through this gate */
113 u8 route_count;
114 };
115
116 struct ent_route_node{
117 v3f co;
118 u8 ref_count, ref_total;
119 };
120
121 struct ent_path_index{
122 u16 index;
123 };
124
125 struct ent_checkpoint{
126 u16 gate_index,
127 path_start,
128 path_count;
129 };
130
131 struct ent_route{
132
133 union{
134 mdl_transform transform;
135 u32 official_track_id;
136 };
137
138 u32 pstr_name;
139 u16 checkpoints_start,
140 checkpoints_count;
141
142 v4f colour;
143
144 /* runtime */
145 u16 active_checkpoint,
146 valid_checkpoints;
147
148 float factive;
149 m4x3f board_transform;
150 mdl_submesh sm;
151 double timing_base;
152 };
153
154 struct ent_water{
155 mdl_transform transform;
156 float max_dist;
157 u32 reserved0, reserved1;
158 };
159
160 struct ent_audio_clip{
161 union{
162 mdl_file file;
163 audio_clip clip;
164 };
165
166 float probability;
167 };
168
169 struct volume_particles{
170 u32 blank, blank2;
171 };
172
173 struct volume_trigger{
174 u32 event, blank;
175 };
176
177 enum volume_subtype{
178 k_volume_subtype_trigger,
179 k_volume_subtype_particle
180 };
181
182 struct ent_volume{
183 mdl_transform transform;
184 m4x3f to_world, to_local;
185 u32 type;
186
187 ent_index target;
188
189 union{
190 volume_trigger trigger;
191 volume_particles particles;
192 };
193 };
194
195 struct ent_audio{
196 mdl_transform transform;
197 u32 flags,
198 clip_start,
199 clip_count;
200 float volume, crossfade;
201 u32 behaviour,
202 group,
203 probability_curve,
204 max_channels;
205 };
206
207 struct ent_marker{
208 mdl_transform transform;
209 u32 pstr_alias;
210 };
211
212 struct ent_traffic{
213 mdl_transform transform;
214 u32 submesh_start,
215 submesh_count,
216 start_node,
217 node_count;
218 float speed,
219 t;
220 u32 index; /* into the path */
221 };
222
223 VG_STATIC ent_marker *ent_find_marker( mdl_context *mdl,
224 mdl_array_ptr *arr, const char *alias )
225 {
226 for( u32 i=0; i<mdl_arrcount(arr); i++ ){
227 ent_marker *marker = mdl_arritm( arr, i );
228
229 if( !strcmp( mdl_pstr( mdl, marker->pstr_alias ), alias ) ){
230 return marker;
231 }
232 }
233
234 return NULL;
235 }
236
237 enum channel_behaviour{
238 k_channel_behaviour_unlimited = 0,
239 k_channel_behaviour_discard_if_full = 1,
240 k_channel_behaviour_crossfade_if_full = 2
241 };
242
243 enum probability_curve{
244 k_probability_curve_constant = 0,
245 k_probability_curve_wildlife_day = 1,
246 k_probability_curve_wildlife_night = 2
247 };
248
249 struct ent_font{
250 u32 alias,
251 variant_start,
252 variant_count,
253 glyph_start,
254 glyph_count,
255 glyph_utf32_base;
256 };
257
258 struct ent_font_variant{
259 u32 name,
260 material_id;
261 };
262
263 struct ent_glyph{
264 v2f size;
265 u32 indice_start,
266 indice_count;
267 };
268
269 #endif /* ENTITY_H */