FS2_Open
Open source remastering of the Freespace 2 engine
model.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) Volition, Inc. 1999. All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell
5  * or otherwise commercially exploit the source or things you created based on the
6  * source.
7  *
8 */
9 
10 
11 
12 #ifndef _MODEL_H
13 #define _MODEL_H
14 
15 #include "globalincs/globals.h" // for NAME_LENGTH
16 #include "globalincs/pstypes.h"
17 #include "graphics/2d.h"
18 #include "object/object.h"
19 
20 class object;
22 
24 extern int model_render_flags_size;
25 
26 #define MAX_DEBRIS_OBJECTS 32
27 #define MAX_MODEL_DETAIL_LEVELS 8
28 #define MAX_PROP_LEN 256
29 #define MAX_NAME_LEN 32
30 #define MAX_ARC_EFFECTS 8
31 
32 #define MOVEMENT_TYPE_NONE -1
33 #define MOVEMENT_TYPE_POS 0
34 #define MOVEMENT_TYPE_ROT 1
35 #define MOVEMENT_TYPE_ROT_SPECIAL 2 // for turrets only
36 #define MOVEMENT_TYPE_TRIGGERED 3 // triggered rotation
37 #define MOVEMENT_TYPE_INTRINSIC_ROTATE 4 // intrinsic (non-subsystem-based) rotation
38 #define MOVEMENT_TYPE_LOOK_AT 5 // the subobject is always looking at a 'look at' subobject, as best it can - Bobboau
39 
40 
41 // DA 11/13/98 Reordered to account for difference between max and game
42 #define MOVEMENT_AXIS_NONE -1
43 #define MOVEMENT_AXIS_X 0
44 #define MOVEMENT_AXIS_Y 2
45 #define MOVEMENT_AXIS_Z 1
46 
47 // defines for special objects like gun and missile points, docking point, etc
48 // Hoffoss: Please make sure that subsystem NONE is always index 0, and UNKNOWN is
49 // always the last subsystem in the list. Also, make sure that MAX is correct.
50 // Otherwise, problems will arise in Fred.
51 
52 #define SUBSYSTEM_NONE 0
53 #define SUBSYSTEM_ENGINE 1
54 #define SUBSYSTEM_TURRET 2
55 #define SUBSYSTEM_RADAR 3
56 #define SUBSYSTEM_NAVIGATION 4
57 #define SUBSYSTEM_COMMUNICATION 5
58 #define SUBSYSTEM_WEAPONS 6
59 #define SUBSYSTEM_SENSORS 7
60 #define SUBSYSTEM_SOLAR 8
61 #define SUBSYSTEM_GAS_COLLECT 9
62 #define SUBSYSTEM_ACTIVATION 10
63 #define SUBSYSTEM_UNKNOWN 11
64 #define SUBSYSTEM_MAX 12 // maximum value for subsystem_xxx, for error checking
65 
66 // Goober5000
67 extern char *Subsystem_types[SUBSYSTEM_MAX];
68 
69 #define MAX_TFP 10 // maximum number of turret firing points
70 
71 #define MAX_SPLIT_PLANE 5 // number of artist specified split planes (used in big ship explosions)
72 
73 // Data specific to a particular instance of a submodel. This gets stuffed/unstuffed using
74 // the model_clear_instance, model_set_instance, model_get_instance functions.
75 typedef struct submodel_instance_info {
76  int blown_off; // If set, this subobject is blown off
77  angles angs; // The current angle this thing is turned to.
79  vec3d pt_on_axis; // in ship RF
82  float turn_accel;
83  int axis_set;
84  int step_zero_timestamp; // timestamp determines when next step is to begin (for stepped rotation)
86 
87 typedef struct submodel_instance {
93  bool blown_off;
96 
97 // Data specific to a particular instance of a model.
98 typedef struct polymodel_instance {
99  int model_num; // global model num index, same as polymodel->id
100  submodel_instance *submodel; // array of submodel instances; mirrors the polymodel->submodel array
102 
103 #define MAX_MODEL_SUBSYSTEMS 200 // used in ships.cpp (only place?) for local stack variable DTP; bumped to 200
104  // when reading in ships.tbl
105 
106 #define MSS_FLAG_ROTATES (1 << 0) // This means the object rotates automatically with "turn_rate"
107 #define MSS_FLAG_STEPPED_ROTATE (1 << 1) // This means that the rotation occurs in steps
108 #define MSS_FLAG_AI_ROTATE (1 << 2) // This means that the rotation is controlled by ai
109 #define MSS_FLAG_CREWPOINT (1 << 3) // If set, this is a crew point.
110 #define MSS_FLAG_TURRET_MATRIX (1 << 4) // If set, this has it's turret matrix created correctly.
111 #define MSS_FLAG_AWACS (1 << 5) // If set, this subsystem has AWACS capability
112 #define MSS_FLAG_ARTILLERY (1 << 6) // if this rotates when weapons are fired - Goober5000
113 #define MSS_FLAG_TRIGGERED (1 << 7) // rotates when triggered by something
114 #define MSS_FLAG_UNTARGETABLE (1 << 8) // Goober5000
115 #define MSS_FLAG_CARRY_NO_DAMAGE (1 << 9) // WMC
116 #define MSS_FLAG_USE_MULTIPLE_GUNS (1 << 10) // WMC
117 #define MSS_FLAG_FIRE_ON_NORMAL (1 << 11) // forces a turret to fire down its normal vecs
118 #define MSS_FLAG_TURRET_HULL_CHECK (1 << 12) // makes the turret check to see if it's going to shoot through it's own hull before fireing - Bobboau
119 #define MSS_FLAG_TURRET_FIXED_FP (1 << 13) // forces turret (when defined with multiple weapons) to prevent the firepoints from alternating
120 #define MSS_FLAG_TURRET_SALVO (1 << 14) // forces turret to fire salvos (all guns simultaneously) - independent targeting
121 #define MSS_FLAG_FIRE_ON_TARGET (1 << 15) // prevents turret from firing unless it is pointing at the firingpoints are pointing at the target
122 #define MSS_FLAG_NO_SS_TARGETING (1 << 16) // toggles the subsystem targeting for the turret
123 #define MSS_FLAG_TURRET_RESET_IDLE (1 << 17) // makes turret reset to their initial position if the target is out of field of view
124 #define MSS_FLAG_TURRET_ALT_MATH (1 << 18) // tells the game to use additional calculations should turret have a defined y fov
125 #define MSS_FLAG_CARRY_SHOCKWAVE (1 << 19) // subsystem - even with 'carry no damage' flag - will carry shockwave damage to the hull
126 #define MSS_FLAG_ALLOW_LANDING (1 << 20) // This subsystem can be landed on
127 #define MSS_FLAG_FOV_EDGE_CHECK (1 << 21) // Tells the game to use better FOV edge checking with this turret
128 #define MSS_FLAG_FOV_REQUIRED (1 << 22) // Tells game not to allow this turret to attempt targeting objects out of FOV
129 #define MSS_FLAG_NO_REPLACE (1 << 23) // set the subsys not to draw replacement ('destroyed') model
130 #define MSS_FLAG_NO_LIVE_DEBRIS (1 << 24) // sets the subsys not to release live debris
131 #define MSS_FLAG_IGNORE_IF_DEAD (1 << 25) // tells homing missiles to ignore the subsys if its dead and home on to hull instead of earlier subsys pos
132 #define MSS_FLAG_ALLOW_VANISHING (1 << 26) // allows subsystem to vanish (prevents explosions & sounds effects from being played)
133 #define MSS_FLAG_DAMAGE_AS_HULL (1 << 27) // applies armor damage to subsystem instead of subsystem damage - FUBAR
134 #define MSS_FLAG_TURRET_LOCKED (1 << 28) // Turret starts locked by default - Sushi
135 #define MSS_FLAG_NO_AGGREGATE (1 << 29) // Don't include with aggregate subsystem types - Goober5000
136 #define MSS_FLAG_TURRET_ANIM_WAIT (1 << 30) // Turret won't fire until animation is complete - Sushi
137 
138 #define MSS_FLAG2_PLAYER_TURRET_SOUND (1 << 0)
139 #define MSS_FLAG2_TURRET_ONLY_TARGET_IF_CAN_FIRE (1 << 1) // Turrets only target things they're allowed to shoot at (e.g. if check-hull fails, won't keep targeting)
140 #define MSS_FLAG2_NO_DISAPPEAR (1 << 2) // Submodel won't disappear when subsystem destroyed
141 #define MSS_FLAG2_COLLIDE_SUBMODEL (1 << 3) // subsystem takes damage only from hits which impact the associated submodel
142 #define MSS_FLAG2_DESTROYED_ROTATION (1 << 4) // allows subobjects to continue to rotate even if they have been destroyed
143 #define MSS_FLAG2_TURRET_USE_AMMO (1 << 5) // enables ammo consumption for turrets (DahBlount)
144 #define MSS_FLAG2_AUTOREPAIR_IF_DISABLED (1 << 6) // Allows the subsystem to repair itself even if disabled (MageKing17)
145 #define MSS_FLAG2_NO_AUTOREPAIR_IF_DISABLED (1 << 7) // Inversion of the previous; disallows this particular subsystem if the ship-wide flag is set (MageKing17)
146 #define MSS_FLAG2_SHARE_FIRE_DIRECTION (1 << 8) // (DahBlount) Whenever the turret fires, make all firing points fire in the same direction.
147 
148 #define NUM_SUBSYSTEM_FLAGS 33
149 
150 // all subsys flags set in model file, used to copy only these flags for different table entries using the same model
151 #define MSS_MODEL_FLAG_MASK (MSS_FLAG_CREWPOINT | MSS_FLAG_ROTATES | MSS_FLAG_TRIGGERED | MSS_FLAG_ARTILLERY | MSS_FLAG_STEPPED_ROTATE)
152 #define MSS_MODEL_FLAG2_MASK 0
153 
154 // definition of stepped rotation struct
155 typedef struct stepped_rotation {
156  int num_steps; // number of steps in complete revolution
157  float fraction; // fraction of time in step spent in accel
158  float t_transit; // time spent moving from one step to next
159  float t_pause; // time at rest between steps
160  float max_turn_rate; // max turn rate going betweens steps
161  float max_turn_accel; // max accel going between steps
163 
164 struct queued_animation;
165 
166 // definition for model subsystems.
167 typedef struct model_subsystem { /* contains rotation rate info */
168 
169  uint flags; // See MSS_FLAG_* defines above
171  char name[MAX_NAME_LEN]; // name of the subsystem. Probably displayed on HUD
172  char subobj_name[MAX_NAME_LEN]; // Temporary (hopefully) parameter used to match stuff in ships.tbl
173  char alt_sub_name[NAME_LENGTH]; // Karajorma - Name that overrides name of original
174  char alt_dmg_sub_name[NAME_LENGTH]; // Name for the damage popup subsystems, allows for translation
175  int subobj_num; // subobject number (from bspgen) -- used to match subobjects of subsystems to these entries; index to polymodel->submodel
176  int model_num; // Which model this is attached to (i.e. the polymodel[] index); same as polymodel->id
177  int type; // type. see SUBSYSTEM_* types above. A generic type thing
178  vec3d pnt; // center point of this subsystem
179  float radius; // the extent of the subsystem
180  float max_subsys_strength; // maximum hits of this subsystem
181  int armor_type_idx; // Armor type on teh subsystem -C
182 
183  // The following items are specific to turrets and will probably be moved to
184  // a separate struct so they don't take up space for all subsystem types.
185  char crewspot[MAX_NAME_LEN]; // unique identifying name for this turret -- used to assign AI class and multiplayer people
186  vec3d turret_norm; // direction this turret faces
187  matrix turret_matrix; // turret_norm converted to a matrix.
188  float turret_fov; // dot of turret_norm:vec_to_enemy > this means can see
189  float turret_max_fov; // dot of turret_norm:vec_to_enemy <= this means barrels can elevate up to the target
190  float turret_y_fov; // turret's base's fov
191  int turret_num_firing_points; // number of firing points on this turret
192  vec3d turret_firing_point[MAX_TFP]; // in parent object's reference frame, point from which to fire.
193  int turret_gun_sobj; // Which subobject in this model the firing points are linked to.
194  float turret_turning_rate; // How fast the turret turns. Read from ships.tbl
195  int turret_base_rotation_snd; // Sound to make when the turret moves
196  float turret_base_rotation_snd_mult; // Volume multiplier for the turret sounds
197  int turret_gun_rotation_snd; // Sound to make when the turret moves
198  float turret_gun_rotation_snd_mult; // Volume multiplier for the turret sounds
199 
200 
201  //Sound stuff
202  int alive_snd; //Sound to make while the subsystem is not-dead
203  int dead_snd; //Sound to make when the subsystem is dead.
204  int rotation_snd; //Sound to make when the subsystem is rotating. (ie turrets)
205 
206  // engine wash info
207  struct engine_wash_info *engine_wash_pointer; // index into Engine_wash_info
208 
209  // rotation specific info
210  float turn_rate; // The turning rate of this subobject, if MSS_FLAG_ROTATES is set.
211  int weapon_rotation_pbank; // weapon-controlled rotation - Goober5000
212  stepped_rotation_t *stepped_rotation; // turn rotation struct
213 
214  // AWACS specific information
215  float awacs_intensity; // awacs intensity of this subsystem
216  float awacs_radius; // radius of effect of the AWACS
217 
218  int primary_banks[MAX_SHIP_PRIMARY_BANKS]; // default primary weapons -hoffoss
219  int primary_bank_capacity[MAX_SHIP_PRIMARY_BANKS]; // capacity of a bank - Goober5000
220  int secondary_banks[MAX_SHIP_SECONDARY_BANKS]; // default secondary weapons -hoffoss
221  int secondary_bank_capacity[MAX_SHIP_SECONDARY_BANKS]; // capacity of a bank -hoffoss
222  int path_num; // path index into polymodel .paths array. -2 if none exists, -1 if not defined
223 
225  queued_animation *triggers; //all the triggered animations associated with this object
226 
228 
229  // target priority setting for turrets
232 
235 
237 
238  //Per-turret ownage settings - SUSHI
242 
243 typedef struct model_special {
244  struct model_special *next, *prev; // for using as a linked list
245  int bank; // used for sequencing gun/missile backs. approach/docking points
246  int slot; // location for gun or missile in this bank
247  vec3d pnt; // point where this special submodel thingy is at
248  vec3d norm; // normal for the special submodel thingy
249 } model_special;
250 
251 // model arc types
252 #define MARC_TYPE_NORMAL 0 // standard freespace 1 blue lightning arcs
253 #define MARC_TYPE_EMP 1 // EMP blast type arcs
254 
255 #define MAX_LIVE_DEBRIS 7
256 
257 typedef struct model_tmap_vert {
260  float u,v;
262 
266 
267  int back;
268  int front;
269 
270  int leaf;
271 };
272 
276  float face_rad;
280 
281  int next;
282 };
283 
286  int n_nodes;
287 
289  int n_leaves;
290 
293 
294  int n_verts;
295  bool used;
296 };
297 
298 class bsp_info
299 {
300 public:
308  look_at_num(-1)
309  {
310  name[0] = 0;
311  lod_name[0] = 0;
312  look_at[0] = 0;
313 
316 
317  memset(&bounding_box, 0, 8 * sizeof(vec3d));
318  memset(&angs, 0, sizeof(angles));
319  memset(&live_debris, 0, MAX_LIVE_DEBRIS * sizeof(int));
320  memset(&details, 0, MAX_MODEL_DETAIL_LEVELS * sizeof(int));
321  memset(&arc_pts, 0, MAX_ARC_EFFECTS * 2 * sizeof(vec3d));
322  memset(&arc_type, 0, MAX_ARC_EFFECTS * sizeof(ubyte));
323  }
324 
325  char name[MAX_NAME_LEN]; // name of the subsystem. Probably displayed on HUD
326  int movement_type; // -1 if no movement, otherwise rotational or positional movement -- subobjects only
327  int movement_axis; // which axis this subobject moves or rotates on.
328  bool can_move; // If true, the position and/or orientation of this submodel can change due to rotation of itself OR a parent
329 
330  vec3d offset; // 3d offset from parent object
331  matrix orientation; // 3d orientation relative to parent object
332 
335 
337 
338  vec3d geometric_center; // geometric center of this subobject. In the same Frame Of
339  // Reference as all other vertices in this submodel. (Relative to pivot point)
340  float rad; // radius for each submodel
341 
342  vec3d min; // The min point of this object's geometry
343  vec3d max; // The max point of this object's geometry
344  vec3d bounding_box[8]; // calculated fron min/max
345 
346  int blown_off; // If set, this subobject is blown off. Stuffed by model_set_instance
347  int my_replacement; // If not -1 this subobject is what should get rendered instead of this one
348  int i_replace; // If this is not -1, then this subobject will replace i_replace when it is damaged
349  angles angs; // The rotation angles of this subobject (Within its own orientation, NOT relative to parent - KeldorKatarn)
350 
351  int is_live_debris; // whether current submodel is a live debris model
352  int num_live_debris; // num live debris models assocaiated with a submodel
353  int live_debris[MAX_LIVE_DEBRIS]; // array of live debris submodels for a submodel
354 
357 
358  // Tree info
359  int parent; // what is parent for each submodel, -1 if none
360  int num_children; // How many children this model has
361  int first_child; // The first_child of this model, -1 if none
362  int next_sibling; // This submodel's next sibling, -1 if none
363 
364  int num_details; // How many submodels are lower detail "mirrors" of this submodel
365  int details[MAX_MODEL_DETAIL_LEVELS]; // A list of all the lower detail "mirrors" of this submodel
366 
367  // Electrical Arc Effect Info
368  // Sets a spark for this submodel between vertex v1 and v2
369  int num_arcs; // See model_add_arc for more info
371  ubyte arc_type[MAX_ARC_EFFECTS]; // see MARC_TYPE_* defines
372 
373  // buffers used by HT&L
376 
379 
385  int use_render_box; // 0==do nothing, 1==only render this object if you are inside the box, -1==only if you're outside
386  bool use_render_box_offset; // whether an offset has been defined; needed because one can't tell just by looking at render_box_offset
387  int use_render_sphere; // 0==do nothing, 1==only render this object if you are inside the sphere, -1==only if you're outside
388  bool use_render_sphere_offset;// whether an offset has been defined; needed because one can't tell just by looking at render_sphere_offset
389  bool gun_rotation; // for animated weapon models
390  bool no_collisions; // for $no_collisions property - kazan
391  bool nocollide_this_only; //SUSHI: Like no_collisions, but not recursive. For the "replacement" collision model scheme.
392  bool collide_invisible; //SUSHI: If set, this submodel should allow collisions for invisible textures. For the "replacement" collision model scheme.
393  bool force_turret_normal; //Wanderer: Sets the turret uvec to override any input of for turret normal.
394  char lod_name[MAX_NAME_LEN]; //FUBAR: Name to be used for LOD naming comparison to preserve compatibility with older tables. Only used on LOD0
395  bool attach_thrusters; //zookeeper: If set and this submodel or any of its parents rotates, also rotates associated thrusters.
396  float dumb_turn_rate; //Bobboau
397  //int look_at; //Bobboau
398  int look_at_num; //VA - number of the submodel to be looked at by this submodel (-1 if none)
399  char look_at[MAX_NAME_LEN]; //VA - name of submodel to be looked at by this submodel
400 };
401 
402 void parse_triggersint(int &n_trig, queued_animation **triggers, char *props);
403 
404 #define MP_TYPE_UNUSED 0
405 #define MP_TYPE_SUBSYS 1
406 
407 typedef struct mp_vert {
408  vec3d pos; // xyz coordinates of vertex in object's frame of reference
409  int nturrets; // number of turrets guarding this vertex
410  int *turret_ids; // array of indices into ship_subsys linked list (can't index using [] though)
411  float radius; // How far the closest obstruction is from this vertex
412 } mp_vert;
413 
414 typedef struct model_path {
415  char name[MAX_NAME_LEN]; // name of the subsystem. Probably displayed on HUD
416  char parent_name[MAX_NAME_LEN]; // parent name of submodel that path is linked to in POF
418  int nverts;
420  int goal; // Which of the verts is the one closest to the goal of this path
421  int type; // What this path takes you to... See MP_TYPE_??? defines above for details
422  int value; // This depends on the type.
423  // For MP_TYPE_UNUSED, this means nothing.
424  // For MP_TYPE_SUBSYS, this is the subsystem number this path takes you to.
425 } model_path;
426 
427 // info for gun and missile banks. Also used for docking points. There should always
428 // only be two slots for each docking bay
429 
430 #define MAX_SLOTS 25
431 
432 typedef struct w_bank {
437 } w_bank;
438 
439 struct glow_point{
442  float radius;
443 };
444 
445 typedef struct thruster_bank {
448 
449  // Engine wash info
450  struct engine_wash_info *wash_info_pointer; // index into Engine_wash_info
451  int obj_num; // what subsystem number this bank is on; index to ship_info->subsystems
452  int submodel_num; // what submodel number this bank is on; index to polymodel->submodel/polymodel_instance->submodel
453 } thruster_bank;
454 
455 #define PULSE_SIN 1
456 #define PULSE_COS 2
457 #define PULSE_TRI 3
458 #define PULSE_SHIFTTRI 4
459 
460 typedef struct glow_point_bank { // glow bank structure -Bobboau
461  int type;
463  int on_time;
464  int off_time;
465  int disp_time;
466  bool is_on;
468  int LOD;
474 
475 typedef struct glow_point_bank_override {
476  char name[33];
477  int type;
478  int on_time;
479  int off_time;
480  int disp_time;
483  bool is_on;
484 
490 
494  float pulse_bias;
500  bool lightcone;
501  float cone_angle;
504  bool dualcone;
505  bool rotating;
508 
511 
512 // defines for docking bay things. The types are essentially flags since docking bays can probably
513 // be used for multiple things in some cases (i.e. rearming and general docking)
514 //WMC - IMPORTANT, update Dock_type_names array if you add a new one of these
516 extern int Num_dock_type_names;
517 
518 #define DOCK_TYPE_CARGO (1<<0)
519 #define DOCK_TYPE_REARM (1<<1)
520 #define DOCK_TYPE_GENERIC (1<<2)
521 
522 #define MAX_DOCK_SLOTS 2
523 
524 typedef struct dock_bay {
526  int type_flags; // indicates what this docking bay can be used for (i.e. cargo/rearm, etc)
527  int num_spline_paths; // number of spline paths which lead to this docking bay
528  int *splines; // array of indices into the Spline_path array
529  char name[MAX_NAME_LEN]; // name of this docking location
532 } dock_bay;
533 
534 // struct that holds the indicies into path information associated with a fighter bay on a capital ship
535 // NOTE: Fighter bay paths are identified by the path_name $bayN (where N is numbered from 1).
536 // Capital ships only have ONE fighter bay on the entire ship
537 // NOTE: MAX_SHIP_BAY_PATHS cannot be bumped higher than 31 without rewriting the arrival/departure flag logic.
538 #define MAX_SHIP_BAY_PATHS 31
539 typedef struct ship_bay {
540  int num_paths; // how many paths are associated with the model's fighter bay
541  int path_indexes[MAX_SHIP_BAY_PATHS]; // index into polymodel->paths[] array
542  int arrive_flags; // bitfield, set to 1 when that path number is reserved for an arrival
543  int depart_flags; // bitfield, set to 1 when that path number is reserved for a departure
544 } ship_bay_t;
545 
546 // three structures now used for representing shields.
547 // shield_tri structure stores information concerning each face of the shield.
548 // verts indexes into the verts array in the higher level structure
549 // neighbors indexes into the tris array in the higher level structure
550 typedef struct shield_tri {
551  int used;
552  int verts[3]; // 3 indices into vertex list of the shield. list found in shield_info struct
553  int neighbors[3]; // indices into array of triangles. neighbor = shares edge. list found in shield_info struct
554  vec3d norm; // norm of this triangle
555 } shield_tri;
556 
557 // a list of these shield_vertex structures comprimises the vertex list of the shield.
558 // The verts array in the shield_tri structure points to one of these members
559 typedef struct shield_vertex {
561  float u,v;
562 } shield_vertex;
563 
564 // the high level shield structure. A ship without any shield has nverts and ntris set to 0.
565 // The vertex list and the tris list are used by the shield_tri structure
566 typedef struct shield_info {
567  int nverts;
568  int ntris;
571 } shield_info;
572 
573 #define BSP_LIGHT_TYPE_WEAPON 1
574 #define BSP_LIGHT_TYPE_THRUSTER 2
575 
576 typedef struct bsp_light {
578  int type; // See BSP_LIGHT_TYPE_?? for values
579  float value; // How much to light up this light. 0-1.
580 } bsp_light;
581 
582 // model_octant - There are 8 of these per model. They are a handy way to categorize
583 // a lot of model properties to get some easy 8x optimizations for model stuff.
584 typedef struct model_octant {
585  vec3d min, max; // The bounding box that makes up this octant defined as 2 points.
586  int nverts; // how many vertices are in this octant
587  vec3d **verts; // The vertices in this octant in the high-res hull. A vertex can only be in one octant.
588  int nshield_tris; // how many shield triangles are in the octant
589  shield_tri **shield_tris; // the shield triangles that make up this octant. A tri could be in multiple octants.
590 } model_octant;
591 
592 #define MAX_EYES 10
593 
594 typedef struct eye {
595  int parent; // parent's subobject number
596  vec3d pnt; // the point for the eye
597  vec3d norm; // direction the eye faces. Not used with first eye since player orient is used
598 } eye;
599 
600 typedef struct cross_section {
601  float z;
602  float radius;
603 } cross_section;
604 
605 #define MAX_MODEL_INSIGNIAS 6
606 #define MAX_INS_FACE_VECS 3
607 #define MAX_INS_VECS 81
608 #define MAX_INS_FACES 128
609 typedef struct insignia {
611  int num_faces;
612  int faces[MAX_INS_FACES][MAX_INS_FACE_VECS]; // indices into the vecs array
613  float u[MAX_INS_FACES][MAX_INS_FACE_VECS]; // u tex coords on a per-face-per-vertex basis
614  float v[MAX_INS_FACES][MAX_INS_FACE_VECS]; // v tex coords on a per-face-per-vertex bases
615  vec3d vecs[MAX_INS_VECS]; // vertex list
616  vec3d offset; // global position offset for this insignia
617  vec3d norm[MAX_INS_VECS] ; //normal of the insignia-Bobboau
618 } insignia;
619 
620 #define PM_FLAG_ALLOW_TILING (1<<0) // Allow texture tiling
621 #define PM_FLAG_AUTOCEN (1<<1) // contains autocentering info
622 #define PM_FLAG_TRANS_BUFFER (1<<2) // render transparency buffer
623 #define PM_FLAG_BATCHED (1<<3) // this model can be batch rendered
624 #define PM_FLAG_HAS_INTRINSIC_ROTATE (1<<4) // whether this model has an intrinsic rotation submodel somewhere
625 
626 // Goober5000
628 {
629 private:
630  int original_texture; // what gets read in from file
631  int texture; // what texture you draw with; reset to original_textures by model_set_instance
632 
633  //WMC - Removed unneeded struct and is_anim to clean this up.
634  //If num_frames is < 2, it doesn't need to be treated like an animation.
635  int num_frames;
636  float total_time; // in seconds
637 
638 public:
639  texture_info();
640  texture_info(int bm_handle);
641  void clear();
642 
643  int GetNumFrames();
644  int GetOriginalTexture();
645  int GetTexture();
646  float GetTotalTime();
647 
648  int LoadTexture(char *filename, char *dbg_name);
649 
650  void PageIn();
651  void PageOut(bool release);
652 
653  int ResetTexture();
654  int SetTexture(int n_tex);
655 };
656 
657 #define TM_BASE_TYPE 0 // the standard base map
658 #define TM_GLOW_TYPE 1 // optional glow map
659 #define TM_SPECULAR_TYPE 2 // optional specular map
660 #define TM_NORMAL_TYPE 3 // optional normal map
661 #define TM_HEIGHT_TYPE 4 // optional height map (for parallax mapping)
662 #define TM_MISC_TYPE 5 // optional utility map
663 #define TM_NUM_TYPES 6 //WMC - Number of texture_info objects in texture_map
664  //Used by scripting - if you change this, do a search
665  //to update switch() statement in lua.cpp
666 // taylor
667 //WMC - OOPified
669 {
670 public:
672 
675 
676  int FindTexture(int bm_handle);
677  int FindTexture(char *name);
678 
679  void PageIn();
680  void PageOut(bool release);
681 
682  void Clear();
683  void ResetToOriginal();
684 
686  : is_ambient(false), is_transparent(false)
687  {}
688 };
689 
690 #define MAX_REPLACEMENT_TEXTURES MAX_MODEL_TEXTURES * TM_NUM_TYPES
691 
692 // Goober5000 - since we need something < 0
693 #define REPLACE_WITH_INVISIBLE -47
694 
695 //used to describe a polygon model
696 // NOTE: Because WMC OOPified the textures, this must now be treated as a class, rather than a struct.
697 // Additionally, a lot of model initialization and de-initialization is currently done in model_load or model_unload.
699 {
700 public:
701  // initialize to 0 and NULL because previously a memset was used
703  : id(-1), version(0), flags(0), n_detail_levels(0), num_debris_objects(0), n_models(0), num_lights(0), lights(NULL),
704  n_view_positions(0), rad(0.0f), core_radius(0.0f), n_textures(0), submodel(NULL), n_guns(0), n_missiles(0), n_docks(0),
705  n_thrusters(0), gun_banks(NULL), missile_banks(NULL), docking_bays(NULL), thrusters(NULL), ship_bay(NULL),
706  shield_collision_tree(NULL), sldc_size(0), n_paths(0), paths(NULL), mass(0), num_xc(0), xc(NULL), num_split_plane(0),
708  vertex_buffer_id(-1)
709  {
710  filename[0] = 0;
713 
714  memset(&detail, 0, MAX_MODEL_DETAIL_LEVELS * sizeof(int));
715  memset(&detail_depth, 0, MAX_MODEL_DETAIL_LEVELS * sizeof(float));
716  memset(&debris_objects, 0, MAX_DEBRIS_OBJECTS * sizeof(int));
717  memset(&bounding_box, 0, 8 * sizeof(vec3d));
718  memset(&view_positions, 0, MAX_EYES * sizeof(eye));
719  memset(&shield, 0, sizeof(shield_info));
720  memset(&octants, 0, 8 * sizeof(model_octant));
721  memset(&split_plane, 0, MAX_SPLIT_PLANE * sizeof(float));
722  memset(&ins, 0, MAX_MODEL_INSIGNIAS * sizeof(insignia));
723 
724 #ifndef NDEBUG
725  ram_used = 0;
726  debug_info_size = 0;
727  debug_info = NULL;
728 #endif
729  }
730 
731 
732  int id; // what the polygon model number is. (Index in Polygon_models)
733  int version;
735 
736  uint flags; // 1=allow tiling
740 
743 
744  int n_models;
745 
746  vec3d mins,maxs; //min,max for whole model
748 
749  int num_lights; // how many lights there are
750  bsp_light * lights; // array of light info
751 
752  int n_view_positions; // number of viewing positions available on this ship
753  eye view_positions[MAX_EYES]; //viewing positions. Default to {0,0,0}. in location 0
754 
755  vec3d autocenter; // valid only if PM_FLAG_AUTOCEN is set
756 
757  float rad; // The radius of everything in the model; shields, thrusters.
758  float core_radius; // The radius to be used for collision detection in small ship vs big ships.
759  // This is equal to 1/2 of the smallest dimension of the hull's bounding box.
760  // texture maps for model
763 
764  bsp_info *submodel; // an array of size n_models of submodel info.
765 
766  // linked lists for special polygon types on this model. Most ships I think will have most
767  // of these. (most ships however, probably won't have approach points).
768  int n_guns; // number of primary gun points (not counting turrets)
769  int n_missiles; // number of secondary missile points (not counting turrets)
770  int n_docks; // number of docking points
771  int n_thrusters; // number of thrusters on this ship.
772  w_bank *gun_banks; // array of gun banks
773  w_bank *missile_banks; // array of missile banks
774  dock_bay *docking_bays; // array of docking point pairs
775  thruster_bank *thrusters; // array of thruster objects -- likely to change in the future
776  ship_bay_t *ship_bay; // contains path indexes for ship bay approach/depart paths
777 
778  shield_info shield; // new shield information
782 
783  int n_paths;
785 
786  // physics info
787  float mass;
790 
792 
793  int num_xc; // number of cross sections
794  cross_section* xc; // pointer to array of cross sections (used in big ship explosions)
795 
796  int num_split_plane; // number of split planes
797  float split_plane[MAX_SPLIT_PLANE]; // actual split plane z coords (for big ship explosions)
798 
800  int num_ins;
801 
802 #ifndef NDEBUG
803  int ram_used; // How much RAM this model uses
805  char *debug_info;
806 #endif
807 
808  int used_this_mission; // used for page-in system, how many times this model has been loaded per mission - taylor
809 
810  int n_glow_point_banks; // number of glow points on this ship. -Bobboau
811  glow_point_bank *glow_point_banks; // array of glow objects -Bobboau
812 
814 
815  int vertex_buffer_id; // HTL vertex buffer id
816 
818 };
819 
820 // Call once to initialize the model system
821 void model_init();
822 
823 // call to unload a model (works like bm_unload()), "force" SHOULD NEVER BE SET outside of modelread.cpp!!!!
824 void model_unload(int modelnum, int force = 0);
825 
826 // Call to free all existing models
827 void model_free_all();
829 
830 // Loads a model from disk and returns the model number it loaded into.
831 int model_load(char *filename, int n_subsystems, model_subsystem *subsystems, int ferror = 1, int duplicate = 0);
832 
833 int model_create_instance(bool is_ship, int model_num);
835 
836 // Goober5000
837 void model_load_texture(polymodel *pm, int i, char *file);
838 
839 // Returns a pointer to the polymodel structure for model 'n'
841 
843 
844 // routine to copy susbsystems. Must be called when subsystems sets are the same -- see ship.cpp
845 void model_copy_subsystems(int n_subsystems, model_subsystem *d_sp, model_subsystem *s_sp);
846 
847 // If MR_FLAG_OUTLINE bit set this color will be used for outlines.
848 // This defaults to black.
849 void model_set_outline_color(int r, int g, int b);
850 
851 void model_set_outline_color_fast(void *outline_color);
852 
853 // IF MR_LOCK_DETAIL is set, then it will always draw detail level 'n'
854 // This defaults to 0. (0=highest, larger=lower)
855 void model_set_detail_level(int n);
856 
857 // Flags you can pass to model_render
858 #define MR_NORMAL (0) // Draw a normal object
859 #define MR_SHOW_OUTLINE (1<<0) // Draw the object in outline mode. Color specified by model_set_outline_color
860 #define MR_SKYBOX (1<<1) // Draw as a skybox
861 #define MR_DESATURATED (1<<2) // Draw model in monochrome using outline color
862 #define MR_EMPTY_SLOT0 (1<<3) // Show the radius around the object
863 #define MR_EMPTY_SLOT1 (1<<4) // Show the shield mesh
864 #define MR_SHOW_THRUSTERS (1<<5) // Show the engine thrusters. See model_set_thrust for how long it draws.
865 #define MR_EMPTY_SLOT2 (1<<6) // Only draw the detail level defined in model_set_detail_level
866 #define MR_NO_POLYS (1<<7) // Don't draw the polygons.
867 #define MR_NO_LIGHTING (1<<8) // Don't perform any lighting on the model.
868 #define MR_NO_TEXTURING (1<<9) // Draw textures as flat-shaded polygons.
869 #define MR_NO_CORRECT (1<<10) // Don't to correct texture mapping
870 #define MR_NO_SMOOTHING (1<<11) // Don't perform smoothing on vertices.
871 #define MR_IS_ASTEROID (1<<12) // When set, treat this as an asteroid.
872 #define MR_IS_MISSILE (1<<13) // When set, treat this as a missilie. No lighting, small thrusters.
873 #define MR_SHOW_OUTLINE_PRESET (1<<14) // Draw the object in outline mode. Color assumed to be set already.
874 #define MR_SHOW_INVISIBLE_FACES (1<<15) // Show invisible faces as green...
875 #define MR_AUTOCENTER (1<<16) // Always use the center of the hull bounding box as the center, instead of the pivot point
876 #define MR_EMPTY_SLOT3 (1<<17) // draw bay paths
877 #define MR_ALL_XPARENT (1<<18) // render it fully transparent
878 #define MR_NO_ZBUFFER (1<<19) // switch z-buffering off completely
879 #define MR_NO_CULL (1<<20) // don't cull backfacing poly's
880 #define MR_EMPTY_SLOT4 (1<<21) // force a given texture to always be used
881 #define MR_NO_BATCH (1<<22) // don't use submodel batching when rendering
882 #define MR_EDGE_ALPHA (1<<23) // makes norms that are faceing away from you render more transparent -Bobboau
883 #define MR_CENTER_ALPHA (1<<24) // oposite of above -Bobboau
884 #define MR_NO_FOGGING (1<<25) // Don't fog - taylor
885 #define MR_SHOW_OUTLINE_HTL (1<<26) // Show outlines (wireframe view) using HTL method
886 #define MR_NO_GLOWMAPS (1<<27) // disable rendering of glowmaps - taylor
887 #define MR_FULL_DETAIL (1<<28) // render all valid objects, particularly ones that are otherwise in/out of render boxes - taylor
888 #define MR_FORCE_CLAMP (1<<29) // force clamp - Hery
889 #define MR_EMPTY_SLOT5 (1<<30) // Use a animated Shader - Valathil
890 #define MR_ATTACHED_MODEL (1<<31) // Used for attached weapon model lodding
891 
892 #define MR_DEPRECATED_NORMAL (0) // Draw a normal object
893 #define MR_DEPRECATED_SHOW_OUTLINE (1<<0) // Draw the object in outline mode. Color specified by model_set_outline_color
894 #define MR_DEPRECATED_SHOW_PIVOTS (1<<1) // Show the pivot points
895 #define MR_DEPRECATED_SHOW_PATHS (1<<2) // Show the paths associated with a model
896 #define MR_DEPRECATED_SHOW_RADIUS (1<<3) // Show the radius around the object
897 #define MR_DEPRECATED_SHOW_SHIELDS (1<<4) // Show the shield mesh
898 #define MR_DEPRECATED_SHOW_THRUSTERS (1<<5) // Show the engine thrusters. See model_set_thrust for how long it draws.
899 #define MR_DEPRECATED_LOCK_DETAIL (1<<6) // Only draw the detail level defined in model_set_detail_level
900 #define MR_DEPRECATED_NO_POLYS (1<<7) // Don't draw the polygons.
901 #define MR_DEPRECATED_NO_LIGHTING (1<<8) // Don't perform any lighting on the model.
902 #define MR_DEPRECATED_NO_TEXTURING (1<<9) // Draw textures as flat-shaded polygons.
903 #define MR_DEPRECATED_NO_CORRECT (1<<10) // Don't to correct texture mapping
904 #define MR_DEPRECATED_NO_SMOOTHING (1<<11) // Don't perform smoothing on vertices.
905 #define MR_DEPRECATED_IS_ASTEROID (1<<12) // When set, treat this as an asteroid.
906 #define MR_DEPRECATED_IS_MISSILE (1<<13) // When set, treat this as a missilie. No lighting, small thrusters.
907 #define MR_DEPRECATED_SHOW_OUTLINE_PRESET (1<<14) // Draw the object in outline mode. Color assumed to be set already.
908 #define MR_DEPRECATED_SHOW_INVISIBLE_FACES (1<<15) // Show invisible faces as green...
909 #define MR_DEPRECATED_AUTOCENTER (1<<16) // Always use the center of the hull bounding box as the center, instead of the pivot point
910 #define MR_DEPRECATED_BAY_PATHS (1<<17) // draw bay paths
911 #define MR_DEPRECATED_ALL_XPARENT (1<<18) // render it fully transparent
912 #define MR_DEPRECATED_NO_ZBUFFER (1<<19) // switch z-buffering off completely
913 #define MR_DEPRECATED_NO_CULL (1<<20) // don't cull backfacing poly's
914 #define MR_DEPRECATED_FORCE_TEXTURE (1<<21) // force a given texture to always be used
915 #define MR_DEPRECATED_FORCE_LOWER_DETAIL (1<<22) // force the model to draw 1 LOD lower, if possible
916 #define MR_DEPRECATED_EDGE_ALPHA (1<<23) // makes norms that are faceing away from you render more transparent -Bobboau
917 #define MR_DEPRECATED_CENTER_ALPHA (1<<24) // oposite of above -Bobboau
918 #define MR_DEPRECATED_NO_FOGGING (1<<25) // Don't fog - taylor
919 #define MR_DEPRECATED_SHOW_OUTLINE_HTL (1<<26) // Show outlines (wireframe view) using HTL method
920 #define MR_DEPRECATED_NO_GLOWMAPS (1<<27) // disable rendering of glowmaps - taylor
921 #define MR_DEPRECATED_FULL_DETAIL (1<<28) // render all valid objects, particularly ones that are otherwise in/out of render boxes - taylor
922 #define MR_DEPRECATED_FORCE_CLAMP (1<<29) // force clamp - Hery
923 #define MR_DEPRECATED_ANIMATED_SHADER (1<<30) // Use a animated Shader - Valathil
924 #define MR_DEPRECATED_ATTACHED_MODEL (1<<31) // Used for attached weapon model lodding
925 
926 #define MR_DEBUG_PIVOTS (1<<0) // Show the pivot points
927 #define MR_DEBUG_PATHS (1<<1) // Show the paths associated with a model
928 #define MR_DEBUG_RADIUS (1<<2) // Show the radius around the object
929 #define MR_DEBUG_SHIELDS (1<<3) // Show the shield mesh
930 #define MR_DEBUG_BAY_PATHS (1<<4) // draw bay paths
931 
932 //Defines for the render parameter of model_render, model_really_render and model_render_buffers
933 #define MODEL_RENDER_OPAQUE 1
934 #define MODEL_RENDER_TRANS 2
935 #define MODEL_RENDER_ALL 3
936 
937 // Renders a model and all it's submodels.
938 // See MR_? defines for values for flags
939 void model_render_DEPRECATED(int model_num, matrix *orient, vec3d * pos, uint flags = MR_DEPRECATED_NORMAL, int objnum = -1, int lighting_skip = -1, int *replacement_textures = NULL, int render = MODEL_RENDER_ALL, const bool is_skybox = false);
940 
941 // Renders just one particular submodel on a model.
942 // See MR_? defines for values for flags
943 void submodel_render_DEPRECATED(int model_num,int submodel_num, matrix *orient, vec3d * pos, uint flags = MR_DEPRECATED_NORMAL, int objnum = -1, int *replacement_textures = NULL, int render = MODEL_RENDER_ALL);
944 
945 // Returns the radius of a model
946 float model_get_radius(int modelnum);
947 float submodel_get_radius(int modelnum, int submodelnum);
948 
949 // Returns the core radius (smallest dimension of hull's bounding box, used for collision detection with big ships only)
950 float model_get_core_radius(int modelnum);
951 
952 // Returns zero is x1,y1,x2,y2 are valid
953 // returns 1 for invalid model, 2 for point offscreen.
954 // note that x1,y1,x2,y2 aren't clipped to 2d screen coordinates!
955 // This function just looks at the radius, and not the orientation, so the
956 // bounding box won't change depending on the obj's orient.
957 extern int model_find_2d_bound(int model_num,matrix *orient, vec3d * pos,int *x1, int *y1, int *x2, int *y2);
958 
959 // Returns zero is x1,y1,x2,y2 are valid
960 // returns 1 for invalid model, 2 for point offscreen.
961 // note that x1,y1,x2,y2 aren't clipped to 2d screen coordinates!
962 // This function looks at the object's bounding box and it's orientation,
963 // so the bounds will change as the object rotates, to give the minimum bouding
964 // rect.
965 extern int model_find_2d_bound_min(int model_num,matrix *orient, vec3d * pos,int *x1, int *y1, int *x2, int *y2);
966 
967 // Returns zero is x1,y1,x2,y2 are valid
968 // returns 1 for invalid model, 2 for point offscreen.
969 // note that x1,y1,x2,y2 aren't clipped to 2d screen coordinates!
970 // This function looks at the object's bounding box and it's orientation,
971 // so the bounds will change as the object rotates, to give the minimum bouding
972 // rect.
973 int submodel_find_2d_bound_min(int model_num,int submodel, matrix *orient, vec3d * pos,int *x1, int *y1, int *x2, int *y2);
974 
975 
976 // Returns zero is x1,y1,x2,y2 are valid
977 // Returns 2 for point offscreen.
978 // note that x1,y1,x2,y2 aren't clipped to 2d screen coordinates!
979 // This function just looks at the radius, and not the orientation, so the
980 // bounding box won't change depending on the obj's orient.
981 int subobj_find_2d_bound(float radius, matrix *orient, vec3d * pos,int *x1, int *y1, int *x2, int *y2);
982 
983 // stats variables
984 #ifndef NDEBUG
985 extern int modelstats_num_polys;
986 extern int modelstats_num_polys_drawn;
987 extern int modelstats_num_verts;
988 extern int modelstats_num_sortnorms;
989 #endif
990 
991 // Tries to move joints so that the turret points to the point dst.
992 // turret1 is the angles of the turret, turret2 is the angles of the gun from turret
993 extern int model_rotate_gun(int model_num, model_subsystem *turret, matrix *orient, angles *base_angles, angles *gun_angles, vec3d *pos, vec3d *dst, int obj_idx, bool reset = false);
994 
995 // Gets and sets turret rotation matrix
996 extern void model_make_turret_matrix(int model_num, model_subsystem * turret );
997 
998 // Rotates the angle of a submodel. Use this so the right unlocked axis
999 // gets stuffed.
1000 extern void submodel_rotate(model_subsystem *psub, submodel_instance_info *sii);
1002 
1003 // Rotates the angle of a submodel. Use this so the right unlocked axis
1004 // gets stuffed. Does this for stepped rotations
1006 
1007 // Goober5000
1008 // For a submodel, return its overall offset from the main model.
1009 extern void model_find_submodel_offset(vec3d *outpnt, int model_num, int sub_model_num);
1010 
1011 // Given a point (pnt) that is in sub_model_num's frame of
1012 // reference, and given the object's orient and position,
1013 // return the point in 3-space in outpnt.
1014 extern void model_find_world_point(vec3d *outpnt, vec3d *mpnt, int model_num, int submodel_num, const matrix *objorient, const vec3d *objpos);
1015 extern void model_instance_find_world_point(vec3d *outpnt, vec3d *mpnt, int model_instance_num, int submodel_num, const matrix *objorient, const vec3d *objpos);
1016 
1017 // Given a point in the world RF, find the corresponding point in the model RF.
1018 // This is special purpose code, specific for model collision.
1019 // NOTE - this code ASSUMES submodel is 1 level down from hull (detail[0])
1020 void world_find_model_point(vec3d *out, vec3d *world_pt, const polymodel *pm, int submodel_num, const matrix *orient, const vec3d *pos);
1021 void world_find_model_instance_point(vec3d *out, vec3d *world_pt, const polymodel_instance *pmi, int submodel_num, const matrix *orient, const vec3d *pos);
1022 
1023 extern void find_submodel_instance_point(vec3d *outpnt, int model_instance_num, int submodel_num);
1024 extern void find_submodel_instance_point_normal(vec3d *outpnt, vec3d *outnorm, int model_instance_num, int submodel_num, const vec3d *submodel_pnt, const vec3d *submodel_norm);
1025 extern void find_submodel_instance_point_orient(vec3d *outpnt, matrix *outorient, int model_instance_num, int submodel_num, const vec3d *submodel_pnt, const matrix *submodel_orient);
1026 extern void find_submodel_instance_world_point(vec3d *outpnt, int model_instance_num, int submodel_num, const matrix *objorient, const vec3d *objpos);
1027 
1028 // Given a polygon model index, find a list of rotating submodels to be used for collision
1029 void model_get_rotating_submodel_list(SCP_vector<int> *submodel_vector, object *objp);
1030 
1031 // Given a polygon model index, get a list of a model tree starting from that index
1032 void model_get_submodel_tree_list(SCP_vector<int> &submodel_vector, polymodel* pm, int mn);
1033 
1034 // For a rotating submodel, find a point on the axis
1036 
1037 // Given a direction (pnt) that is in sub_model_num's frame of
1038 // reference, and given the object's orient and position,
1039 // return the point in 3-space in outpnt.
1040 extern void model_find_world_dir(vec3d *out_dir, vec3d *in_dir, int model_num, int submodel_num, const matrix *objorient);
1041 extern void model_instance_find_world_dir(vec3d *out_dir, vec3d *in_dir, int model_instance_num, int submodel_num, const matrix *objorient);
1042 
1043 // Clears all the submodel instances stored in a model to their defaults.
1044 extern void model_clear_instance(int model_num);
1045 
1048 
1049 // Sets rotating submodel turn info to that stored in model
1050 void model_set_instance_info(submodel_instance_info *sii, float turn_rate, float turn_accel);
1051 
1052 // Clears all the values in a particular instance to their defaults.
1054 
1055 // Sets the submodel instance data in a submodel
1056 extern void model_set_instance(int model_num, int sub_model_num, submodel_instance_info *sii, int flags = 0);
1057 extern void model_set_instance_techroom(int model_num, int sub_model_num, float angle_1, float angle_2);
1058 
1059 void model_update_instance(int model_instance_num, int sub_model_num, submodel_instance_info *sii, int flags);
1060 
1061 // Adds an electrical arcing effect to a submodel
1062 void model_add_arc(int model_num, int sub_model_num, vec3d *v1, vec3d *v2, int arc_type);
1063 
1064 // Fills in an array with points from a model. Only gets up to max_num verts.
1065 // Returns number of verts found
1066 extern int submodel_get_points(int model_num, int submodel_num, int max_num, vec3d **nts);
1067 
1068 // Gets two random points on the surface of a submodel
1069 extern void submodel_get_two_random_points(int model_num, int submodel_num, vec3d *v1, vec3d *v2, vec3d *n1 = NULL, vec3d *n2 = NULL);
1071 // gets the index into the docking_bays array of the specified type of docking point
1072 // Returns the index. second functions returns the index of the docking bay with
1073 // the specified name
1074 extern int model_find_dock_index(int modelnum, int dock_type, int index_to_start_at = 0);
1075 extern int model_find_dock_name_index(int modelnum, char *name);
1076 
1077 // returns the actual name of a docking point on a model, needed by Fred.
1078 char *model_get_dock_name(int modelnum, int index);
1079 
1080 // returns number of docking points for a model
1081 int model_get_num_dock_points(int modelnum);
1082 int model_get_dock_index_type(int modelnum, int index);
1083 
1084 // get all the different docking point types on a model
1085 int model_get_dock_types(int modelnum);
1086 
1087 // Goober5000
1088 // returns index in [0, MAX_SHIP_BAY_PATHS)
1089 int model_find_bay_path(int modelnum, char *bay_path_name);
1090 
1091 // Returns number of verts in a submodel;
1093 
1094 // Returns number of polygons in a submodel;
1096 
1097 // Given a vector that is in sub_model_num's frame of
1098 // reference, and given the object's orient and position,
1099 // return the vector in the model's frame of reference.
1100 void model_find_obj_dir(vec3d *w_vec, vec3d *m_vec, int model_instance_num, int submodel_num, matrix *objorient);
1101 void model_instance_find_obj_dir(vec3d *w_vec, vec3d *m_vec, int model_instance_num, int submodel_num, matrix *objorient);
1102 
1103 
1104 // This is the interface to model_check_collision. Rather than passing all these
1105 // values and returning values in globals, just fill in a temporary variable with
1106 // the input values and call model_check_collision
1107 typedef struct mc_info {
1108  // Input values
1110  int model_num; // What model to check
1111  int submodel_num; // What submodel to check if MC_SUBMODEL is set
1112  matrix *orient; // The orient of the model
1113  vec3d *pos; // The pos of the model in world coordinates
1114  vec3d *p0; // The starting point of the ray (sphere) to check
1115  vec3d *p1; // The ending point of the ray (sphere) to check
1116  int flags; // Flags that the model_collide code looks at. See MC_??? defines
1117  float radius; // If MC_CHECK_THICK is set, checks a sphere moving with the radius.
1118  int lod; // Which detail level of the submodel to check instead
1119 
1120  // Return values
1121  int num_hits; // How many collisions were found
1122  float hit_dist; // The distance from p0 to hitpoint
1123  vec3d hit_point; // Where the collision occurred at in hit_submodel's coordinate system
1124  vec3d hit_point_world; // Where the collision occurred at in world coordinates
1125  int hit_submodel; // Which submodel got hit.
1126  int hit_bitmap; // Which texture got hit. -1 if not a textured poly
1127  float hit_u, hit_v; // Where on hit_bitmap the ray hit. Invalid if hit_bitmap < 0
1128  int shield_hit_tri; // Which triangle on the shield got hit or -1 if none
1129  vec3d hit_normal; // Vector normal of polygon of collision. (This is in submodel RF)
1130  int edge_hit; // Set if an edge got hit. Only valid if MC_CHECK_THICK is set.
1131  ubyte *f_poly; // pointer to flat poly where we intersected
1132  ubyte *t_poly; // pointer to tmap poly where we intersected
1134 
1135  // flags can be changed for the case of sphere check finds an edge hit
1136 } mc_info;
1137 
1138 inline void mc_info_init(mc_info *mc)
1139 {
1140  mc->model_instance_num = -1;
1141  mc->model_num = -1;
1142  mc->submodel_num = -1;
1143  mc->orient = nullptr;
1144  mc->pos = nullptr;
1145  mc->p0 = nullptr;
1146  mc->p1 = nullptr;
1147  mc->flags = 0;
1148  mc->lod = 0;
1149  mc->radius = 0;
1150  mc->num_hits = 0;
1151  mc->hit_dist = 0;
1152  mc->hit_point = vmd_zero_vector;
1154  mc->hit_submodel = -1;
1155  mc->hit_bitmap = -1;
1156  mc->hit_u = 0; mc->hit_v = 0;
1157  mc->shield_hit_tri = -1;
1159  mc->edge_hit = 0;
1160  mc->f_poly = nullptr;
1161  mc->t_poly = nullptr;
1162  mc->bsp_leaf = nullptr;
1163 }
1164 
1165 
1166 //======== MODEL_COLLIDE ============
1167 
1168 // Model Collision flags, used in model_collide()
1169 #define MC_CHECK_MODEL (1<<0) // Check the polygons in the model.
1170 #define MC_CHECK_SHIELD (1<<1) // check for collision against shield, if it exists.
1171 #define MC_ONLY_SPHERE (1<<2) // Only check bounding sphere. Not accurate, but fast.
1172  // NOTE! This doesn't set hit_point correctly with MC_CHECK_SPHERELINE
1173 #define MC_ONLY_BOUND_BOX (1<<3) // Only check bounding boxes. Pretty accurate and slower than MC_ONLY_SPHERE.
1174  // Checks the rotatated bounding box of each submodel.
1175  // NOTE! This doesn't set hit_point correctly with MC_CHECK_SPHERELINE
1176 #define MC_CHECK_RAY (1<<4) // Checks a ray from p0 *through* p1 on to infinity
1177 #define MC_CHECK_SPHERELINE (1<<5) // Checks a moving sphere rather than just a ray. Radius
1178 #define MC_SUBMODEL (1<<6) // If this is set, only check the submodel specified in mc->submodel_num. Use with MC_CHECK_MODEL
1179 #define MC_SUBMODEL_INSTANCE (1<<7) // Check submodel and its children (of a rotating submodel)
1180 #define MC_CHECK_INVISIBLE_FACES (1<<8) // Check the invisible faces.
1181 
1182 
1183 /*
1184  Checks to see if a vector from p0 to p0 collides with a model of
1185  type 'model_num' at 'orient' 'pos'.
1186 
1187  Returns the number of polys that were hit. Zero is none, obviously.
1188  Return true if a collision with hull (or shield, if MC_CHECK_SHIELD set),
1189  else return false.
1190 
1191  If it did it one or more, then hitpt is the closest 3d point that the
1192  vector hit. See the MC_? defines for flag values.
1193 
1194  Model_collide can test a sphere against either (1) shield or (2) model.
1195 
1196  To check a sphere, set the radius of sphere in mc_info structure and
1197  set the flag MC_CHECK_SPHERE.
1198 
1199  Here is a sample for how to use:
1200 
1201  mc_info mc;
1202 
1203  mc.model_num = ???; // Fill in the model to check
1204  mc.orient = &obj->orient; // The object's orient
1205  mc.pos = &obj->pos; // The object's position
1206  mc.p0 = &p0; // Point 1 of ray to check
1207  mc.p1 = &p1; // Point 2 of ray to check
1208  mc.flags = MC_CHECK_MODEL; // flags
1209 
1210 ** TO COLLIDE AGAINST A LINE SEGMENT
1211 
1212  model_collide(&mc);
1213  if (mc.num_hits) {
1214  // We hit submodel mc.hit_submodel on texture mc.hitbitmap,
1215  // at point mc.hit_point_world, with uv's of mc.hit_u, mc.hit_v.
1216  }
1217 
1218 ** TO COLLIDE AGAINST A SPHERE
1219  mc.flags |= MC_CHECK_SPHERELINE;
1220  mc.radius = radius;
1221 
1222  model_collide(&mc, radius);
1223  if (mc.num_hits) {
1224  // We hit submodel mc.hit_submodel on texture mc.hitbitmap,
1225  // at point mc.hit_point_world, with uv's of mc.hit_u, mc.hit_v.
1226  // Check (mc.edge_hit) to see if we hit an edge
1227  }
1228 */
1229 
1230 int model_collide(mc_info *mc_info_obj);
1231 void model_collide_parse_bsp(bsp_collision_tree *tree, void *model_ptr, int version);
1232 
1234 void model_remove_bsp_collision_tree(int tree_index);
1236 
1237 void model_collide_preprocess(matrix *orient, int model_instance_num, int detail = 0);
1238 
1239 // Sets the submodel instance data in a submodel
1240 // If show_damaged is true it shows only damaged submodels.
1241 // If it is false it shows only undamaged submodels.
1242 void model_show_damaged(int model_num, int show_damaged);
1243 
1244 
1245 //=========================== MODEL OCTANT STUFF ================================
1246 
1247 // Models are now divided into 8 octants. Shields too.
1248 // This made the collision code faster. Shield is 4x and ship faces
1249 // are about 2x faster.
1250 
1251 // Before, calling model_collide with flags=0 didn't check the shield
1252 // but did check the model itself. Setting the shield flags caused
1253 // the shield to get check along with the ship.
1254 // Now, you need to explicitly tell the model_collide code to check
1255 // the model, so you can check the model or shield or both.
1256 
1257 // If you need to check them both, do it in one call; this saves some
1258 // time. If checking the shield is sufficient for determining
1259 // something (like if it is under the hud) then use just shield
1260 // check, it is at least 5x faster than checking the model itself.
1261 
1262 
1263 // Model octant ordering - this is a made up ordering, but it makes sense.
1264 // X Y Z index description
1265 // - - - 0 left bottom rear
1266 // - - + 1 left bottom front
1267 // - + - 2 left top rear
1268 // - + + 3 left top front
1269 // + - - 4 right bottom rear
1270 // + - + 5 right bottom front
1271 // + + - 6 right top rear
1272 // + + + 7 right top front
1273 
1274 // Returns which octant point 'pnt' is closet to. This will always return
1275 // a valid octant (0-7) since the point doesn't have to be in an octant.
1276 // If model_orient and/or model_pos are NULL, pnt is assumed to already
1277 // be rotated into the model's local coordinates.
1278 // If oct is not null, it will be filled in with a pointer to the octant
1279 // data.
1280 int model_which_octant_distant(vec3d *pnt, int model_num,matrix *model_orient, vec3d * model_pos, model_octant **oct);
1281 
1282 // Returns which octant point 'pnt' is in. This might return
1283 // -1 if the point isn't in any octant.
1284 // If model_orient and/or model_pos are NULL, pnt is assumed to already
1285 // be rotated into the model's local coordinates.
1286 // If oct is not null, it will be filled in with a pointer to the octant
1287 // data. Or NULL if the pnt isn't in the octant.
1288 int model_which_octant(vec3d *pnt, int model_num,matrix *model_orient, vec3d * model_pos, model_octant **oct);
1289 
1290 typedef struct mst_info {
1296 
1297  bool use_ab;
1298  float glow_noise;
1301 
1309 
1310  mst_info() : primary_bitmap(-1), primary_glow_bitmap(-1), secondary_glow_bitmap(-1), tertiary_glow_bitmap(-1), distortion_bitmap(-1),
1311  use_ab(false), glow_noise(1.0f), rotvel(vmd_zero_vector), length(vmd_zero_vector), glow_rad_factor(1.0f),
1312  secondary_glow_rad_factor(1.0f), tertiary_glow_rad_factor(1.0f), glow_length_factor(1.0f), distortion_rad_factor(1.0f), distortion_length_factor(1.0f),
1313  draw_distortion(true)
1314  {}
1315 } mst_info;
1316 
1317 // scale the engines thrusters by this much
1318 // Only enabled if MR_SHOW_THRUSTERS is on
1319 void model_set_thrust(int model_num = -1, mst_info *mst = NULL);
1320 
1321 
1322 //=======================================================================================
1323 // Finds the closest point on a model to a point in space. Actually only finds a point
1324 // on the bounding box of the model.
1325 // Given:
1326 // model_num Which model
1327 // submodel_num Which submodel, -1 for hull
1328 // orient Orientation of the model
1329 // pos Position of the model
1330 // eye_pos Point that you want to find the closest point to
1331 // Returns:
1332 // distance from eye_pos to closest_point. 0 means eye_pos is
1333 // on or inside the bounding box.
1334 // Also fills in outpnt with the actual closest point.
1336 
1337 // set the insignia bitmap to be used when rendering a ship with an insignia (-1 switches it off altogether)
1338 void model_set_insignia_bitmap(int bmap);
1339 
1340 // set model transparency for use with MR_ALL_XPARENT
1341 void model_set_alpha(float alpha);
1342 
1343 // set the forces bitmap
1344 void model_set_forced_texture(int bmap);
1345 
1346 // see if the given texture is used by the passed model. 0 if not used, 1 if used, -1 on error
1347 int model_find_texture(int model_num, int bitmap);
1348 
1349 // find closest point on extended bounding box (the bounding box plus all the planes that make it up)
1350 // returns closest distance to extended box
1351 // positive return value means start_point is outside extended box
1352 // displaces closest point an optional amount delta to the outside of the box
1353 // closest_box_point can be NULL.
1354 float get_world_closest_box_point_with_delta(vec3d *closest_box_point, object *box_obj, vec3d *start_point, int *is_inside, float delta);
1355 
1356 // given a newly loaded model, page in all textures
1357 void model_page_in_textures(int modelnum, int ship_info_index = -1);
1358 
1359 // given a model, unload all of its textures
1360 void model_page_out_textures(int model_num, bool release = false);
1361 
1362 void model_set_warp_globals(float scale_x = 1.0f, float scale_y = 1.0f, float scale_z = 1.0f, int bitmap_id = -1, float alpha = -1.0f);
1363 
1364 void model_set_replacement_textures(int *replacement_textures);
1365 
1366 void model_setup_cloak(vec3d *shift, int full_cloak, int alpha);
1367 void model_finish_cloak(int full_cloak);
1368 
1369 void model_do_look_at(int model_num); //Bobboau
1370 
1372 
1373 int model_should_render_engine_glow(int objnum, int bank_obj);
1374 
1375 void model_interp_set_clip_plane(vec3d* pos = NULL, vec3d* normal = NULL);
1376 
1377 void model_interp_set_animated_effect_and_timer(int effect_num = 0, float effect_timer = 0.0f);
1378 
1379 bool model_get_team_color(team_color *clr, const SCP_string &team, const SCP_string &secondaryteam, fix timestamp, int fadetime);
1380 
1381 void model_interp_set_team_color(const SCP_string &team, const SCP_string &secondaryteam, fix timestamp, int fadetime);
1382 
1383 void moldel_calc_facing_pts( vec3d *top, vec3d *bot, vec3d *fvec, vec3d *pos, float w, float z_add, vec3d *Eyeposition );
1384 
1385 void interp_render_arc(vec3d *v1, vec3d *v2, color *primary, color *secondary, float arc_width);
1386 
1387 void model_render_insignias(polymodel *pm, int detail_level, int bitmap_num);
1388 
1390 
1392 
1393 void model_draw_paths( int model_num, uint flags );
1394 
1396 
1398 
1400 
1401 void glowpoint_init();
1404 
1405 #endif // _MODEL_H
vec3d ** verts
Definition: model.h:587
void mc_info_init(mc_info *mc)
Definition: model.h:1138
void model_update_instance(int model_instance_num, int sub_model_num, submodel_instance_info *sii, int flags)
Definition: modelread.cpp:4796
vec3d max
Definition: model.h:343
int model_which_octant_distant(vec3d *pnt, int model_num, matrix *model_orient, vec3d *model_pos, model_octant **oct)
struct model_path model_path
#define MAX_SLOTS
Definition: model.h:430
bool force_turret_normal
Definition: model.h:393
float submodel_get_radius(int modelnum, int submodelnum)
Definition: modelread.cpp:3123
struct submodel_instance submodel_instance
vec3d render_box_max
Definition: model.h:381
int model_find_2d_bound(int model_num, matrix *orient, vec3d *pos, int *x1, int *y1, int *x2, int *y2)
Definition: modelread.cpp:3301
int model_collide(mc_info *mc_info_obj)
bsp_info * submodel
Definition: model.h:764
int timestamp(int delta_ms)
Definition: timer.cpp:226
float hit_v
Definition: model.h:1127
int n_paths
Definition: model.h:783
float max_turn_rate
Definition: model.h:160
float get_world_closest_box_point_with_delta(vec3d *closest_box_point, object *box_obj, vec3d *start_point, int *is_inside, float delta)
ubyte tmap_num
Definition: model.h:279
int i
Definition: multi_pxo.cpp:466
#define MAX_TFP
Definition: model.h:69
float hit_u
Definition: model.h:1127
int * turret_ids
Definition: model.h:410
#define MAX_SPLIT_PLANE
Definition: model.h:71
int n_textures
Definition: model.h:761
void model_show_damaged(int model_num, int show_damaged)
vec3d render_sphere_offset
Definition: model.h:384
int model_find_bay_path(int modelnum, char *bay_path_name)
Definition: modelread.cpp:5142
vec3d hit_point
Definition: model.h:1123
int rotation_snd
Definition: model.h:204
bsp_collision_leaf * leaf_list
Definition: model.h:288
vec3d turret_norm
Definition: model.h:186
char lod_name[MAX_NAME_LEN]
Definition: model.h:394
#define MAX_SHIP_PRIMARY_BANKS
Definition: globals.h:62
vec3d * pos
Definition: model.h:1113
void model_find_world_point(vec3d *outpnt, vec3d *mpnt, int model_num, int submodel_num, const matrix *objorient, const vec3d *objpos)
Definition: modelread.cpp:4099
int shield_hit_tri
Definition: model.h:1128
vec3d min
Definition: model.h:342
int depart_flags
Definition: model.h:543
int live_debris[MAX_LIVE_DEBRIS]
Definition: model.h:353
float radius[MAX_SLOTS]
Definition: model.h:436
void model_remove_bsp_collision_tree(int tree_index)
Definition: modelread.cpp:5197
float turn_rate
Definition: model.h:210
int nverts
Definition: model.h:567
int bsp_data_size
Definition: model.h:333
bool is_ambient
Definition: model.h:673
vec3d mins
Definition: model.h:746
int n_missiles
Definition: model.h:769
void model_set_instance(int model_num, int sub_model_num, submodel_instance_info *sii, int flags=0)
Definition: modelread.cpp:4726
int collision_tree_index
Definition: model.h:336
polymodel * model_get(int model_num)
Definition: modelread.cpp:3134
submodel_instance_info * sii
Definition: model.h:94
int glow_timestamp
Definition: model.h:462
insignia ins[MAX_MODEL_INSIGNIAS]
Definition: model.h:799
int debris_objects[MAX_DEBRIS_OBJECTS]
Definition: model.h:742
int turret_gun_sobj
Definition: model.h:193
float v
Definition: model.h:561
void model_copy_subsystems(int n_subsystems, model_subsystem *d_sp, model_subsystem *s_sp)
Definition: modelread.cpp:505
void model_clear_submodel_instance(submodel_instance *sm_instance, bsp_info *sm)
Definition: modelread.cpp:4684
GLuint index
Definition: Glext.h:5608
char * model_get_dock_name(int modelnum, int index)
Definition: modelread.cpp:5103
int n_view_positions
Definition: model.h:752
int turret_gun_rotation_snd
Definition: model.h:197
void model_get_rotating_submodel_list(SCP_vector< int > *submodel_vector, object *objp)
Definition: modelread.cpp:4468
int model_get_dock_index_type(int modelnum, int index)
Definition: modelread.cpp:5120
int model_rotate_gun(int model_num, model_subsystem *turret, matrix *orient, angles *base_angles, angles *gun_angles, vec3d *pos, vec3d *dst, int obj_idx, bool reset=false)
Definition: modelread.cpp:3904
int id
Definition: model.h:732
int parent
Definition: model.h:595
float value
Definition: model.h:579
int Num_dock_type_names
Definition: modelread.cpp:122
struct mp_vert mp_vert
void model_set_replacement_textures(int *replacement_textures)
polymodel()
Definition: model.h:702
uint flags2
Definition: model.h:170
int distortion_bitmap
Definition: model.h:1295
#define MAX_MODEL_TEXTURES
Definition: globals.h:78
vec3d max
Definition: model.h:585
int detail[MAX_MODEL_DETAIL_LEVELS]
Definition: model.h:738
float t_pause
Definition: model.h:159
Definition: pstypes.h:88
float detail_depth[MAX_MODEL_DETAIL_LEVELS]
Definition: model.h:739
int parent
Definition: model.h:359
vec3d bounding_box[8]
Definition: model.h:344
vec3d center_of_mass
Definition: model.h:788
w_bank * gun_banks
Definition: model.h:772
vec3d norm
Definition: model.h:597
model_tmap_vert * vert_list
Definition: model.h:291
void model_find_world_dir(vec3d *out_dir, vec3d *in_dir, int model_num, int submodel_num, const matrix *objorient)
Definition: modelread.cpp:4551
int num_arcs
Definition: model.h:369
int modelstats_num_polys
Definition: modelinterp.cpp:45
void find_submodel_instance_point(vec3d *outpnt, int model_instance_num, int submodel_num)
Definition: modelread.cpp:4258
float u[MAX_INS_FACES][MAX_INS_FACE_VECS]
Definition: model.h:613
float turret_max_fov
Definition: model.h:189
Definition: 2d.h:95
struct thruster_bank thruster_bank
int verts[3]
Definition: model.h:552
int subobj_find_2d_bound(float radius, matrix *orient, vec3d *pos, int *x1, int *y1, int *x2, int *y2)
Definition: modelread.cpp:3345
void model_set_outline_color_fast(void *outline_color)
void model_set_alpha(float alpha)
int dead_snd
Definition: model.h:203
CButton * team
vec3d mc_base
Definition: model.h:90
bool attach_thrusters
Definition: model.h:395
void model_collide_preprocess(matrix *orient, int model_instance_num, int detail=0)
#define MAX_INS_FACE_VECS
Definition: model.h:606
float tertiary_glow_rad_factor
Definition: model.h:1304
GLclampf f
Definition: Glext.h:7097
vec3d norm
Definition: model.h:441
vec3d * point_list
Definition: model.h:292
int model_find_2d_bound_min(int model_num, matrix *orient, vec3d *pos, int *x1, int *y1, int *x2, int *y2)
Definition: modelread.cpp:3168
int * splines
Definition: model.h:528
stepped_rotation_t * stepped_rotation
Definition: model.h:212
int n_glow_point_banks
Definition: model.h:810
float model_get_core_radius(int modelnum)
Definition: modelread.cpp:3114
GLenum GLuint texture
Definition: Glext.h:5872
int model_which_octant(vec3d *pnt, int model_num, matrix *model_orient, vec3d *model_pos, model_octant **oct)
int lod
Definition: model.h:1118
int glow_bitmap
Definition: model.h:471
void model_add_arc(int model_num, int sub_model_num, vec3d *v1, vec3d *v2, int arc_type)
Definition: modelread.cpp:5003
shield_tri ** shield_tris
Definition: model.h:589
vec3d maxs
Definition: model.h:746
bsp_collision_tree * model_get_bsp_collision_tree(int tree_index)
Definition: modelread.cpp:5189
matrix mc_orient
Definition: model.h:91
char look_at[MAX_NAME_LEN]
Definition: model.h:399
void submodel_stepped_rotate(model_subsystem *psub, submodel_instance_info *sii)
Definition: modelread.cpp:3474
void model_load_texture(polymodel *pm, int i, char *file)
Definition: modelread.cpp:2412
int turret_reset_delay
Definition: model.h:227
int type
Definition: model.h:421
Definition: model.h:432
shield_vertex * verts
Definition: model.h:569
float u
Definition: model.h:561
mst_info()
Definition: model.h:1310
#define MAX_SHIP_BAY_PATHS
Definition: model.h:538
int model_get_num_dock_points(int modelnum)
Definition: modelread.cpp:5112
int used_this_mission
Definition: model.h:808
hull_check orient
Definition: lua.cpp:5049
flag_def_list Dock_type_names[]
Definition: modelread.cpp:115
std::basic_string< char, std::char_traits< char >, std::allocator< char > > SCP_string
Definition: vmallocator.h:21
void find_submodel_instance_point_normal(vec3d *outpnt, vec3d *outnorm, int model_instance_num, int submodel_num, const vec3d *submodel_pnt, const vec3d *submodel_norm)
Definition: modelread.cpp:4302
object * objp
Definition: lua.cpp:3105
int parent_submodel
Definition: model.h:417
float hit_dist
Definition: model.h:1122
GLfloat GLfloat GLfloat v2
Definition: Glext.h:5640
int details[MAX_MODEL_DETAIL_LEVELS]
Definition: model.h:365
struct stepped_rotation stepped_rotation_t
bsp_collision_leaf * bsp_leaf
Definition: model.h:1133
struct polymodel_instance polymodel_instance
ship_bay_t * ship_bay
Definition: model.h:776
struct shield_vertex shield_vertex
Definition: model.h:594
int turret_base_rotation_snd
Definition: model.h:195
int n_thrusters
Definition: model.h:771
#define MAX_EYES
Definition: model.h:592
vec3d * p0
Definition: model.h:1114
hull_check submodel_num
Definition: lua.cpp:5048
void model_draw_paths_htl(int model_num, uint flags)
void model_render_insignias(polymodel *pm, int detail_level, int bitmap_num)
vec3d turret_firing_point[MAX_TFP]
Definition: model.h:192
vertex_buffer buffer
Definition: model.h:374
float gun_submodel_rotation
Definition: model.h:813
thruster_bank * thrusters
Definition: model.h:775
#define TM_NUM_TYPES
Definition: model.h:663
float turret_base_rotation_snd_mult
Definition: model.h:196
vec3d pnt[MAX_SLOTS]
Definition: model.h:434
int subobj_num
Definition: model.h:175
int model_num
Definition: model.h:1110
dock_bay * docking_bays
Definition: model.h:774
int num_lights
Definition: model.h:749
int primary_banks[MAX_SHIP_PRIMARY_BANKS]
Definition: model.h:218
float mass
Definition: model.h:787
int neighbors[3]
Definition: model.h:553
struct glow_point_bank_override glow_point_bank_override
void submodel_render_DEPRECATED(int model_num, int submodel_num, matrix *orient, vec3d *pos, uint flags=MR_DEPRECATED_NORMAL, int objnum=-1, int *replacement_textures=NULL, int render=MODEL_RENDER_ALL)
char * debug_info
Definition: model.h:805
int turret_max_bomb_ownage
Definition: model.h:239
int submodel_get_num_verts(int model_num, int submodel_num)
void model_init()
Definition: modelread.cpp:409
struct dock_bay dock_bay
void parse_triggersint(int &n_trig, queued_animation **triggers, char *props)
int model_create_bsp_collision_tree()
Definition: modelread.cpp:5162
matrix turret_matrix
Definition: model.h:187
bool no_collisions
Definition: model.h:390
vec3d pnt
Definition: model.h:596
int i_replace
Definition: model.h:348
int sldc_size
Definition: model.h:780
void world_find_model_point(vec3d *out, vec3d *world_pt, const polymodel *pm, int submodel_num, const matrix *orient, const vec3d *pos)
Definition: modelread.cpp:4182
void model_make_turret_matrix(int model_num, model_subsystem *turret)
Definition: modelread.cpp:3846
void model_find_submodel_offset(vec3d *outpnt, int model_num, int sub_model_num)
Definition: modelread.cpp:4041
char alt_dmg_sub_name[NAME_LENGTH]
Definition: model.h:174
vec3d pos
Definition: model.h:577
ushort vertnum
Definition: model.h:258
#define MAX_SHIP_SECONDARY_BANKS
Definition: globals.h:63
void model_instance_find_world_point(vec3d *outpnt, vec3d *mpnt, int model_instance_num, int submodel_num, const matrix *objorient, const vec3d *objpos)
Definition: modelread.cpp:4135
void model_instance_free_all()
Definition: modelread.cpp:355
void model_draw_paths(int model_num, uint flags)
int edge_hit
Definition: model.h:1130
SCP_vector< glow_point_bank_override > glowpoint_bank_overrides
Definition: modelread.cpp:124
void model_interp_set_team_color(const SCP_string &team, const SCP_string &secondaryteam, fix timestamp, int fadetime)
GLintptr offset
Definition: Glext.h:5497
float core_radius
Definition: model.h:758
int model_find_dock_index(int modelnum, int dock_type, int index_to_start_at=0)
Definition: modelread.cpp:5031
void find_submodel_instance_point_orient(vec3d *outpnt, matrix *outorient, int model_instance_num, int submodel_num, const vec3d *submodel_pnt, const matrix *submodel_orient)
Definition: modelread.cpp:4370
void model_delete_instance(int model_instance_num)
Definition: modelread.cpp:2907
GLdouble GLdouble GLdouble r
Definition: Glext.h:5337
vec3d autocenter
Definition: model.h:755
int num_live_debris
Definition: model.h:352
void model_draw_bay_paths(int model_num)
int flags
Definition: model.h:1116
int LoadTexture(char *filename, char *dbg_name)
unsigned int uint
Definition: pstypes.h:64
bsp_info * sm
Definition: lua.cpp:7079
GLboolean GLboolean g
Definition: Glext.h:5781
uint flags
Definition: model.h:169
void model_set_forced_texture(int bmap)
GLenum GLenum dst
Definition: Glext.h:5917
bool use_ab
Definition: model.h:1297
int look_at_num
Definition: model.h:398
float glow_noise
Definition: model.h:1298
void model_find_obj_dir(vec3d *w_vec, vec3d *m_vec, int model_instance_num, int submodel_num, matrix *objorient)
Definition: modelread.cpp:3383
bool collide_invisible
Definition: model.h:392
void PageOut(bool release)
struct model_special * next
Definition: model.h:244
float turret_y_fov
Definition: model.h:190
int off_time
Definition: model.h:464
vec3d * p1
Definition: model.h:1115
int num_paths
Definition: model.h:540
int model_find_texture(int model_num, int bitmap)
void model_clear_instance(int model_num)
Definition: modelread.cpp:4624
struct engine_wash_info * engine_wash_pointer
Definition: model.h:207
void PageOut(bool release)
char * filename
vec3d rotvel
Definition: model.h:1299
int num_points
Definition: model.h:446
int is_damaged
Definition: model.h:356
void moldel_calc_facing_pts(vec3d *top, vec3d *bot, vec3d *fvec, vec3d *pos, float w, float z_add, vec3d *Eyeposition)
texture_map maps[MAX_MODEL_TEXTURES]
Definition: model.h:762
int used
Definition: model.h:551
int submodel_get_points(int model_num, int submodel_num, int max_num, vec3d **nts)
bool use_render_box_offset
Definition: model.h:386
ubyte num_verts
Definition: model.h:278
int FindTexture(int bm_handle)
int secondary_banks[MAX_SHIP_SECONDARY_BANKS]
Definition: model.h:220
int debug_info_size
Definition: model.h:804
struct mst_info mst_info
void world_find_model_instance_point(vec3d *out, vec3d *world_pt, const polymodel_instance *pmi, int submodel_num, const matrix *orient, const vec3d *pos)
Definition: modelread.cpp:4215
void model_draw_bay_paths_htl(int model_num)
int n_docks
Definition: model.h:770
float t_transit
Definition: model.h:158
submodel_instance * submodel
Definition: model.h:100
struct cross_section cross_section
struct shield_info shield_info
int glow_neb_bitmap
Definition: model.h:472
vertex_buffer detail_buffers[MAX_MODEL_DETAIL_LEVELS]
Definition: model.h:817
float z
Definition: model.h:601
bool can_move
Definition: model.h:328
vertex_buffer trans_buffer
Definition: model.h:375
float favor_current_facing
Definition: model.h:234
int use_render_box
Definition: model.h:385
float distortion_length_factor
Definition: model.h:1307
int model_num
Definition: model.h:176
int submodel_num
Definition: model.h:452
int num_details
Definition: model.h:364
shield_info shield
Definition: model.h:778
uint flags
Definition: model.h:736
int hit_submodel
Definition: model.h:1125
vec3d norm[MAX_DOCK_SLOTS]
Definition: model.h:531
bool draw_distortion
Definition: model.h:1308
queued_animation * triggers
Definition: model.h:225
int secondary_bank_capacity[MAX_SHIP_SECONDARY_BANKS]
Definition: model.h:221
Definition: bmpman.h:101
int is_live_debris
Definition: model.h:351
int nverts
Definition: model.h:418
struct model_special model_special
int primary_glow_bitmap
Definition: model.h:1292
vec3d norm[MAX_INS_VECS]
Definition: model.h:617
bool use_render_sphere_offset
Definition: model.h:388
vec3d offset
Definition: model.h:330
int num_children
Definition: model.h:360
void model_do_intrinsic_rotations(int model_instance_num=-1)
Definition: modelread.cpp:4878
Definition: model.h:407
void model_init_submodel_axis_pt(submodel_instance_info *sii, int model_num, int submodel_num)
Definition: modelread.cpp:4936
GLenum GLuint id
Definition: Glext.h:5156
int model_load(char *filename, int n_subsystems, model_subsystem *subsystems, int ferror=1, int duplicate=0)
Definition: modelread.cpp:2573
vec3d eye_pos
Definition: fredrender.cpp:103
ushort normnum
Definition: model.h:259
float max_subsys_strength
Definition: model.h:180
int num_slots
Definition: model.h:433
SCP_vector< vec3d > shield_points
Definition: model.h:781
float radius
Definition: model.h:1117
void submodel_rotate(model_subsystem *psub, submodel_instance_info *sii)
Definition: modelread.cpp:3688
const GLuint * textures
Definition: Glext.h:7569
void model_page_in_textures(int modelnum, int ship_info_index=-1)
#define delta
Definition: fvi.cpp:418
int turret_num_firing_points
Definition: model.h:191
void model_set_insignia_bitmap(int bmap)
vec3d norm[MAX_SLOTS]
Definition: model.h:435
int type_flags
Definition: model.h:526
int nshield_tris
Definition: model.h:588
void model_instance_find_obj_dir(vec3d *w_vec, vec3d *m_vec, int model_instance_num, int submodel_num, matrix *objorient)
Definition: modelread.cpp:3416
void model_draw_debug_points(polymodel *pm, bsp_info *submodel, uint flags)
char crewspot[MAX_NAME_LEN]
Definition: model.h:185
int n_triggers
Definition: model.h:224
float turret_gun_rotation_snd_mult
Definition: model.h:198
ubyte * shield_collision_tree
Definition: model.h:779
char * Subsystem_types[SUBSYSTEM_MAX]
Definition: modelread.cpp:95
int num_target_priorities
Definition: model.h:231
int primary_bank_capacity[MAX_SHIP_PRIMARY_BANKS]
Definition: model.h:219
#define MODEL_RENDER_ALL
Definition: model.h:935
char alt_sub_name[NAME_LENGTH]
Definition: model.h:173
float awacs_radius
Definition: model.h:216
int num_ins
Definition: model.h:800
long fix
Definition: pstypes.h:54
void submodel_get_two_random_points(int model_num, int submodel_num, vec3d *v1, vec3d *v2, vec3d *n1=NULL, vec3d *n2=NULL)
GLclampd n
Definition: Glext.h:7286
unsigned char ubyte
Definition: pstypes.h:62
vec3d geometric_center
Definition: model.h:338
Definition: object.h:141
int nverts
Definition: model.h:586
int model_get_dock_types(int modelnum)
Definition: modelread.cpp:5128
float face_rad
Definition: model.h:276
angles angs
Definition: model.h:349
#define MAX_DOCK_SLOTS
Definition: model.h:522
float radius
Definition: model.h:442
vec3d hit_point_world
Definition: model.h:1124
int my_replacement
Definition: model.h:347
int version
Definition: model.h:733
int goal
Definition: model.h:420
int tertiary_glow_bitmap
Definition: model.h:1294
float radius
Definition: model.h:411
vec3d pos
Definition: model.h:560
float glow_length_factor
Definition: model.h:1305
bsp_light * lights
Definition: model.h:750
float rad
Definition: model.h:340
GLfloat GLfloat v1
Definition: Glext.h:5639
void model_page_out_textures(int model_num, bool release=false)
float glow_rad_factor
Definition: model.h:1302
float turret_rof_scaler
Definition: model.h:236
int blown_off
Definition: model.h:346
GLbitfield flags
Definition: Glext.h:6722
Definition: 2d.h:109
bool nocollide_this_only
Definition: model.h:391
int faces[MAX_INS_FACES][MAX_INS_FACE_VECS]
Definition: model.h:612
int SetTexture(int n_tex)
struct ship_bay ship_bay_t
GLuint const GLchar * name
Definition: Glext.h:5608
int disp_time
Definition: model.h:465
#define MAX_DEBRIS_OBJECTS
Definition: model.h:26
int alive_snd
Definition: model.h:202
int GetOriginalTexture()
cross_section * xc
Definition: model.h:794
float radius
Definition: model.h:179
int primary_bitmap
Definition: model.h:1291
int value
Definition: model.h:422
int type
Definition: model.h:578
#define MAX_ARC_EFFECTS
Definition: model.h:30
ubyte arc_type[MAX_ARC_EFFECTS]
Definition: model.h:371
int hit_bitmap
Definition: model.h:1126
GLboolean GLboolean GLboolean b
Definition: Glext.h:5781
int num_hits
Definition: model.h:1121
int model_find_dock_name_index(int modelnum, char *name)
Definition: modelread.cpp:5055
int weapon_rotation_pbank
Definition: model.h:211
void model_instance_find_world_dir(vec3d *out_dir, vec3d *in_dir, int model_instance_num, int submodel_num, const matrix *objorient)
Definition: modelread.cpp:4587
float turret_turning_rate
Definition: model.h:194
int submodel_get_num_polys(int model_num, int submodel_num)
#define MAX_MODEL_INSIGNIAS
Definition: model.h:605
int detail_level
Definition: model.h:610
int modelstats_num_polys_drawn
Definition: modelinterp.cpp:46
int movement_axis
Definition: model.h:327
char parent_name[MAX_NAME_LEN]
Definition: model.h:416
#define MR_DEPRECATED_NORMAL
Definition: model.h:892
void model_free_all()
Definition: modelread.cpp:337
vec3d pnt
Definition: model.h:178
polymodel_instance * model_get_instance(int model_instance_num)
Definition: modelread.cpp:3154
float turret_fov
Definition: model.h:188
void model_set_outline_color(int r, int g, int b)
int turret_max_target_ownage
Definition: model.h:240
glow_point_bank * glow_point_banks
Definition: model.h:811
ubyte * bsp_data
Definition: model.h:334
void model_render_DEPRECATED(int model_num, matrix *orient, vec3d *pos, uint flags=MR_DEPRECATED_NORMAL, int objnum=-1, int lighting_skip=-1, int *replacement_textures=NULL, int render=MODEL_RENDER_ALL, const bool is_skybox=false)
float desired_turn_rate
Definition: model.h:81
#define NAME_LENGTH
Definition: globals.h:15
int model_render_flags_size
Definition: modelread.cpp:50
int num_debris_objects
Definition: model.h:741
GLubyte GLubyte GLubyte GLubyte w
Definition: Glext.h:5679
struct shield_tri shield_tri
struct model_octant model_octant
float rad
Definition: model.h:757
bool collision_checked
Definition: model.h:92
int n_models
Definition: model.h:744
#define MAX_INS_VECS
Definition: model.h:607
struct mc_info mc_info
vec3d render_box_offset
Definition: model.h:382
#define FILESPEC_LENGTH
Definition: globals.h:22
void submodel_get_two_random_points_better(int model_num, int submodel_num, vec3d *v1, vec3d *v2)
void model_do_look_at(int model_num)
Definition: modelread.cpp:4927
int submodel
Definition: lua.cpp:5007
bool is_transparent
Definition: model.h:674
vec3d norm
Definition: model.h:554
struct model_tmap_vert model_tmap_vert
int obj_num
Definition: model.h:451
int model_should_render_engine_glow(int objnum, int bank_obj)
int num_xc
Definition: model.h:793
glow_point * points
Definition: model.h:447
void model_set_instance_info(submodel_instance_info *sii, float turn_rate, float turn_accel)
Definition: modelread.cpp:4708
unsigned short ushort
Definition: pstypes.h:63
char subobj_name[MAX_NAME_LEN]
Definition: model.h:172
vertex * outline_buffer
Definition: model.h:377
int next_sibling
Definition: model.h:362
float model_get_radius(int modelnum)
Definition: modelread.cpp:3105
int num_split_plane
Definition: model.h:796
void model_render_shields(polymodel *pm, uint flags)
float render_sphere_radius
Definition: model.h:383
bool blown_off
Definition: model.h:93
struct insignia insignia
bsp_info()
Definition: model.h:301
vec3d length
Definition: model.h:1300
int submodel_find_2d_bound_min(int model_num, int submodel, matrix *orient, vec3d *pos, int *x1, int *y1, int *x2, int *y2)
Definition: modelread.cpp:3232
char out_dir[MAX_PATH]
matrix moment_of_inertia
Definition: model.h:789
struct w_bank w_bank
void model_set_thrust(int model_num=-1, mst_info *mst=NULL)
ubyte * t_poly
Definition: model.h:1132
#define MAX_MODEL_DETAIL_LEVELS
Definition: model.h:27
uint n_verts_outline
Definition: model.h:378
int num_faces
Definition: model.h:611
void model_interp_set_animated_effect_and_timer(int effect_num=0, float effect_timer=0.0f)
float radius
Definition: model.h:602
int is_thruster
Definition: model.h:355
hull_check pos
Definition: lua.cpp:5050
int bank
Definition: model.h:245
int secondary_glow_bitmap
Definition: model.h:1293
#define MAX_LIVE_DEBRIS
Definition: model.h:255
int arrive_flags
Definition: model.h:542
int model_instance_num
Definition: model.h:1109
int n_guns
Definition: model.h:768
vec3d pos
Definition: model.h:408
int num_spline_paths
Definition: model.h:527
glow_point * points
Definition: model.h:470
vec3d arc_pts[MAX_ARC_EFFECTS][2]
Definition: model.h:370
ubyte * f_poly
Definition: model.h:1131
texture_map()
Definition: model.h:685
void model_clear_submodel_instances(int model_instance_num)
Definition: modelread.cpp:4696
float dumb_turn_rate
Definition: model.h:396
void model_interp_set_clip_plane(vec3d *pos=NULL, vec3d *normal=NULL)
mp_vert * verts
Definition: model.h:419
bsp_collision_node * node_list
Definition: model.h:285
int modelstats_num_verts
Definition: modelinterp.cpp:47
float secondary_glow_rad_factor
Definition: model.h:1303
eye view_positions[MAX_EYES]
Definition: model.h:753
int path_num
Definition: model.h:222
int num_points
Definition: model.h:469
struct glow_point_bank glow_point_bank
float split_plane[MAX_SPLIT_PLANE]
Definition: model.h:797
void interp_render_arc(vec3d *v1, vec3d *v2, color *primary, color *secondary, float arc_width)
int nturrets
Definition: model.h:409
polymodel * pm
Definition: lua.cpp:1598
vec3d hit_normal
Definition: model.h:1129
void model_clear_instance_info(submodel_instance_info *sii)
Definition: modelread.cpp:4669
struct engine_wash_info * wash_info_pointer
Definition: model.h:450
w_bank * missile_banks
Definition: model.h:773
int vertex_buffer_id
Definition: model.h:815
struct submodel_instance_info submodel_instance_info
model_octant octants[8]
Definition: model.h:791
void model_setup_cloak(vec3d *shift, int full_cloak, int alpha)
float awacs_intensity
Definition: model.h:215
bool is_on
Definition: model.h:466
matrix orientation
Definition: model.h:331
void model_set_warp_globals(float scale_x=1.0f, float scale_y=1.0f, float scale_z=1.0f, int bitmap_id=-1, float alpha=-1.0f)
GLboolean reset
Definition: Glext.h:5243
void model_set_instance_techroom(int model_num, int sub_model_num, float angle_1, float angle_2)
Definition: modelread.cpp:4772
false
Definition: lua.cpp:6789
model_path * paths
Definition: model.h:784
float optimum_range
Definition: model.h:233
#define SUBSYSTEM_MAX
Definition: model.h:64
int model_create_instance(bool is_ship, int model_num)
Definition: modelread.cpp:2855
struct eye eye
flag_def_list model_render_flags[]
Definition: modelread.cpp:40
vec3d pnt
Definition: model.h:440
int model_num
Definition: lua.cpp:4996
GLclampf GLclampf GLclampf alpha
Definition: Glext.h:5177
struct model_special * prev
Definition: model.h:244
int model_instance_num
Definition: lua.cpp:4996
int submodel_num
Definition: model.h:1111
void find_submodel_instance_world_point(vec3d *outpnt, int model_instance_num, int submodel_num, const matrix *objorient, const vec3d *objpos)
Definition: modelread.cpp:4431
vec3d pnt
Definition: model.h:247
int ram_used
Definition: model.h:803
vec3d render_box_min
Definition: model.h:380
angles angs
Definition: model.h:88
int target_priority[32]
Definition: model.h:230
vec3d vmd_zero_vector
Definition: vecmat.cpp:24
void ResetToOriginal()
float distortion_rad_factor
Definition: model.h:1306
GLdouble GLdouble GLdouble GLdouble top
Definition: Glext.h:10330
int movement_type
Definition: model.h:326
bool gun_rotation
Definition: model.h:389
char filename[FILESPEC_LENGTH]
Definition: model.h:734
vec3d bounding_box[8]
Definition: model.h:747
#define MAX_NAME_LEN
Definition: model.h:29
float fraction
Definition: model.h:157
vec3d pnt[MAX_DOCK_SLOTS]
Definition: model.h:530
struct bsp_light bsp_light
matrix * orient
Definition: model.h:1112
SCP_vector< glow_point_bank_override >::iterator get_glowpoint_bank_override_by_name(const char *name)
Definition: modelread.cpp:5550
const GLdouble * v
Definition: Glext.h:5322
#define MAX_INS_FACES
Definition: model.h:608
float max_turn_accel
Definition: model.h:161
shield_tri * tris
Definition: model.h:570
matrix vmd_identity_matrix
Definition: vecmat.cpp:28
int ntris
Definition: model.h:568
int armor_type_idx
Definition: model.h:181
vec3d vecs[MAX_INS_VECS]
Definition: model.h:615
int submodel_parent
Definition: model.h:467
float model_find_closest_point(vec3d *outpnt, int model_num, int submodel_num, matrix *orient, vec3d *pos, vec3d *eye_pos)
bool model_get_team_color(team_color *clr, const SCP_string &team, const SCP_string &secondaryteam, fix timestamp, int fadetime)
int modelstats_num_sortnorms
Definition: modelinterp.cpp:48
vec3d norm
Definition: model.h:248
vec3d offset
Definition: model.h:616
angles prev_angs
Definition: model.h:89
void model_set_detail_level(int n)
int slot
Definition: model.h:246
int first_child
Definition: model.h:361
int n_detail_levels
Definition: model.h:737
float GetTotalTime()
struct model_subsystem model_subsystem
int use_render_sphere
Definition: model.h:387
void glowpoint_init()
Definition: modelread.cpp:5779
void model_unload(int modelnum, int force=0)
Definition: modelread.cpp:162
int num_slots
Definition: model.h:525
int path_indexes[MAX_SHIP_BAY_PATHS]
Definition: model.h:541
vec3d plane_norm
Definition: model.h:275
vec3d min
Definition: model.h:585
void model_get_submodel_tree_list(SCP_vector< int > &submodel_vector, polymodel *pm, int mn)
Definition: modelread.cpp:4533
void model_finish_cloak(int full_cloak)
vec3d plane_pnt
Definition: model.h:274
void model_collide_parse_bsp(bsp_collision_tree *tree, void *model_ptr, int version)