1 /*
2 			    SAR Objects and Scene
3  */
4 
5 #ifndef OBJ_H
6 #define OBJ_H
7 
8 #include <sys/types.h>
9 
10 #include "sfm.h"
11 #include "v3dtex.h"
12 #include "sound.h"
13 
14 
15 /*
16  *	Object Flags Type:
17  */
18 #define sar_obj_flags_t	unsigned long
19 
20 /*
21  *	Gradient Animation Counter Type:
22  */
23 #define sar_grad_anim_t	u_int16_t
24 #define SAR_GRAD_ANIM_COEFF(x)	((float)(x) / (float)((sar_grad_anim_t)-1))
25 
26 /*
27  *	DMS Units Type:
28  */
29 #define sar_dms_t	float
30 
31 /*
32  *	Time Of Day Codes:
33  */
34 typedef enum {
35 	SAR_TOD_CODE_UNDEFINED,
36 	SAR_TOD_CODE_DAY,
37 	SAR_TOD_CODE_DAWN,
38 	SAR_TOD_CODE_NIGHT,
39 	SAR_TOD_CODE_DUSK
40 } sar_tod_code;
41 
42 /*
43  *	Camera References:
44  */
45 typedef enum {
46 	SAR_CAMERA_REF_COCKPIT,
47 	SAR_CAMERA_REF_SPOT,
48 	SAR_CAMERA_REF_TOWER,
49 	SAR_CAMERA_REF_MAP,
50 	SAR_CAMERA_REF_HOIST
51 } sar_camera_ref;
52 
53 
54 /*
55  *	Air Worthy States:
56  */
57 typedef enum {
58 	SAR_AIR_WORTHY_NOT_FLYABLE,	/* Pile of junk */
59 	SAR_AIR_WORTHY_OUT_OF_CONTROL,
60 	SAR_AIR_WORTHY_FLYABLE
61 } sar_air_worthy_state;
62 
63 /*
64  *	Engine States:
65  */
66 typedef enum {
67 	SAR_ENGINE_OFF,
68 	SAR_ENGINE_INIT,
69 	SAR_ENGINE_ON
70 } sar_engine_state;
71 
72 /*
73  *	Autopilot States:
74  */
75 typedef enum {
76 	SAR_AUTOPILOT_OFF,
77 	SAR_AUTOPILOT_ON
78 } sar_autopilot_state;
79 
80 /*
81  *	Human color palette index and max:
82  */
83 #define SAR_HUMAN_COLOR_FACE            0
84 #define SAR_HUMAN_COLOR_HAIR            1
85 #define SAR_HUMAN_COLOR_TORSO           2
86 #define SAR_HUMAN_COLOR_HIPS            3
87 #define SAR_HUMAN_COLOR_LEGS            4
88 #define SAR_HUMAN_COLOR_FEET            5
89 #define SAR_HUMAN_COLOR_ARMS            6
90 #define SAR_HUMAN_COLOR_HANDS           7
91 
92 #define SAR_HUMAN_COLORS_MAX            8
93 
94 
95 /*
96  *	Color:
97  *
98  *	Each member must be of type float and their order is
99  *	important, units are in coefficients from 0.0 to 1.0.
100  */
101 typedef struct {
102 	float		r, g, b, a;
103 } sar_color_struct;
104 #define SAR_COLOR(p)	((sar_color_struct *)(p))
105 
106 
107 /*
108  *	Visual Model:
109  *
110  *	Values for a GL display list with reference count feature that
111  *	allows other objects to share this visual model simply by
112  *	incrementing the ref_count.  The GL display list pointer data
113  *	reffers to a GLuint.
114  *
115  *	Members filename and name are used to identify if this visual
116  *	model should be shared or not by allowing you to check if
117  *	another object uses this same visual model.
118  */
119 typedef enum {
120 	SAR_VISUAL_MODEL_NOT_LOADED,
121 	SAR_VISUAL_MODEL_LOADING,
122 	SAR_VISUAL_MODEL_LOADED
123 } sar_visual_model_load_state;
124 typedef struct {
125 
126 	sar_visual_model_load_state	load_state;
127 
128 	int		ref_count;	/* Reference count */
129 
130 	char		*filename;	/* Can be NULL */
131 	char		*name;		/* Can be NULL */
132 
133 	void		*data;		/* A GLuint referencing a GL list */
134 
135 	/* Statistics */
136 	unsigned long	mem_size;	/* Memory size, in bytes */
137 	int		statements,	/* Total GL statements */
138 			primitives;	/* Total GL primitives */
139 
140 } sar_visual_model_struct;
141 #define SAR_VISUAL_MODEL(p)	((sar_visual_model_struct *)(p))
142 
143 
144 /*
145  *	Position/Velocity:
146  *
147  *	Each member must be of type float and their order is
148  *	important.
149  *
150  *	When used as position the units are in meters, when used as
151  *	velocity the units are in meters per cycle.
152  */
153 typedef struct {
154 	float		x, y, z;
155 } sar_position_struct;
156 #define SAR_POSITION(p)		((sar_position_struct *)(p))
157 
158 /*
159  *	Direction:
160  *
161  *	Each member must be of type float and their order is
162  *	important, units are in radians.
163  */
164 typedef struct {
165 	float		heading, pitch, bank;
166 } sar_direction_struct;
167 #define SAR_DIRECTION(p)	((sar_direction_struct *)(p))
168 
169 /*
170  *	Scale:
171  *
172  *	Each member must be of type float and their order is
173  *	important, units are in coefficients.
174  */
175 typedef struct {
176 	float		x, y, z;
177 } sar_scale_struct;
178 #define SAR_SCALE(p)		((sar_scale_struct *)(p))
179 
180 
181 /*
182  *	Intercept:
183  */
184 typedef struct {
185 	sar_obj_flags_t	flags;		/* Reserved */
186 	float		x, y, z;	/* Center of intercept, in meters */
187 	float		radius;		/* Cylendrical size of intercept, in meters */
188 	float		urgency;	/* Specifies the "urgency" of which this
189 					 * intercept must be reached (used for a
190 					 * variety of purposes) */
191 	char		*name;		/* Intercept name/label */
192 } sar_intercept_struct;
193 #define SAR_INTERCEPT(p)	((sar_intercept_struct *)(p))
194 
195 
196 /*
197  *	Light:
198  */
199 typedef struct {
200 
201 #define SAR_LIGHT_FLAG_ON		(1 << 0)
202 #define SAR_LIGHT_FLAG_STROBE		(1 << 1)
203 #define SAR_LIGHT_FLAG_ATTENUATE	(1 << 2)
204 	sar_obj_flags_t	flags;
205 
206 	sar_position_struct	pos;
207 	sar_direction_struct	dir;
208 
209 	int		radius;		/* In pixels */
210 
211 	sar_color_struct	color,			/* Appearance color */
212 				attenuate_color;	/* Attenuate color */
213 
214 	/* On/off timers (if the SAR_LIGHT_FLAG_STROBE flag is set)
215 	 * in milliseconds
216 	 */
217 	time_t		next_on, int_on,
218 			next_off, int_off;
219 	time_t		int_delay_on;	/* Additional interval to wait
220 					 * before turning light on when
221 					 * timer is reset */
222 } sar_light_struct;
223 #define SAR_LIGHT(p)	((sar_light_struct *)(p))
224 
225 
226 /*
227  *	Contact Bounds:
228  *
229  *	Note that any object can have contact bounds, but rules apply
230  *	to different object types.
231  *
232  *	Objects of type SAR_OBJ_TYPE_HUMAN and SAR_OBJ_TYPE_AIRCRAFT
233  *	should only have crash flag SAR_CRASH_FLAG_CRASH_OTHER set and
234  *	it's contact shape must be SAR_CONTACT_SHAPE_CYLENDRICAL.
235  *
236  *	Other objects that you want to set crash flag
237  *	SAR_CRASH_FLAG_CRASH_CAUSE can have any contact shape.
238  *
239  *	Now objects that you want to be landable or walkable must have
240  *	crash flag SAR_CRASH_FLAG_SUPPORT_SURFACE set.
241  *
242  *	If an object's crash flag has set
243  *	SAR_CRASH_FLAG_SUPPORT_SURFACE then the object can only have its
244  *	heading rotated.
245  */
246 typedef enum {
247 	SAR_CRASH_TYPE_OBSTRUCTION,
248 	SAR_CRASH_TYPE_GROUND,
249 	SAR_CRASH_TYPE_MOUNTAIN,		/* To be more specific than
250 						 * just ground */
251 	SAR_CRASH_TYPE_BUILDING,
252 	SAR_CRASH_TYPE_AIRCRAFT,		/* Not used */
253         SAR_CRASH_TYPE_FIRE
254 } sar_crash_type;
255 
256 typedef enum {
257 	SAR_CONTACT_SHAPE_SPHERICAL,
258 	SAR_CONTACT_SHAPE_CYLENDRICAL,
259 	SAR_CONTACT_SHAPE_RECTANGULAR
260 } sar_contact_shape;
261 
262 typedef struct {
263 
264 #define SAR_CRASH_FLAG_CRASH_OTHER      (1 << 0)	/* Crash into or contact
265 							 * other objects */
266 #define SAR_CRASH_FLAG_CRASH_CAUSE      (1 << 1)	/* Other objects can
267 							 * crash into this
268 							 * object */
269 #define SAR_CRASH_FLAG_SUPPORT_SURFACE	(1 << 2)	/* Landable/walkable */
270 	sar_obj_flags_t	crash_flags;
271 
272 	/* Crash Type (used only if the Crash Flag
273 	 * SAR_CRASH_FLAG_CRASH_CAUSE is set), this specifies what type
274 	 * of crash it would be if an object crashed into this object
275 	 */
276 	sar_crash_type	crash_type;
277 
278 	/* Contact Shape */
279 	sar_contact_shape	contact_shape;
280 
281 	/* Contact Radius (in meters) for Contact Shape
282 	 * SAR_CONTACT_SHAPE_SPHERICAL or SAR_CONTACT_SHAPE_CYLENDRICAL
283 	 */
284 	float		contact_radius;
285 
286 	/* Contact Height (in meters) for Contact Shape
287 	 * SAR_CONTACT_SHAPE_CYLENDRICAL
288 	 */
289 	float		contact_h_min,
290 			contact_h_max;
291 
292 	/* Contact Geometry (in meters, left hand rule) for Contact
293 	 * Shape SAR_CONTACT_SHAPE_RECTANGULAR
294 	 */
295 	float		contact_x_min, contact_x_max,
296 			contact_y_min, contact_y_max,
297 			contact_z_min, contact_z_max;
298 
299 	/* Value records for the object's inversed heading for the trig
300 	 * functions, this is used to speed up rotations about heading
301 	 * for SAR_CONTACT_SHAPE_RECTANGULAR shape contact
302 	 *
303 	 * Ie cos_heading = cos(-heading) and sin_heading = sin(-heading)
304 	 */
305 	float		cos_heading,
306 			sin_heading;
307 
308 } sar_contact_bounds_struct;
309 #define SAR_CONTACT_BOUNDS(p)	((sar_contact_bounds_struct *)(p))
310 
311 
312 /*
313  *	Sound Source:
314  */
315 typedef struct {
316 
317 	char		*name;		/* Arbitary name to identify this
318 					 * in a list of sound sources */
319 
320 	char		*filename,	/* Full path to sound object */
321 			*filename_far;
322 
323 	float		range,		/* Maximum range (in meters) */
324 			range_far;	/* Play far sound if beyond this
325 					 * range (in meters) */
326 
327 	sar_position_struct	pos;	/* Offset from center of object */
328 
329 	float		cutoff;		/* Cutoff angle (in radians),
330 					 * can be 0.0 to specify "in all
331 					 * directions" */
332 	sar_direction_struct	dir;	/* Direction, used only if cutoff
333 					 * is positive */
334 
335 	/* Sample rate limit, the amount that the sample rate can
336 	 * increase to
337 	 *
338 	 * For example if the sound object's sample rate is 11025 hz
339 	 * and sample_rate_limit is 30000 hz, then the sound object's
340 	 * sample rate can be increased from 11025 to 30000 hz
341 	 */
342 	int		sample_rate_limit;
343 
344 } sar_sound_source_struct;
345 #define SAR_SOUND_SOURCE(p)	((sar_sound_source_struct *)(p))
346 
347 
348 /*
349  *	Rotor/Propellar:
350  */
351 typedef enum {
352 	SAR_ROTOR_FLAG_SPINS		= (1 << 0),
353 	SAR_ROTOR_FLAG_CAN_PITCH	= (1 << 1),
354 	SAR_ROTOR_FLAG_PITCH_STATE	= (1 << 2),	/* Set if pitched forward
355 							 * (does not determine
356 							 * flight model type) */
357 	SAR_ROTOR_FLAG_NO_PITCH_LANDED	= (1 << 3),	/* May not pitch when
358 							 * landed */
359 	SAR_ROTOR_FLAG_FOLLOW_CONTROLS	= (1 << 5),	/* Pitches & banks in
360 							 * response to control
361 							 * positions */
362 	SAR_ROTOR_FLAG_BLUR_WHEN_FAST	= (1 << 8),	/* Blur when spinning
363 							 * fast */
364 	SAR_ROTOR_FLAG_BLUR_ALWAYS	= (1 << 9)	/* Always blur (overrides
365 							 * SAR_ROTOR_FLAG_BLUR_WHEN_FAST */
366 } sar_rotor_flags;
367 typedef struct {
368 
369 	sar_rotor_flags	flags;
370 
371 	sar_position_struct	pos;	/* Relative from center of object */
372 	sar_direction_struct	dir;	/* Note: rotor spins about the Y axis */
373 
374 	float		radius;		/* Length of longest blade (in meters) */
375 	float		blades_offset;	/* Blades offset from rotor (in meters) */
376 	int		total_blades;	/* Number of blades */
377 
378 	sar_grad_anim_t	anim_pos;	/* Spin animation position */
379 
380 	sar_visual_model_struct	*visual_model,
381 				*visual_model_ir;
382 
383 	/* Rotor pitch rotate position (0 to (sar_grad_anim_t)-1),
384 	 * where (sar_grad_anim_t)-1 is pitched forwards
385 	 * (when SAR_ROTOR_FLAG_PITCH_STATE is set)
386 	 */
387 	sar_grad_anim_t	pitch_anim_pos;
388 
389 	/* Rotor wash animation position */
390 	sar_grad_anim_t	rotor_wash_anim_pos;
391 
392 	int		blade_blur_tex_num,	/* Blured blade texture */
393 			wash_tex_num;		/* Prop wash texture */
394 
395 	/* Control position coefficients (used only if
396 	 * SAR_ROTOR_FLAG_FOLLOW_PB is set)
397 	 */
398 	float		control_coeff_pitch,
399 			control_coeff_bank;
400 
401 	/* Blades blur color (used when blades are spinning fast) */
402 	sar_color_struct	blades_blur_color;
403 
404 } sar_obj_rotor_struct;
405 #define SAR_OBJ_ROTOR(p)	((sar_obj_rotor_struct *)(p))
406 
407 
408 /*
409  *	Object Part:
410  *
411  *	Flaps, ailerons, elevator, rudder, air brakes, landing gears,
412  *	canopies, etc
413  */
414 typedef enum {
415 	SAR_OBJ_PART_TYPE_AILERON_LEFT,
416 	SAR_OBJ_PART_TYPE_AILERON_RIGHT,
417 	SAR_OBJ_PART_TYPE_RUDDER_TOP,
418 	SAR_OBJ_PART_TYPE_RUDDER_BOTTOM,
419 	SAR_OBJ_PART_TYPE_ELEVATOR,
420 	SAR_OBJ_PART_TYPE_CANNARD,			/* Forward elevator */
421 	SAR_OBJ_PART_TYPE_AILERON_ELEVATOR_LEFT,	/* Combo */
422 	SAR_OBJ_PART_TYPE_AILERON_ELEVATOR_RIGHT,	/* Combo */
423 	SAR_OBJ_PART_TYPE_FLAP,
424 	SAR_OBJ_PART_TYPE_AIR_BRAKE,
425 	SAR_OBJ_PART_TYPE_DOOR,
426 	SAR_OBJ_PART_TYPE_DOOR_RESCUE,
427 	SAR_OBJ_PART_TYPE_CANOPY,
428 	SAR_OBJ_PART_TYPE_LANDING_GEAR
429 } sar_obj_part_type;
430 
431 typedef struct {
432 
433 	sar_obj_part_type	type;
434 
435 /* Part Flags (different part types may have the same part flag
436  * values)
437  */
438 #define SAR_OBJ_PART_FLAG_STATE		(1 << 0)	/* Set if opened/extended */
439 #define SAR_OBJ_PART_FLAG_HIDE_MIN	(1 << 1)	/* Hide when animation value is at min */
440 #define SAR_OBJ_PART_FLAG_HIDE_MAX	(1 << 2)	/* Hide when animation value is at max */
441 /* Doors, Rescue Doors, and Canopies */
442 #define SAR_OBJ_PART_FLAG_DOOR_FIXED	(1 << 3)	/* True if fixed (always closed) */
443 #define SAR_OBJ_PART_FLAG_DOOR_LOCKED	(1 << 4)	/* True if locked */
444 #define SAR_OBJ_PART_FLAG_DOOR_STAY_OPEN	(1 << 5)	/* Do not close door on
445 								 * next loop check,
446 								 * ie if door was opened by player explicitly */
447 /* Landing Gears */
448 #define SAR_OBJ_PART_FLAG_LGEAR_FIXED	(1 << 3)	/* Always down */
449 #define SAR_OBJ_PART_FLAG_LGEAR_DAMAGED	(1 << 4)
450 #define SAR_OBJ_PART_FLAG_LGEAR_MISSING	(1 << 5)	/* Non-existant */
451 #define SAR_OBJ_PART_FLAG_LGEAR_SKI	(1 << 6)
452 #define SAR_OBJ_PART_FLAG_LGEAR_FLOATS	(1 << 7)	/* Can land on water */
453 	sar_obj_flags_t	flags;
454 
455 	/* Offset relative to center of object, pos_min and pos_max
456 	 * are deltas relative to pos_cen
457 	 *
458 	 * Note that some part types interprite these values differently
459 	 */
460 	sar_position_struct	pos_min,
461 				pos_cen,
462 				pos_max;
463 
464 	/* Direction, dir_min and dir_max are deltas relative to
465 	 * dir_cen
466 	 *
467 	 * Note that some part types interprite these values differently
468 	 */
469 	sar_direction_struct	dir_min,
470 				dir_cen,
471 				dir_max;
472 
473 	sar_grad_anim_t anim_pos,       /* 0 to (sar_grad_anim_t)-1 */
474 			anim_rate;      /* Units per cycle */
475 
476 	float		temperature;
477 
478 	sar_visual_model_struct	*visual_model,
479 				*visual_model_ir;
480 
481 } sar_obj_part_struct;
482 #define SAR_OBJ_PART(p)		((sar_obj_part_struct *)(p))
483 
484 
485 /*
486  *	External Fuel Tank:
487  *
488  *	This is a fuel tank that is on an object.
489  *
490  *	See sar_object_fueltank_struct (which is a fuel tank object).
491  */
492 typedef struct {
493 
494 #define SAR_EXTERNAL_FUELTANK_FLAG_FIXED	(1 << 0)	/* Not droppable */
495 #define SAR_EXTERNAL_FUELTANK_FLAG_ONBOARD	(1 << 1)	/* Not yet jettesoned */
496 	sar_obj_flags_t	flags;
497 
498 	/* Offset from center of object, in meters */
499 	sar_position_struct	offset_pos;
500 
501 	/* Spherical contact bounds radius, in meters */
502 	float		radius;
503 
504 	/* Belly to center height, in meters */
505 	float		belly_to_center_height;
506 
507 	/* Mass and fuel, in kg */
508 	float		dry_mass,
509 			fuel,
510 			fuel_max;
511 
512 	float		temperature;
513 
514 	sar_visual_model_struct	*visual_model,
515 				*visual_model_ir;
516 
517 } sar_external_fueltank_struct;
518 #define SAR_EXTERNAL_FUELTANK(p)	((sar_external_fueltank_struct *)(p))
519 
520 
521 /*
522  *	Hoist:
523  */
524 typedef enum {
525 	SAR_HOIST_DEPLOYMENT_BASKET	= (1 << 0),
526 	SAR_HOIST_DEPLOYMENT_DIVER	= (1 << 1),
527 	SAR_HOIST_DEPLOYMENT_HOOK	= (1 << 2)
528 } sar_hoist_deployment_flags;
529 typedef struct {
530 
531 	/* Offset from center of object */
532 	sar_position_struct	offset;
533 
534 	/* Position (not offset) of basket */
535 	sar_position_struct	pos;
536 
537 	/* Direction of basket */
538 	sar_direction_struct	dir;
539 
540 	/* Rope extension (if <= 0.0 then implies the rope is fully
541 	 * retracted)
542 	 */
543 	float		rope_cur,	/* In meters */
544 			rope_max;
545 	float		rope_rate;	/* In meters per cycle */
546 
547 	/* Rope visual extension, since rope_cur may be longer than the
548 	 * distance to the landable ground (in meters) we need to use
549 	 * this value when drawing
550 	 */
551 	float		rope_cur_vis;
552 
553 	/* Indicates rope end is in contact with ground */
554 	char		on_ground;
555 
556 	/* Hoist deployment */
557 	sar_hoist_deployment_flags	deployments,	/* Available deployments */
558 					cur_deployment;	/* Selected deployment */
559 
560 	/* Cylendrical contact area of rescue basket, in meters */
561 	float		contact_radius,
562 			contact_z_min,
563 			contact_z_max;
564 
565 	/* Load capacity, in kg */
566 	float		capacity;
567 
568 	/* Reference to occupant human object index numbers (does not
569 	 * include the diver)
570 	 */
571 	int		*occupant;
572 	int		total_occupants;
573 
574 	/* Total mass of occupant object(s) in kg, this is to speed up
575 	 * calculations. The value is updated when a new occupant object
576 	 * is added to the hoist and reset to 0 when the hoist is deployed
577 	 * the next time.
578 	 */
579 	float		occupants_mass;
580 
581 	/* Texture reference numbers on scene structure */
582 	int		side_tex_num,
583 			end_tex_num,
584 			bottom_tex_num,
585 			water_ripple_tex_num;
586 
587 	/* Diver color palette */
588 	sar_color_struct	diver_color[SAR_HUMAN_COLORS_MAX];
589 
590 	/* Animation position and rate */
591 	sar_grad_anim_t	anim_pos,
592 			anim_rate;
593 
594 } sar_obj_hoist_struct;
595 #define SAR_OBJ_HOIST(p)	((sar_obj_hoist_struct *)(p))
596 
597 
598 
599 /*
600  *	Object Types:
601  */
602 typedef enum {
603 	SAR_OBJ_TYPE_GARBAGE		= 0,
604 	SAR_OBJ_TYPE_STATIC		= 1,
605 	SAR_OBJ_TYPE_AUTOMOBILE		= 2,
606 	SAR_OBJ_TYPE_WATERCRAFT		= 3,
607 	SAR_OBJ_TYPE_AIRCRAFT		= 4,
608 /* Note type 5 used to be airplane, it's now changed to be part of
609  * type 4 (which was helicopter) so both 4 and 5 are all flying things
610  * now */
611 	SAR_OBJ_TYPE_GROUND		= 6,	/* Cylendrical landable object */
612 	SAR_OBJ_TYPE_RUNWAY		= 7,
613 	SAR_OBJ_TYPE_HELIPAD		= 8,
614 	SAR_OBJ_TYPE_HUMAN		= 9,
615 	SAR_OBJ_TYPE_SMOKE		= 10,
616 	SAR_OBJ_TYPE_FIRE		= 11,
617 	SAR_OBJ_TYPE_EXPLOSION		= 12,
618 	SAR_OBJ_TYPE_CHEMICAL_SPRAY	= 13,	/* Water, fire-retardant, etc */
619 	SAR_OBJ_TYPE_FUELTANK		= 14,	/* Fuel tank dropped from an
620 						 * aircraft */
621 	SAR_OBJ_TYPE_PREMODELED		= 20
622 } sar_obj_type;
623 
624 
625 /*
626  *	Object Type Check macros:
627  */
628 #define SAR_OBJ_IS_STATIC(p)	\
629 (((p) != NULL) ? ((*(sar_obj_type *)(p)) == SAR_OBJ_TYPE_STATIC) : 0)
630 
631 #define SAR_OBJ_IS_AUTOMOBILE(p)	\
632 (((p) != NULL) ? ((*(sar_obj_type *)(p)) == SAR_OBJ_TYPE_AUTOMOBILE) : 0)
633 
634 #define SAR_OBJ_IS_WATERCRAFT(p)	\
635 (((p) != NULL) ? ((*(sar_obj_type *)(p)) == SAR_OBJ_TYPE_WATERCRAFT) : 0)
636 
637 #define SAR_OBJ_IS_AIRCRAFT(p)	\
638 (((p) != NULL) ? ((*(sar_obj_type *)(p)) == SAR_OBJ_TYPE_AIRCRAFT) : 0)
639 
640 #define SAR_OBJ_IS_GROUND(p)	\
641 (((p) != NULL) ? ((*(sar_obj_type *)(p)) == SAR_OBJ_TYPE_GROUND) : 0)
642 
643 #define SAR_OBJ_IS_RUNWAY(p)	\
644 (((p) != NULL) ? ((*(sar_obj_type *)(p)) == SAR_OBJ_TYPE_RUNWAY) : 0)
645 
646 #define SAR_OBJ_IS_HELIPAD(p)	\
647 (((p) != NULL) ? ((*(sar_obj_type *)(p)) == SAR_OBJ_TYPE_HELIPAD) : 0)
648 
649 #define SAR_OBJ_IS_HUMAN(p)	\
650 (((p) != NULL) ? ((*(sar_obj_type *)(p)) == SAR_OBJ_TYPE_HUMAN) : 0)
651 
652 #define SAR_OBJ_IS_SMOKE(p)	\
653 (((p) != NULL) ? ((*(sar_obj_type *)(p)) == SAR_OBJ_TYPE_SMOKE) : 0)
654 
655 #define SAR_OBJ_IS_FIRE(p)	\
656 (((p) != NULL) ? ((*(sar_obj_type *)(p)) == SAR_OBJ_TYPE_FIRE) : 0)
657 
658 #define SAR_OBJ_IS_EXPLOSION(p)	\
659 (((p) != NULL) ? ((*(sar_obj_type *)(p)) == SAR_OBJ_TYPE_EXPLOSION) : 0)
660 
661 #define SAR_OBJ_IS_CHEMICAL_SPRAY(p)	\
662 (((p) != NULL) ? ((*(sar_obj_type *)(p)) == SAR_OBJ_TYPE_CHEMICAL_SPRAY) : 0)
663 
664 #define SAR_OBJ_IS_FUELTANK(p)	\
665 (((p) != NULL) ? ((*(sar_obj_type *)(p)) == SAR_OBJ_TYPE_FUELTANK) : 0)
666 
667 #define SAR_OBJ_IS_PREMODELED(p)	\
668 (((p) != NULL) ? ((*(sar_obj_type *)(p)) == SAR_OBJ_TYPE_PREMODELED) : 0)
669 
670 
671 /*
672  *	Object Type Substructure Pointer Get macros:
673  *
674  *	These macros will return a pointer to the substructure (member
675  *	data) with cast or NULL if the given object pointer is NULL or
676  *	not of the corresponding type.
677  */
678 #define SAR_OBJ_GET_STATIC(p)	\
679 (sar_object_static_struct *)((SAR_OBJ_IS_STATIC(p)) ? \
680  ((sar_object_struct *)(p))->data : NULL \
681 )
682 
683 #define SAR_OBJ_GET_AIRCRAFT(p)	\
684 (sar_object_aircraft_struct *)((SAR_OBJ_IS_AIRCRAFT(p)) ? \
685  ((sar_object_struct *)(p))->data : NULL \
686 )
687 
688 #define SAR_OBJ_GET_GROUND(p)	\
689 (sar_object_ground_struct *)((SAR_OBJ_IS_GROUND(p)) ? \
690  ((sar_object_struct *)(p))->data : NULL \
691 )
692 
693 #define SAR_OBJ_GET_RUNWAY(p)	\
694 (sar_object_runway_struct *)((SAR_OBJ_IS_RUNWAY(p)) ? \
695  ((sar_object_struct *)(p))->data : NULL \
696 )
697 
698 #define SAR_OBJ_GET_HELIPAD(p)	\
699 (sar_object_helipad_struct *)((SAR_OBJ_IS_HELIPAD(p)) ? \
700  ((sar_object_struct *)(p))->data : NULL \
701 )
702 
703 #define SAR_OBJ_GET_HUMAN(p)	\
704 (sar_object_human_struct *)((SAR_OBJ_IS_HUMAN(p)) ? \
705  ((sar_object_struct *)(p))->data : NULL \
706 )
707 
708 #define SAR_OBJ_GET_SMOKE(p)	\
709 (sar_object_smoke_struct *)((SAR_OBJ_IS_SMOKE(p)) ? \
710  ((sar_object_struct *)(p))->data : NULL \
711 )
712 
713 #define SAR_OBJ_GET_FIRE(p)	\
714 (sar_object_fire_struct *)((SAR_OBJ_IS_FIRE(p)) ? \
715  ((sar_object_struct *)(p))->data : NULL \
716 )
717 
718 #define SAR_OBJ_GET_EXPLOSION(p)	\
719 (sar_object_explosion_struct *)((SAR_OBJ_IS_EXPLOSION(p)) ? \
720  ((sar_object_struct *)(p))->data : NULL \
721 )
722 
723 #define SAR_OBJ_GET_CHEMICAL_SPRAY(p)	\
724 (sar_object_chemical_spray_struct *)((SAR_OBJ_IS_CHEMICAL_SPRAY(p)) ? \
725  ((sar_object_struct *)(p))->data : NULL \
726 )
727 
728 #define SAR_OBJ_GET_FUELTANK(p)	\
729 (sar_object_fueltank_struct *)((SAR_OBJ_IS_FUELTANK(p)) ? \
730  ((sar_object_struct *)(p))->data : NULL \
731 )
732 
733 #define SAR_OBJ_GET_PREMODELED(p)	\
734 (sar_object_premodeled_struct *)((SAR_OBJ_IS_PREMODELED(p)) ? \
735  ((sar_object_struct *)(p))->data : NULL \
736 )
737 
738 
739 /*
740  *	Aircraft:
741  */
742 typedef enum {
743 	SAR_FLIGHT_MODEL_HELICOPTER,
744 	SAR_FLIGHT_MODEL_AIRPLANE,
745 	SAR_FLIGHT_MODEL_SLEW
746 } sar_flight_model_type;
747 typedef struct {
748 
749 	/* Flight Model Type */
750 	sar_flight_model_type flight_model_type;
751 
752 	/* Previously set Flight Model Type (for switching back and
753 	 * forth between flight model types
754 	 */
755 	sar_flight_model_type last_flight_model_type;
756 
757 	/* Flight Dynamics Model */
758 	SFMModelStruct	*fdm;
759 
760 	/* Air Worthy State */
761 	sar_air_worthy_state air_worthy_state;
762 
763 	/* Current speed, in meters per cycle */
764 	float		speed;
765 
766 	/* Stall speed, the speed at which a controllable stall begins.
767 	 * Loss of lift can still occure twice beyond this value, in
768 	 * meters per cycle
769 	 */
770 	float		speed_stall,
771 			stall_coeff;
772 
773 	/* Maximum speed (this is typically *several* times the rated
774 	 * maximum speed), in meters per cycle
775 	 */
776 	float		speed_max;
777 
778 	/* overspeed_expected is the overspeed value according to the
779 	 * specifications of the aircraft, if the speed reaches or
780 	 * exceeds this value then overspeed warnings and affects are
781 	 * performed, units are in meters per cycle
782 	 *
783 	 * overspeed is the speed at which the aircraft will incure
784 	 * damage, in meters per cycle
785 	 */
786 	float		overspeed_expected,
787 			overspeed;
788 
789 	/* Current velocity vector representing velocity in object
790 	 * relative vector direction, in meters per cycle
791 	 */
792 	sar_position_struct vel;
793 
794 	/* Z acceleration, in meters per cucle^2 */
795 	float		z_accel;
796 
797 	/* Minimum drag in meters per cycle, must be non-negative */
798 	float		min_drag;
799 
800 	/* Acceleration response for when flight_model_type is set to
801 	 * SAR_FLIGHT_MODEL_HELICOPTER, higher values produce less
802 	 * responsiveness)
803 	 *
804 	 * Note: This should really be called be accel dampening
805 	 */
806 	sar_position_struct accel_responsiveness;
807 
808 	/* Acceleration response for when flight_model_type is set to
809 	 * SAR_FLIGHT_MODEL_AIRPLANE, higher values produce less
810 	 * responsiveness)
811 	 *
812 	 * Note: This should really be called be accel dampening
813 	 */
814 	sar_position_struct airplane_accel_responsiveness;
815 
816 
817 	/* Attitude change rates, in radians per cycle */
818 	sar_direction_struct attitude_change_rate;
819 
820 	/* Pitch and bank leveling, in radians per cycle */
821 	float		pitch_leveling,
822 			bank_leveling;
823 
824 	/* Ground pitch offset in radians (can be negative) */
825 	float		ground_pitch_offset;
826 
827 	/* Cockpit offset relative to object center */
828 	sar_position_struct cockpit_offset_pos;
829 
830 	/* Cockpit visual model */
831 	sar_visual_model_struct *visual_model_cockpit;
832 
833 	/* Belly to center of object in meters */
834 	float		belly_height;
835 
836 	/* Height of landing gear in meters */
837 	float		gear_height;
838 
839 	/* Mass */
840 	float		dry_mass;		/* In kg */
841 	float		fuel_rate;		/* In kg consumed per cycle */
842 	float		fuel, fuel_max;		/* In kg */
843 	int		crew,
844 			passengers,
845 			passengers_max;
846 	float		passengers_mass;	/* Total mass of current
847 						 * passengers (in kg) */
848 
849 	/* Passengers pending to leave or drop from this aircraft,
850 	 * 0 means none and any positive value means this many passengers
851 	 * need to go when the aircraft's door is fully opened and its
852 	 * conditions are right (ie landed at the right helipad)
853 	 */
854 	int		passengers_leave_pending,
855 			passengers_drop_pending;
856 
857 	/* External fuel tanks */
858 	sar_external_fueltank_struct **external_fueltank;
859 	int		total_external_fueltanks;
860 
861 	/* Engine state and control positions */
862 	sar_engine_state	engine_state;
863 	time_t		next_engine_on;		/* Time till engine starts up (in ms) */
864 
865 	/* Throttle control position. In aircraft flight model this is
866 	 * the actual throttle control position, in helicopter flight
867 	 * model this is the speed at which the rotors are spinning.
868 	 * Range is from 0.0 to 1.0
869 	 */
870 	float		throttle;
871 
872 	/* Current collective value and collective range. The current
873 	 * collective value is always 1.0 in airplane flight model. In
874 	 * helicopter flight model, the current collective value matches
875 	 * the game controller's throttle position
876 	 *
877 	 * Both the collective and collective_range are in values from
878 	 * 0.0 to 1.0
879 	 */
880 	float		collective,
881 			collective_range;
882 
883 	/* Engine data */
884 	float		engine_power;		/* In kg * m / cycle^2 */
885 	char		engine_can_pitch;	/* 1 for tilt rotors */
886 
887 	/* Engine sounds */
888 	int		engine_inside_sndsrc;
889 	void		*engine_inside_sndplay;
890 	int		engine_outside_sndsrc;
891 	void		*engine_outside_sndplay;
892 
893 	/* Repeating warning sounds */
894 	int		stall_sndsrc;
895 	void		*stall_sndplay;
896 	int		overspeed_sndsrc;
897 	void		*overspeed_sndplay;
898 
899 
900 	/* Visual controller positions, these values only dictate
901 	 * the visual display of control parts
902 	 */
903 	float		control_heading,	/* Rudder, -1.0 to 1.0 */
904 			control_pitch,		/* Elevator, -1.0 to 1.0 */
905 			control_bank;		/* Ailerons, -1.0 to 1.0 */
906 
907 	/* Effective controller positions, these values will be passed
908 	 * to the FDM and control the actual attitude changing
909 	 */
910 	float		control_effective_heading,	/* Rudder, -1.0 to 1.0 */
911 			control_effective_pitch,	/* Elevator, -1.0 to 1.0 */
912 			control_effective_bank;		/* Ailerons, -1.0 to 1.0 */
913 
914 	float		elevator_trim;		/* -1.0 to 1.0 */
915 
916 	/* Flaps */
917 	float		flaps_position;		/* 0.0 (retracted) to 1.0
918 						 * (fully deployed) */
919 	float		flaps_stall_offset;	/* Moves the speed_stall
920 						 * ahead by this many
921 						 * meters per cycle */
922 
923 	/* Service ceiling, in meters */
924 	float		service_ceiling;
925 
926 	/* Distance from object's center to touchable ground in meters
927 	 * (note that this is usually negative unless the object is
928 	 * underground)
929 	 */
930 	float		center_to_ground_height;
931 
932 
933 	/* Moveable parts */
934 	sar_obj_part_struct	**part;
935 	int		total_parts;
936 
937 	/* Rotors */
938 	sar_obj_rotor_struct	**rotor;
939 	int		total_rotors;
940 
941 	/* Landed states */
942 	char		landed,		/* 1 if landed */
943 			on_water;	/* If landed is 1 and on_water is 1,
944 					 * then is on water */
945 
946 	/* Landing gear state:
947 	 * -1	non-existant
948 	 * 0    up/retracted/in
949 	 * 1    down/deployed/out
950 	 */
951 	int		landing_gear_state;
952 
953 	/* Ground turning */
954 	float		gturn_radius;	/* Distance from farthest non-turning
955 					 * gear to turning gear in meters, can
956 					 * be negative (0 implies no turning) */
957 	/* Ground turning velocity optimul and maximum (meters per
958 	 * cycle)
959 	 */
960 	float		gturn_vel_opt,
961 			gturn_vel_max;
962 
963 	/* Air brakes and wheel brakes:
964 	 * -1   non-existant
965 	 * 0    off
966 	 * 1    on
967 	 * 2    locked (parking brakes on)
968 	 */
969 	int		air_brakes_state,
970 			wheel_brakes_state;
971 
972 	/* Air brake affect on speed, in units of meters per cycle
973 	 * Can be 0.0 if this aircraft has no air brakes
974 	 * The affect of the air brakes will be at its maximum
975 	 * (the exact value of air_brakes_rate) when the speed
976 	 * approaches speed_max_expected.  As the speed reduces to
977 	 * speed_stall the affect of air_brakes_rate will be reduced
978 	 * to 10% and as the speed reduces to 0 the affect of
979 	 * air_brakes_rate will be 0%
980 	 */
981 	float		air_brakes_rate;
982 
983 	/* Spot light direction */
984 	sar_direction_struct	spotlight_dir;
985 
986 	/* Rescue hoist */
987 	sar_obj_hoist_struct	*hoist;
988 
989 	/* Intercept waypoints */
990 	sar_intercept_struct	**intercept;
991 	int		total_intercepts,
992 			cur_intercept;
993 
994 	/* Autopilot data */
995 	sar_autopilot_state autopilot_state;
996 	float		autopilot_altitude;	/* Target height in meters
997 						 * above sea level */
998 } sar_object_aircraft_struct;
999 #define SAR_OBJECT_AIRCRAFT(p)	((sar_object_aircraft_struct *)(p))
1000 
1001 
1002 /*
1003  *	Ground/Heightfield:
1004  */
1005 typedef struct {
1006 
1007 	/* Elevation from (above) local MSL in meters. If MSL was
1008 	 * set to 10 meters and this elevation was set to 3 meters then
1009 	 * the resulting elevation would be 13 meters to any object within
1010 	 * contact of the ground object.
1011 	 *
1012 	 * Note that the ground object itself completely ignores the
1013 	 * scene structure defined ground_elevation_msl value.
1014 	 */
1015 	float		elevation;
1016 
1017 	/* Translation of heightfield from center of object */
1018 	float		x_trans,
1019 			y_trans,
1020 			z_trans;
1021 
1022 	/* Heightfield data (only used if z_point_value is not NULL) */
1023 	float		x_len,		/* grid_points_x * grid_x_spacing */
1024 			y_len;		/* grid_points_y * grid_y_spacing */
1025 	int		grid_points_x,	/* Number of grid points */
1026 			grid_points_y,
1027 			grid_points_total;	/* grid_points_x * grid_points_y */
1028 	float		grid_x_spacing,	/* Size of each grid in meters */
1029 			grid_y_spacing,
1030 			grid_z_spacing;
1031 	double		*z_point_value;	/* Heightfield z height map, each
1032 					 * point value came from
1033 					 * (image_data_pixel) /
1034 					 * 0xff * grid_z_spacing */
1035 
1036 	/* Value records for this ground object's inversed heading for the
1037 	 * trig functions, this is used to speed up rotations of heading
1038 	 * for checking an object over this ground object's heightfield
1039 	 * surface. It also limits ground objects to only have its
1040 	 * heading rotated.
1041 	 *
1042 	 * Ie cos_heading = cos(-heading) and sin_heading = sin(-heading)
1043 	 */
1044 	float		cos_heading,
1045 			sin_heading;
1046 
1047 } sar_object_ground_struct;
1048 #define SAR_OBJECT_GROUND(p)	((sar_object_ground_struct *)(p))
1049 
1050 
1051 /*
1052  *	Smoke Puffs & Sparks:
1053  */
1054 typedef enum {
1055 	SAR_SMOKE_TYPE_SMOKE,
1056 	SAR_SMOKE_TYPE_SPARKS,
1057 	SAR_SMOKE_TYPE_DEBRIS
1058 } sar_smoke_type;
1059 /* Smoke Puff & Sparks Units */
1060 typedef struct {
1061 
1062 	sar_position_struct pos;	/* In world coordinates */
1063 
1064 	sar_position_struct vel;
1065 
1066 	/* Color, only used when the smoke type is set to
1067 	 * SAR_SMOKE_TYPE_SPARKS
1068 	 */
1069 	sar_color_struct color;
1070 
1071 	/* Current size in meters */
1072 	float		radius;
1073 
1074 	/* Current visibility of smoke unit, in range of 0.0 to 1.0.
1075 	 * If 0.0 then it will not be drawn at all and is considered
1076 	 * "available for use"
1077 	 */
1078 	float		visibility;
1079 
1080 } sar_object_smoke_unit_struct;
1081 /* Smoke/Sparks */
1082 typedef struct {
1083 
1084 	sar_smoke_type	type;
1085 
1086 	/* Spawn offset position, this offset is applied to the actual
1087 	 * location of the smoke trail object where each unit will be
1088 	 * spawned at
1089 	 */
1090 	sar_position_struct respawn_offset;
1091 
1092 	/* Starting and ending radius values for all units
1093 	 *
1094 	 * If the smoke type is SAR_OBJ_SMOKE_TYPE_SPARKS then
1095 	 * radius_start is ignored and radius_max is how far sparks
1096 	 * should fly
1097 	 */
1098 	float		radius_start,
1099 			radius_max;
1100 
1101 	/* Radius increase rate in meters per cycle (must be positive)
1102 	 *
1103 	 * If the smoke type is SAR_OBJ_SMOKE_TYPE_SPARKS then this
1104 	 * value is ignored
1105 	 */
1106 	float		radius_rate;
1107 
1108 	/* If this is true then when a smoke unit has reached its
1109 	 * maximum size its visiblity will be reset to 0.0 (thus marking
1110 	 * it as "available for use")
1111 	 */
1112 	int		hide_at_max;
1113 
1114 	/* If this is true then this object will be marked for deletion
1115 	 * (its life span set to 1) when all of its units are no longer
1116 	 * visible (visibility = 0.0)
1117 	 */
1118 	int		delete_when_no_units;
1119 
1120 	/* Respawn intervals (in ms)
1121 	 *
1122 	 * If respawn_int is 0 then no respawning will take place
1123 	 *
1124 	 * This is often used to stop respawning but keep the already
1125 	 * visible smoke units around
1126 	 */
1127 	time_t		respawn_int,
1128 			respawn_next;
1129 
1130 	/* Texture number on scene structure */
1131 	int		tex_num;
1132 
1133 	/* Reference object that this smoke trail is to follow (can be -1
1134 	 * for none or do not follow)
1135 	 */
1136 	int		ref_object;
1137 
1138 	/* Each smoke unit forming this smoke trail */
1139 	sar_object_smoke_unit_struct *unit;
1140 	int		total_units;
1141 
1142 } sar_object_smoke_struct;
1143 #define SAR_OBJECT_SMOKE_UNIT(p)	((sar_object_smoke_unit_struct *)(p))
1144 #define SAR_OBJECT_SMOKE(p)		((sar_object_smoke_struct *)(p))
1145 
1146 
1147 /*
1148  *	Explosion/Splash:
1149  */
1150 typedef enum {
1151 	SAR_EXPLOSION_COLOR_EMISSION_NONE,	/* Interacts with light (ie splashes) */
1152 	SAR_EXPLOSION_COLOR_EMISSION_IS_LIGHT,	/* Does not interact with light */
1153 	SAR_EXPLOSION_COLOR_EMISSION_EMIT_LIGHT	/* Gives off light */
1154 } sar_explosion_color_emission;
1155 typedef enum {
1156 	SAR_EXPLOSION_CENTER_OFFSET_NONE,
1157 	SAR_EXPLOSION_CENTER_OFFSET_BASE
1158 } sar_explosion_center_offset;
1159 typedef struct {
1160 
1161 	/* Spherical size of the explosion (in meters), this is also
1162 	 * used to calculate the displayed explosion billboard
1163 	 */
1164 	float		radius;
1165 
1166 	sar_explosion_color_emission	color_emission;
1167 	sar_explosion_center_offset	center_offset;
1168 
1169 	time_t		frame_inc_int,	/* Frame increment interval (in ms) */
1170 			next_frame_inc;	/* Time to increment next frame (in ms) */
1171 
1172 	int		cur_frame,	/* Current frame */
1173 			frame_repeats;	/* Number of times animation has cycled */
1174 
1175 	/* Number of frame repeats, 0 or less to repeat forever (or
1176 	 * when life span has exceeded)
1177 	 */
1178 	int		total_frame_repeats;
1179 
1180 	/* Texture number on scene */
1181 	int		tex_num,
1182 			ir_tex_num;
1183 
1184 	/* Reference object that this explosion is to follow (can be
1185 	 * -1 for none/do not follow)
1186 	 */
1187 	int		ref_object;
1188 
1189 } sar_object_explosion_struct;
1190 #define SAR_OBJECT_EXPLOSION(p)	((sar_object_explosion_struct *)(p))
1191 
1192 
1193 /*
1194  *	Fire:
1195  */
1196 typedef struct {
1197 
1198 	/* Cylendrical size of fire in meters, this is also used to
1199 	 * calculate the fire billboard
1200 	 *
1201 	 * Center is at the base of the fire
1202 	 */
1203 	float		radius,
1204 			height;
1205 
1206 	time_t		frame_inc_int,	/* Frame increment interval, in ms */
1207 			next_frame_inc;	/* Time to increment next frame, in ms */
1208 	int		cur_frame,	/* Current frame */
1209 			frame_repeats;	/* Number of times animation has cycled */
1210 
1211 	/* Number of frame repeats, 0 or less to repeat forever (or
1212 	 * when life span has exceeded)
1213 	 */
1214 	int		total_frame_repeats;
1215 
1216 	/* Texture number on scene */
1217 	int		tex_num,
1218 			ir_tex_num;
1219 
1220 	/* Reference object that this fire is to follow (can be -1 for
1221 	 * none/do not follow)
1222 	 */
1223 	int		ref_object;
1224 
1225 } sar_object_fire_struct;
1226 #define SAR_OBJECT_FIRE(p)	((sar_object_fire_struct *)(p))
1227 
1228 
1229 /*
1230  *	Chemical Spray:
1231  *
1232  *	A single puff of chemical spray (ie water, fire-retardant, etc).
1233  */
1234 typedef enum {
1235 	SAR_CHEMICAL_WATER,
1236 	SAR_CHEMICAL_FIRE_RETARDANT
1237 } sar_chemical_type;
1238 typedef struct {
1239 
1240 	sar_chemical_type	chemical_type;
1241 
1242 	int		owner;		/* Object that created this spray or -1
1243 					 * for none */
1244 
1245 	/* Texture number on the scene */
1246 	int		tex_num;
1247 
1248 } sar_object_chemical_spray_struct;
1249 #define SAR_OBJECT_CHEMICAL_SPRAY(p)	((sar_object_chemical_spray_struct *)(p))
1250 
1251 
1252 /*
1253  *	Fuel Tank:
1254  *
1255  *	Note: This is not a fuel tank that is currently on an aircraft,
1256  *	do not confuse this with the fuel tanks on objects (see
1257  *	sar_external_fueltank_struct).
1258  */
1259 typedef enum {
1260 	SAR_FUELTANK_FLAG_ON_GROUND	= (1 << 0)
1261 } sar_fueltank_flags;
1262 typedef struct {
1263 
1264 	sar_fueltank_flags	flags;
1265 
1266 	/* Current speed in meters per cycle */
1267 	float		speed;
1268 
1269 	/* Maximum negative vertical velocity in meters per cycle */
1270 	float		vel_z_max;
1271 
1272 	/* Current velocity vector representing velocity in object
1273 	 * relative vector direction, in meters per cycle
1274 	 */
1275 	sar_position_struct	vel;
1276 
1277 	/* Belly to center height, in meters */
1278 	float		belly_to_center_height;
1279 
1280 	/* Index of object of which this fuel tank fell off of (can be
1281 	 * -1 for unknown)
1282 	 */
1283 	int		ref_object;
1284 
1285 	/* Mass and fuel (in kg) */
1286 	float		dry_mass,
1287 			fuel,
1288 			fuel_max;
1289 
1290 } sar_object_fueltank_struct;
1291 #define SAR_OBJECT_FUELTANK(p)	((sar_object_fueltank_struct *)(p))
1292 
1293 
1294 /*
1295  *	Runway:
1296  */
1297 typedef enum {
1298 	SAR_RUNWAY_FLAG_THRESHOLDS	= (1 << 0),	/* Thresholds (not
1299 							 * Displaced Thresholds) */
1300 	SAR_RUNWAY_FLAG_BORDERS		= (1 << 1),	/* Side Borders */
1301 	SAR_RUNWAY_FLAG_TD_MARKERS	= (1 << 2),	/* Touch Down Markers */
1302 	SAR_RUNWAY_FLAG_MIDWAY_MARKERS	= (1 << 3),
1303 	SAR_RUNWAY_FLAG_NORTH_GS	= (1 << 4),	/* North Glide Slope */
1304 	SAR_RUNWAY_FLAG_SOUTH_GS	= (1 << 5)	/* South Glide Slope */
1305 } sar_runway_flags;
1306 typedef enum {
1307 	SAR_RUNWAY_SURFACE_PAVED,
1308 	SAR_RUNWAY_SURFACE_GRAVEL,
1309 	SAR_RUNWAY_SURFACE_CONCRETE,
1310 	SAR_RUNWAY_SURFACE_GROVED
1311 } sar_runway_surface_type;
1312 typedef enum {
1313 	SAR_RUNWAY_APPROACH_LIGHTING_END	= (1 << 0),
1314 	SAR_RUNWAY_APPROACH_LIGHTING_TRACER	= (1 << 1),
1315 	SAR_RUNWAY_APPROACH_LIGHTING_ALIGN	= (1 << 2),
1316 	SAR_RUNWAY_APPROACH_LIGHTING_ILS_GLIDE	= (1 << 3)
1317 } sar_runway_approach_lighting_flags;
1318 typedef struct {
1319 
1320 	sar_runway_flags	flags;
1321 
1322 	/* Size (in meters) */
1323 	float		length,
1324 			width;
1325 
1326 	/* Surface Type */
1327 	sar_runway_surface_type	surface_type;
1328 
1329 	/* End Labels */
1330 	char		*north_label,
1331 			*south_label;
1332 	sar_visual_model_struct	*north_label_vmodel,
1333 				*south_label_vmodel;
1334 	float		north_label_width,
1335 			south_label_width;
1336 
1337 	/* Number of dashes (0 for none) */
1338 	int		dashes;
1339 
1340 	/* Edge lighting in meters (0.0 for none) */
1341 	float		edge_light_spacing;
1342 
1343 	/* Approach lighting flags */
1344 	sar_runway_approach_lighting_flags	north_approach_lighting_flags,
1345 						south_approach_lighting_flags;
1346 	sar_grad_anim_t	tracer_anim_pos,
1347 			tracer_anim_rate;
1348 
1349 	/* Displaced threshold offset from respective edges in meters
1350 	 * (can be 0.0 for none)
1351 	 */
1352 	float		north_displaced_threshold,
1353 			south_displaced_threshold;
1354 
1355 	sar_visual_model_struct	*threshold_vmodel,
1356 				*td_marker_vmodel,
1357 				*midway_marker_vmodel,
1358 				*north_displaced_threshold_vmodel,
1359 				*south_displaced_threshold_vmodel;
1360 
1361 	/* Runway background texture number (on scene structure) */
1362 	int		tex_num;
1363 
1364 } sar_object_runway_struct;
1365 #define SAR_OBJECT_RUNWAY(p)	((sar_object_runway_struct *)(p))
1366 
1367 
1368 /*
1369  *	Helipad:
1370  */
1371 typedef enum {
1372 	SAR_HELIPAD_FLAG_LABEL			= (1 << 1),
1373 	SAR_HELIPAD_FLAG_EDGE_LIGHTING		= (1 << 2),
1374 	SAR_HELIPAD_FLAG_FUEL			= (1 << 3),
1375 	SAR_HELIPAD_FLAG_REPAIR			= (1 << 4),
1376 	SAR_HELIPAD_FLAG_DROPOFF		= (1 << 5),	/* Can drop
1377 								 * off passengers */
1378 	SAR_HELIPAD_FLAG_REF_OBJECT		= (1 << 6),	/* Has ref object */
1379 	SAR_HELIPAD_FLAG_FOLLOW_REF_OBJECT	= (1 << 7),
1380 	SAR_HELIPAD_FLAG_RESTART_POINT		= (1 << 8)	/* Is a restarting
1381 								 * point */
1382 } sar_helipad_flags;
1383 typedef enum {
1384 	SAR_HELIPAD_STYLE_GROUND_PAVED,
1385 	SAR_HELIPAD_STYLE_GROUND_BARE,		/* Unpaved */
1386 	SAR_HELIPAD_STYLE_BUILDING,		/* Roof top */
1387 	SAR_HELIPAD_STYLE_VEHICLE		/* On a vehicle or vessel */
1388 } sar_helipad_style;
1389 typedef struct {
1390 
1391 	sar_helipad_flags	flags;
1392 	sar_helipad_style	style;
1393 
1394 	/* Size of landable area (in meters) */
1395 	float		length,
1396 			width;
1397 
1398 	/* Downward recession from the helipad's landable surface into
1399 	 * the ground (in meters)
1400 	 *
1401 	 * Example, a value of 2 means 2 meters down
1402 	 */
1403 	float		recession;
1404 
1405 	/* Label */
1406 	char		*label;
1407 	sar_visual_model_struct	*label_vmodel;
1408 	float		label_width;
1409 
1410 	/* Lighting edge spacing, in meters */
1411 	float		light_spacing;
1412 
1413 	/* Texture number on scene structure, specifying the texture
1414 	 * for the helipad's main landable area
1415 	 */
1416 	int		tex_num;
1417 
1418 	/* If SAR_HELIPAD_FLAG_REF_OBJECT is set then these members
1419 	 * will have affect
1420 	 *
1421 	 * Note: ref_offset is applied before ref_dir
1422 	 */
1423 	int		ref_object;	/* Object that this helipad `follows' */
1424 	sar_position_struct	ref_offset;	/* Relative to ref_object */
1425 	sar_direction_struct	ref_dir;	/* Relative to ref_object */
1426 
1427 } sar_object_helipad_struct;
1428 #define SAR_OBJECT_HELIPAD(p)	((sar_object_helipad_struct *)(p))
1429 
1430 
1431 /*
1432  *	Human/Actor:
1433  */
1434 typedef enum {
1435 	SAR_HUMAN_FLAG_NEED_RESCUE	= (1 << 1),
1436 	SAR_HUMAN_FLAG_SIT		= (1 << 2),	/* Base at tush */
1437 	SAR_HUMAN_FLAG_SIT_DOWN		= (1 << 3),	/* Base at tush, feet
1438 							 * out forward */
1439 	SAR_HUMAN_FLAG_SIT_UP		= (1 << 4),	/* Base at feet */
1440 	SAR_HUMAN_FLAG_LYING		= (1 << 5),
1441 	SAR_HUMAN_FLAG_ALERT		= (1 << 6),	/* Is awake */
1442 	SAR_HUMAN_FLAG_AWARE		= (1 << 7),	/* Knows of surroundings */
1443 	SAR_HUMAN_FLAG_IN_WATER		= (1 << 8),
1444 	SAR_HUMAN_FLAG_ON_STREATCHER	= (1 << 9),
1445 	SAR_HUMAN_FLAG_RUN		= (1 << 10),	/* Animate as running */
1446 	SAR_HUMAN_FLAG_RUN_TOWARDS	= (1 << 11),	/* Intends to run towards
1447 							 * (does not imply currently
1448 							 * running */
1449 	SAR_HUMAN_FLAG_RUN_AWAY		= (1 << 12),	/* Intends to run away
1450 							 * (does not imply currently
1451 							 * running */
1452 	SAR_HUMAN_FLAG_PUSHING		= (1 << 13),
1453 	SAR_HUMAN_FLAG_GRIPPED		= (1 << 14),	/* Someone/something is
1454 							 * holding this (ie in
1455 							 * rescue basket */
1456 	SAR_HUMAN_FLAG_DIVER_CATCHER	= (1 << 15)
1457 } sar_human_flags;
1458 typedef struct {
1459 
1460 	sar_human_flags	flags;
1461 
1462 	float		mass;	/* In kg */
1463 
1464 	float		height;	/* In meters */
1465 
1466 	sar_grad_anim_t	anim_pos,
1467 			anim_rate;
1468 
1469 	/* Colors, see definations for SAR_HUMAN_COLOR_* and
1470 	 * SAR_HUMAN_COLORS_MAX for index positions and maximum colors
1471 	 * (respectivly)
1472 	 */
1473 	sar_color_struct	color[SAR_HUMAN_COLORS_MAX];
1474 
1475 	/* Water ripples texture number on the scene */
1476 	int		water_ripple_tex_num;
1477 
1478 	/* Reference to object running towards or away from, the following
1479 	 * values have special meaning:
1480 	 *
1481 	 *	-1	No intercepting
1482 	 *	-2	Intercept player
1483 	 *
1484 	 * Works when flags SAR_HUMAN_FLAG_RUN_TOWARDS xor
1485 	 * SAR_HUMAN_FLAG_RUN_AWAY is set and intercepting_object is
1486 	 * valid and not the human object itself.
1487 	 */
1488 	int		intercepting_object;
1489 
1490 	/* Distance to intercepting object in meters (may be ignored if
1491 	 * intercepting_object is -1.
1492 	 */
1493 	float		intercepting_object_distance2d,
1494 			intercepting_object_distance3d;
1495 
1496 	/* Number of assisting humans following this human (0 for none).
1497 	 * these are not other objects but rather groups of humans drawn
1498 	 * with this human object to make it look like multiple
1499 	 * humans.
1500 	 */
1501 	int		assisting_humans;
1502 	sar_color_struct	assisting_human_color[SAR_HUMAN_COLORS_MAX];
1503 
1504 	/* Messages */
1505 	char		*mesg_enter;	/* Entering into aircraft or vehicle */
1506 
1507 } sar_object_human_struct;
1508 #define SAR_OBJECT_HUMAN(p)	((sar_object_human_struct *)(p))
1509 
1510 
1511 /*
1512  *	Premodeled Object:
1513  */
1514 typedef enum {
1515 	SAR_OBJ_PREMODELED_BUILDING,
1516 	SAR_OBJ_PREMODELED_CONTROL_TOWER,
1517 	SAR_OBJ_PREMODELED_HANGAR,
1518 	SAR_OBJ_PREMODELED_POWER_TRANSMISSION_TOWER,
1519 	SAR_OBJ_PREMODELED_TOWER,
1520 	SAR_OBJ_PREMODELED_RADIO_TOWER
1521 } sar_premodeled_type;
1522 typedef struct {
1523 
1524 	sar_premodeled_type	type;
1525 
1526 	/* Values, depending on type, not all may be applicateable */
1527 	float		width,
1528 			length,
1529 			height;
1530 
1531 	/* Animation */
1532 	sar_grad_anim_t	anim_pos,
1533 			anim_rate;
1534 
1535 	/* Reference to a texture on the scene */
1536 #define SAR_OBJ_PREMODEL_MAX_TEXTURES	10
1537 	int		tex_num[SAR_OBJ_PREMODEL_MAX_TEXTURES];
1538 
1539 } sar_object_premodeled_struct;
1540 #define SAR_OBJECT_PREMODELED(p)	((sar_object_premodeled_struct *)(p))
1541 
1542 
1543 /*
1544  *	SAR Object Core:
1545  */
1546 typedef struct {
1547 
1548 	sar_obj_type	type;
1549 
1550 #define SAR_OBJ_FLAG_NO_DEPTH_TEST	(1 << 1)
1551 #define SAR_OBJ_FLAG_HIDE_DAY_MODEL	(1 << 2)	/* Hide day model when not day */
1552 #define SAR_OBJ_FLAG_HIDE_DAWN_MODEL	(1 << 3)	/* Hide dawn model when not dawn */
1553 #define SAR_OBJ_FLAG_HIDE_DUSK_MODEL	(1 << 4)	/* Hide dusk model when not dusk */
1554 #define SAR_OBJ_FLAG_HIDE_NIGHT_MODEL	(1 << 5)	/* Hide night model when not night */
1555 
1556 /* These two only work if SAR_OBJ_FLAG_HIDE_NIGHT_MODEL is set */
1557 #define SAR_OBJ_FLAG_NIGHT_MODEL_AT_DAWN	(1 << 6)	/* Show night modem at dawn */
1558 #define SAR_OBJ_FLAG_NIGHT_MODEL_AT_DUSK	(1 << 7)	/* Show night modem at dusk */
1559 
1560 #define SAR_OBJ_FLAG_SHADE_MODEL_SMOOTH	(1 << 8)	/* Use smooth shading */
1561 
1562 #define SAR_OBJ_FLAG_FAR_MODEL_DAY_ONLY	(1 << 9)	/* Display far model during
1563 							 * time only.
1564 							 */
1565 #define SAR_OBJ_FLAG_POLYGON_OFFSET	(1 << 10)	/* Enable polygon offset */
1566 #define SAR_OBJ_FLAG_POLYGON_OFFSET_REVERSE	(1 << 11)	/* Same as SAR_OBJ_FLAG_POLYGON_OFFSET
1567 								 * cept offsets in
1568 								 * the other direction.
1569 								 */
1570 #define SAR_OBJ_FLAG_POLYGON_OFFSET_WRITE_DEPTH	(1 << 12)	/* Write depth if
1571 								 * polygon offsetting.
1572 								 */
1573 
1574 	sar_obj_flags_t flags;
1575 
1576 	/* Name of object (can be NULL) */
1577 	char		*name;
1578 
1579 	/* Current position and direction */
1580 	sar_position_struct	pos;
1581 	sar_direction_struct	dir;
1582 
1583 	/* Visible range of this object, in meters
1584 	 *
1585 	 * Object is not displayed when the camera is farther is beyond
1586 	 * this range
1587 	 */
1588 	float		range;
1589 
1590 	/* Visible range for displaying the far visual model when the
1591 	 * camera is beyond this range, in meters
1592 	 */
1593 	float		range_far;
1594 
1595 
1596 	/* Distance from sea level to touchable ground under object, in
1597 	 * meters (ignored for objects of type SAR_OBJ_TYPE_GROUND)
1598 	 */
1599 	float		ground_elevation_msl;
1600 
1601 
1602 	/* Contact bounds */
1603 	sar_contact_bounds_struct	*contact_bounds;
1604 
1605 
1606 	/* Time stamp of when this object was created in milliseconds
1607 	 * and in systime seconds (respectivly). The value in milliseconds
1608 	 * may not be accurate when timmers are reset
1609 	 */
1610 	time_t		birth_time_ms,
1611 			birth_time_sec;
1612 
1613 	/* When this object `dies' (0 if lives forever) */
1614 	time_t		life_span;
1615 
1616 	/* Hit points */
1617 	float		hit_points,
1618 			hit_points_max;
1619 
1620 	/* Temperature for FLIR (0.0 to 1.0) */
1621 	float		temperature;
1622 
1623 	/* Visual models */
1624 	sar_visual_model_struct	*visual_model,		/* Day */
1625 				*visual_model_ir,	/* InfraRed */
1626 				*visual_model_far,	/* Far */
1627 				*visual_model_dawn,	/* Dawn */
1628 				*visual_model_dusk,	/* Dusk */
1629 				*visual_model_night,	/* Night */
1630 				*visual_model_shadow;	/* Shadow */
1631 
1632 	/* Lights */
1633 	sar_light_struct	**light;
1634 	int			total_lights;
1635 
1636 	/* Sound sources */
1637 	sar_sound_source_struct	**sndsrc;
1638 	int			total_sndsrcs;
1639 
1640 	/* Pointer to additional data specific to the object type,
1641 	 * the structure's type is specified by this structure's member
1642 	 * type
1643 	 */
1644 	void *data;
1645 
1646 } sar_object_struct;
1647 #define SAR_OBJECT(p)	((sar_object_struct *)(p))
1648 
1649 
1650 
1651 /*
1652  *	Scene Ground Base:
1653  *
1654  *	Contains visual models and tiling values for displaying of the
1655  *	ground base.
1656  */
1657 typedef struct {
1658 
1659 	/* Note, ground base moves with camera in modulous increments
1660 	 * of the tiled width and height
1661 	 */
1662 
1663 	/* Tiling size, in meters */
1664 	int		tile_width,
1665 			tile_height;
1666 
1667 	/* Tiling limited to this range from origin, in meters */
1668 	float		close_range;
1669 
1670 
1671 	/* Simple (far) solid color base plane and visual model */
1672 	sar_color_struct	color;
1673 	sar_visual_model_struct	*visual_model_simple;
1674 
1675 	/* Close up texture tiled base plane visual model */
1676 	sar_visual_model_struct	*visual_model_close;
1677 
1678 } sar_scene_base_struct;
1679 #define SAR_SCENE_BASE(p)	((sar_scene_base_struct *)(p))
1680 
1681 /*
1682  *	Scene Horizon:
1683  */
1684 typedef struct {
1685 
1686 	/* Records the last time of day since midnight from the scene
1687 	 * in units of 5 minute intervals as a whole number for horizon
1688 	 * texture regeneration, see SARSimUpdateScene() in simmanage.c
1689 	 * for when and how this value is updated
1690 	 */
1691 	int		last_tod;
1692 
1693 	/* Gradient textures, 0 is most highlighted and
1694 	 * total_textures - 1 is darkest
1695 	 */
1696 	v3d_texture_ref_struct **texture;
1697 	int		total_textures;
1698 
1699 } sar_scene_horizon_struct;
1700 #define SAR_SCENE_HORIZON(p)	((sar_scene_horizon_struct *)(p))
1701 
1702 /*
1703  *	Scene Cloud Layer:
1704  *
1705  *	Flat tiled layer of clouds as tiled textured quads.
1706  */
1707 typedef struct {
1708 
1709 	/* Note, cloud layer moves with camera in modulous
1710 	 * of the tiled width and height on the XY plane
1711 	 */
1712 
1713 	/* Tiling size, in meters */
1714 	int		tile_width,
1715 			tile_height;
1716 
1717 	/* Tiling limited to this range from origin of tiling, in
1718 	 * meters
1719 	 */
1720 	float		range;
1721 
1722 	/* Name of cloud texture on scene structure */
1723 	char		*tex_name;
1724 
1725 	sar_visual_model_struct *visual_model;
1726 
1727 	/* Height from MSL, in meters */
1728 	float		z;
1729 
1730 } sar_cloud_layer_struct;
1731 #define SAR_CLOUD_LAYER(p)	((sar_cloud_layer_struct *)(p))
1732 
1733 /*
1734  *	Scene Cloud Billboard:
1735  */
1736 typedef struct {
1737 
1738 	/* Note, cloud billboard moves with camera in modulous of the
1739 	 * tiled width and height on the XY plane
1740 	 */
1741 
1742 	/* Tiling size, in meters */
1743 	int		tile_width,
1744 			tile_height;
1745 
1746 	/* Name of texture on scene structure */
1747 	char		*tex_name;
1748 	/* Matched texture on scene structure */
1749 	int		tex_num;
1750 
1751 	/* Position of billboard object relative to tiled center */
1752 	sar_position_struct pos;
1753 
1754 	/* Size of cloud object, in meters */
1755 	float		width,
1756 			height;
1757 
1758 	/* Lightening timers, in ms
1759 	 *
1760 	 * If lightening_min_int and lightening_max_int are 0 then
1761 	 * that means there is no lightening
1762 	 */
1763 	time_t		lightening_min_int,	/* Minimum off interval */
1764 			lightening_max_int,	/* Maximum off interval */
1765 			lightening_next_on,	/* Waiting to go on */
1766 			lightening_next_off,	/* Waiting to go off */
1767 			lightening_started_on;	/* When turned on */
1768 
1769 	/* Lightening points relative to cloud billboard's center,
1770 	 * in meters
1771 	 */
1772 #define SAR_LIGHTENING_POINTS_MAX	6
1773 	sar_position_struct lightening_point[SAR_LIGHTENING_POINTS_MAX];
1774 
1775 } sar_cloud_bb_struct;
1776 #define SAR_CLOUD_BB(p)		((sar_cloud_bb_struct *)(p))
1777 
1778 /*
1779  *	Scene:
1780  */
1781 typedef enum {
1782 	SAR_SCENE_BASE_FLAG_IS_WATER	= (1 << 1)	/* All of the base is water */
1783 } sar_scene_base_flags;
1784 typedef struct {
1785 
1786 	/* Title of scenery */
1787 	char		*title;
1788 
1789 	/* Time of day (in seconds) since midnight */
1790 	float		tod;
1791 
1792 	/* Time Of Day Code, updated in SARSimUpdateScene() */
1793 	sar_tod_code	tod_code;
1794 
1795 	/* Ground Base Flags */
1796 	sar_scene_base_flags	base_flags;
1797 
1798 	/* CANT angle in radians, this value is only applied on readouts
1799 	 * added to the internal angle value in question
1800 	 */
1801 	float		cant_angle;
1802 
1803 	/* MSL elevation in meters */
1804 	float		msl_elevation;
1805 
1806 	/* GPS information */
1807 	sar_dms_t	dms_x_offset,	/* In degrees, -140.0 to 140.0 */
1808 			dms_y_offset;	/* In degrees, -90.0 to 90.0 */
1809 	float		planet_radius;	/* In meters */
1810 
1811 	/* Visual Models List, each object's Visual Models are recorded
1812 	 * here in this list and only these Visual Models may be deleted
1813 	 */
1814 	sar_visual_model_struct	**visual_model;
1815 	int			total_visual_models;
1816 
1817 	/* Sky and horizon gradient colors */
1818 	sar_color_struct	sky_nominal_color,
1819 				sky_brighten_color,
1820 				sky_darken_color;
1821 	/* Celestial object colors, these colors define the low and high
1822 	 * tint colors of the celestial object (where low means it is near
1823 	 * the horizon).
1824 	 */
1825 	sar_color_struct	star_low_color,
1826 				star_high_color,
1827 				sun_low_color,
1828 				sun_high_color,
1829 				moon_low_color,
1830 				moon_high_color;
1831 
1832 	/* Position of sun is dirived from light_pos */
1833 
1834 	/* Moon position, a unit vector to be applied to the camera
1835 	 * position
1836 	 */
1837 	sar_position_struct	moon_pos;
1838 	/* Moon visibility hint, 1 = above horizon, 0 = hidden */
1839 	char			moon_visibility_hint;
1840 
1841 
1842 	/* Atmosphere (when enabled) */
1843 	float		atmosphere_dist_coeff,	/* Coeff * max visiblity */
1844 			atmosphere_density_coeff;
1845 
1846 	/* Rain density coefficient, 0.0 for no rain, 0.5 for moderate,
1847 	 * 1.0 for densest rain
1848 	 */
1849 	float		rain_density_coeff;
1850 
1851 	/* Reference to player object */
1852 	int			player_obj_num;
1853 	sar_object_struct	*player_obj_ptr;
1854 	char			player_has_crashed;	/* 1 if player object has crashed */
1855 
1856 	/* Pointers to SAR_OBJ_TYPE_GROUND objects, you may free
1857 	 * the pointer array but not the pointer to structures!!
1858 	 */
1859 	sar_object_struct	**ground_object;
1860 	int			total_ground_objects;
1861 
1862 	/* Pointers to SAR_OBJ_TYPE_HUMAN objects that *need rescue*.
1863 	 * You may free the pointer array but not the pointers to structures!!
1864 	 */
1865 	sar_object_struct	**human_need_rescue_object;
1866 	int			total_human_need_rescue_objects;
1867 
1868 
1869 	/* Camera reference */
1870 	sar_camera_ref	camera_ref;
1871 
1872 	/* Camera field of view, in radians along Z axis (about the
1873 	 * the X axis)
1874 	 */
1875 	float		camera_fovz;
1876 
1877 	/* Direction of camera (when camera_ref=SAR_CAMERA_REF_COCKPIT) */
1878 	sar_direction_struct camera_cockpit_dir;
1879 
1880 	/* Direction from object to camera (when
1881 	 * camera_ref=SAR_CAMERA_REF_SPOT)
1882 	 */
1883 	sar_direction_struct camera_spot_dir;
1884 	float		camera_spot_dist;
1885 
1886 	/* Distance from hoist to camera (when
1887 	 * camera_ref=SAR_CAMERA_REF_HOIST)
1888 	 */
1889 	sar_direction_struct camera_hoist_dir;
1890 	float	camera_hoist_dist;
1891 
1892 	/* Position of camera (when camera_ref=SAR_CAMERA_REF_MAP) */
1893 	sar_position_struct camera_map_pos;
1894 
1895 	/* Position of camera (when camera_ref=SAR_CAMERA_REF_TOWER) */
1896 	sar_position_struct camera_tower_pos;
1897 
1898 	/* Target object that the camera is tracking (can be -1) */
1899 	int		camera_target;
1900 
1901 	/* Stack of camera rotation matrixes (set in sardraw.c) to
1902 	 * rotate any vertex relative to the camera's rotation, each
1903 	 * a 3 * 3 matrix.
1904 	 * Member camera_rotmatrix_count indicates the actual number
1905 	 * of matrixes set, which is equal or less than
1906 	 * SAR_CAMERA_ROTMATRIX_MAX
1907 	 */
1908 #define SAR_CAMERA_ROTMATRIX_MAX	5
1909 	double		camera_rotmatrix[SAR_CAMERA_ROTMATRIX_MAX][3 * 3];
1910 	int		camera_rotmatrix_count;
1911 
1912 	/* Ear position, this is updated when the scene is drawn and
1913 	 * the camera set
1914 	 */
1915 	sar_position_struct ear_pos;
1916 
1917 
1918 	/* Global Primary Light */
1919 
1920 	/* Position offset
1921 	 * This specifies a unit vector that is to be applied to the
1922 	 * camera's position to position the Global Primary Light
1923 	 */
1924 	sar_position_struct light_pos;
1925 
1926 	/* Intensity/color
1927 	 * This is not the color of the sun, the sun color is found in
1928 	 * sun_low_color and sun_high_color
1929 	 */
1930 	sar_color_struct light_color;
1931 	char		light_visibility_hint;	/* 1 if above horizon */
1932 
1933 	/* Light position coefficient orthogonal to camera's center,
1934 	 * the range is from [-1.0 to 1.0] (values out of this range
1935 	 * mean that it is out of the camera's view
1936 	 */
1937 	float		light_xc,
1938 			light_yc;
1939 
1940 
1941 	/* Ground Base */
1942 	sar_scene_base_struct base;
1943 
1944 	/* Horizon */
1945 	sar_scene_horizon_struct horizon;
1946 
1947 	/* Cloud Layers */
1948 	sar_cloud_layer_struct **cloud_layer;
1949 	int		total_cloud_layers;
1950 
1951 	/* Cloud Billboards */
1952 	sar_cloud_bb_struct **cloud_bb;
1953 	int		total_cloud_bbs;
1954 	/* Primary Lightening Coeff (0.0 to 1.0, 0.0=off), this is
1955 	 * set to positive when the cloud billboard's lightening is
1956 	 * active, updated in SARSimUpdateScene()
1957 	 */
1958 	float		pri_lightening_coeff;
1959 
1960 	/* Loaded Textures List */
1961 	v3d_texture_ref_struct **texture_ref;
1962 	int		total_texture_refs;
1963 
1964 	/* Index references to specific textures (a value can be -1 if
1965 	 * the texture in question was not loaded in the texture_ref
1966 	 * list)
1967 	 */
1968 	int		texnum_sun,
1969 			texnum_moon,
1970 			texnum_spotlightcast;
1971 
1972 	/* Global Sound Sources */
1973 	sar_sound_source_struct **sndsrc;
1974 	int		total_sndsrcs;
1975 
1976 
1977 	/* Player control panel (ControlPanel *) */
1978 	void		*player_control_panel;
1979 
1980 
1981 	/* Messages list */
1982 	char		**message;
1983 	int		total_messages;
1984 
1985 	/* Display message until this time runs out (in milliseconds),
1986 	 * a value of 0 milliseconds implies that the message is not to
1987 	 * be shown
1988 	 */
1989 	time_t		message_display_until;
1990 
1991 	/* Sticky banner message, for displaying crash reason or
1992 	 * mission failed reason, whenever it is not NULL
1993 	 */
1994 	char		**sticky_banner_message;
1995 	int		total_sticky_banner_messages;
1996 
1997 	/* Camera reference title, the name of the target object and/or
1998 	 * description of what the camera is showing
1999 	 */
2000 	char		*camera_ref_title;
2001 	time_t		camera_ref_title_display_until;
2002 
2003 	/* Flight dynamics model realm structure, used by the SFM
2004 	 * library as global reference while simulating all flight
2005 	 * dynamics models
2006 	 */
2007 	SFMRealmStruct	*realm;
2008 
2009 } sar_scene_struct;
2010 #define SAR_SCENE(p)	((sar_scene_struct *)(p))
2011 #define SAR_IS_CAMERA_IN_COCKPIT(s)	(((s) != NULL) ? \
2012  ((s)->camera_ref == SAR_CAMERA_REF_COCKPIT) : 0 \
2013 )
2014 #define SAR_IS_EAR_IN_COCKPIT(s)	(((s) != NULL) ? \
2015  ((s)->camera_ref == SAR_CAMERA_REF_COCKPIT) : 0 \
2016 )
2017 
2018 
2019 #endif	/* OBJ_H */
2020