FS2_Open
Open source remastering of the Freespace 2 engine
modelanim.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 _MODELANIM_H
13 #define _MODELANIM_H
14 
15 #include <limits.h>
16 
17 #define MAX_TRIGGERED_ANIMATIONS 15
18 
19 // WMC: Steps to adding a triggered animation
20 // 1 - add TRIGGER_TYPE_* define
21 // 2 - increment MAX_TRIGGER_ANIMATION_TYPES
22 // 3 - add name to animation_type_names array
23 // 4 - add start trigger (model_anim_start_type)
24 // 5 - add stop trigger (model_anim_start_type)
25 
26 #define TRIGGER_TYPE_NONE -1 // No animation
27 #define TRIGGER_TYPE_INITIAL 0 // This is just the position the subobject should be placed in
28 #define TRIGGER_TYPE_DOCKING_STAGE_1 1 // Before you dock
29 #define TRIGGER_TYPE_DOCKING_STAGE_2 2 // Before you dock
30 #define TRIGGER_TYPE_DOCKING_STAGE_3 3 // Before you dock
31 #define TRIGGER_TYPE_DOCKED 4 // As you dock
32 #define TRIGGER_TYPE_PRIMARY_BANK 5 // Primary banks
33 #define TRIGGER_TYPE_SECONDARY_BANK 6 // Secondary banks
34 #define TRIGGER_TYPE_DOCK_BAY_DOOR 7 // Fighter bays
35 #define TRIGGER_TYPE_AFTERBURNER 8 // Afterburner -C
36 #define TRIGGER_TYPE_TURRET_FIRING 9 // Turret shooting -C
37 #define TRIGGER_TYPE_SCRIPTED 10 // Triggered exclusively by scripting...maybe SEXPs? -C
38 #define TRIGGER_TYPE_TURRET_FIRED 11 // Triggered after a turret has fired -The E
39 
40 #define MAX_TRIGGER_ANIMATION_TYPES 12
41 
43 
44 
45 // Model Animation Position settings
47  MA_POS_NOT_SET = 0, // not yet setup
48  MA_POS_SET = 1, // set, but is moving
49  MA_POS_READY = 2 // set, done with move
50 };
51 
52 #define ANIMATION_SUBTYPE_ALL INT_MAX
53 
62  int start;
64  int end;
65  int end_time;
67  bool absolute;
68  int type;
69  int subtype;
70  int instance;
72 
75  int end_sound;
76  float snd_rad;
77 
79 };
82 
83 /*
84 struct trigger_instance{
85  int type;
86  int sub_type;
87  queued_animation properties;
88  void corect();
89 };
90 */
91 
97 {
98  private:
99  int start_sound;
100  int loop_sound;
101  int end_sound;
102  int current_snd;
103  int current_snd_index;
104  float snd_rad;
105  int obj_num;
106 
107  int n_queue;
110 
111  public:
114  void clear();
115 
116  void start(queued_animation *q);
119  void apply_trigger_angles(angles *submodel_angles);
120 
121  void add_queue(queued_animation *new_queue, int dir);
122  void process_queue();
123 
126  vec3d rot_accel; // rotational acceleration, 0 means instant
127  vec3d rot_vel; // radians per second, hold this speed when rot_accel has pushed it to this
128  vec3d slow_angle; // angle that we should start to slow down
129  vec3d end_angle; // lock it in
131 
132  int instance; // which animation this is (for reversals)
133  bool has_started; // animation has started playing
134  int end_time; // time that we should stop
135  int start_time; // the time the current animation started
136 };
137 
139 
140 // functions...
141 
142 struct model_subsystem;
143 class ship_subsys;
144 class ship;
145 class ship_info;
146 
150 
151 // gets animation type index from string name
152 int model_anim_match_type(char *p);
153 
154 // starts an animation of a certan type that may be assosiated with a submodel of a ship (returns true if an animation was started)
155 bool model_anim_start_type(ship_subsys *pss, int animation_type, int subtype, int direction, bool instant = false); // for a specific subsystem
156 bool model_anim_start_type(ship *shipp, int animation_type, int subtype, int direction, bool instant = false); // for all valid subsystems
157 
158 // how long until the animation is done
159 int model_anim_get_time_type(ship_subsys *pss, int animation_type, int subtype); // for a specific subsystem
160 int model_anim_get_time_type(ship *shipp, int animation_type, int subtype); // for all valid subsystems
161 
162 // this is for handling multiplayer-safe, client-side, animations
164 
165 
166 // for pushing and popping animations
167 typedef struct stack_item
168 {
171  int subtype;
173  bool instant;
174 } stack_item;
175 
177 
179 
180 bool model_anim_push_and_start_type(int stack_unique_id, ship *shipp, int animation_type, int subtype, int direction, bool instant = false);
181 bool model_anim_pop_and_start_type(int stack_unique_id);
182 
183 #endif // _MODELANIM_H
bool model_anim_pop_and_start_type(int stack_unique_id)
Definition: modelanim.cpp:928
void model_anim_submodel_trigger_rotate(model_subsystem *psub, ship_subsys *ss)
Definition: modelanim.cpp:403
void apply_trigger_angles(angles *submodel_angles)
Definition: modelanim.cpp:133
void model_anim_handle_multiplayer(ship *shipp)
Definition: modelanim.cpp:863
void set_to_final(queued_animation *q)
Definition: modelanim.cpp:164
Definition: pstypes.h:88
#define MAX_TRIGGER_ANIMATION_TYPES
Definition: modelanim.h:40
void model_anim_fix_reverse_times(ship_info *sip)
Definition: modelanim.cpp:705
int model_anim_get_time_type(ship_subsys *pss, int animation_type, int subtype)
Definition: modelanim.cpp:740
struct stack_item stack_item
bool model_anim_start_type(ship_subsys *pss, int animation_type, int subtype, int direction, bool instant=false)
Definition: modelanim.cpp:566
ship * shipp
Definition: lua.cpp:9162
int subtype
Definition: modelanim.h:171
bool instant
Definition: modelanim.h:173
SCP_vector< stack_item > animation_stack
Definition: modelanim.h:176
bool model_anim_push_and_start_type(int stack_unique_id, ship *shipp, int animation_type, int subtype, int direction, bool instant=false)
Definition: modelanim.cpp:914
int subtype
Definition: lua.cpp:9763
#define MAX_TRIGGERED_ANIMATIONS
Definition: modelanim.h:17
void set_to_initial(queued_animation *q)
Definition: modelanim.cpp:156
int model_anim_match_type(char *p)
Definition: modelanim.cpp:38
Definition: ship.h:534
char * Animation_type_names[MAX_TRIGGER_ANIMATION_TYPES]
Definition: modelanim.cpp:22
SCP_map< int, animation_stack > Animation_map
Definition: modelanim.cpp:912
GLdouble GLdouble GLdouble GLdouble q
Definition: Glext.h:5345
void queued_animation_init(queued_animation *qa)
Definition: modelanim.cpp:350
#define NAME_LENGTH
Definition: globals.h:15
int direction
Definition: modelanim.h:172
void queued_animation_correct(queued_animation *qa)
Definition: modelanim.cpp:372
ship * shipp
Definition: modelanim.h:169
GLfloat GLfloat p
Definition: Glext.h:8373
void add_queue(queued_animation *new_queue, int dir)
Definition: modelanim.cpp:210
int animation_type
Definition: modelanim.h:170
void model_anim_set_initial_states(ship *shipp)
Definition: modelanim.cpp:823
SCP_vector< triggered_rotation > Triggered_rotations
Definition: modelanim.cpp:20
void start(queued_animation *q)
Definition: modelanim.cpp:94
EModelAnimationPosition
Definition: modelanim.h:46
char sub_name[NAME_LENGTH]
Definition: modelanim.h:78