2 // animation.hxx - classes to manage model animation.
3 // Written by David Megginson, started 2002.
5 // This file is in the Public Domain, and comes with no warranty.
7 #ifndef _SG_ANIMATION_HXX
8 #define _SG_ANIMATION_HXX 1
11 # error This library requires C++
21 #include <simgear/math/point3d.hxx>
22 #include <simgear/props/props.hxx>
25 // Don't pull in the headers, since we don't need them here.
30 // Has anyone done anything *really* stupid, like making min and max macros?
40 //////////////////////////////////////////////////////////////////////
42 //////////////////////////////////////////////////////////////////////
45 * Abstract base class for all animations.
47 class SGAnimation : public ssgBase
51 SGAnimation (SGPropertyNode_ptr props, ssgBranch * branch);
53 virtual ~SGAnimation ();
56 * Get the SSG branch holding the animation.
58 virtual ssgBranch * getBranch () { return _branch; }
61 * Initialize the animation, after children have been added.
66 * Update the animation.
68 virtual void update();
71 * Set the value of sim_time_sec. This needs to be called every
72 * frame in order for the time based animations to work correctly.
74 static void set_sim_time_sec( double val ) { sim_time_sec = val; }
78 static double sim_time_sec;
88 class SGNullAnimation : public SGAnimation
91 SGNullAnimation (SGPropertyNode_ptr props);
92 virtual ~SGNullAnimation ();
97 * A range, or level-of-detail (LOD) animation.
99 class SGRangeAnimation : public SGAnimation
102 SGRangeAnimation (SGPropertyNode_ptr props);
103 virtual ~SGRangeAnimation ();
108 * Animation to turn and face the screen.
110 class SGBillboardAnimation : public SGAnimation
113 SGBillboardAnimation (SGPropertyNode_ptr props);
114 virtual ~SGBillboardAnimation ();
119 * Animation to select alternative versions of the same object.
121 class SGSelectAnimation : public SGAnimation
124 SGSelectAnimation( SGPropertyNode *prop_root,
125 SGPropertyNode_ptr props );
126 virtual ~SGSelectAnimation ();
127 virtual void update();
129 SGCondition * _condition;
134 * Animation to spin an object around a center point.
136 * This animation rotates at a specific velocity.
138 class SGSpinAnimation : public SGAnimation
141 SGSpinAnimation( SGPropertyNode *prop_root,
142 SGPropertyNode_ptr props,
143 double sim_time_sec );
144 virtual ~SGSpinAnimation ();
145 virtual void update();
147 SGPropertyNode_ptr _prop;
149 double _position_deg;
150 double _last_time_sec;
158 * Animation to draw objects for a specific amount of time each.
160 class SGTimedAnimation : public SGAnimation
163 SGTimedAnimation (SGPropertyNode_ptr props);
164 virtual ~SGTimedAnimation ();
165 virtual void update();
167 double _duration_sec;
168 double _last_time_sec;
174 * Animation to rotate an object around a center point.
176 * This animation rotates to a specific position.
178 class SGRotateAnimation : public SGAnimation
181 SGRotateAnimation( SGPropertyNode *prop_root, SGPropertyNode_ptr props );
182 virtual ~SGRotateAnimation ();
183 virtual void update();
185 SGPropertyNode_ptr _prop;
188 SGInterpTable * _table;
193 double _position_deg;
201 * Animation to slide along an axis.
203 class SGTranslateAnimation : public SGAnimation
206 SGTranslateAnimation( SGPropertyNode *prop_root,
207 SGPropertyNode_ptr props );
208 virtual ~SGTranslateAnimation ();
209 virtual void update();
211 SGPropertyNode_ptr _prop;
214 SGInterpTable * _table;
225 * Animation to blend an object.
227 class SGBlendAnimation : public SGAnimation
230 SGBlendAnimation( SGPropertyNode *prop_root,
231 SGPropertyNode_ptr props );
232 virtual ~SGBlendAnimation ();
233 virtual void update();
235 SGPropertyNode_ptr _prop;
236 SGInterpTable * _table;
247 * Animation to scale an object.
249 class SGScaleAnimation : public SGAnimation
252 SGScaleAnimation( SGPropertyNode *prop_root,
253 SGPropertyNode_ptr props );
254 virtual ~SGScaleAnimation ();
255 virtual void update();
257 SGPropertyNode_ptr _prop;
264 SGInterpTable * _table;
284 * Animation to rotate texture mappings around a center point.
286 * This animation rotates to a specific position.
288 class SGTexRotateAnimation : public SGAnimation
291 SGTexRotateAnimation( SGPropertyNode *prop_root, SGPropertyNode_ptr props );
292 virtual ~SGTexRotateAnimation ();
293 virtual void update();
295 SGPropertyNode_ptr _prop;
298 SGInterpTable * _table;
303 double _position_deg;
311 * Animation to slide texture mappings along an axis.
313 class SGTexTranslateAnimation : public SGAnimation
316 SGTexTranslateAnimation( SGPropertyNode *prop_root,
317 SGPropertyNode_ptr props );
318 virtual ~SGTexTranslateAnimation ();
319 virtual void update();
321 SGPropertyNode_ptr _prop;
326 SGInterpTable * _table;
339 * Classes for handling multiple types of Texture translations on one object
342 class SGTexMultipleAnimation : public SGAnimation
345 SGTexMultipleAnimation( SGPropertyNode *prop_root,
346 SGPropertyNode_ptr props );
347 virtual ~SGTexMultipleAnimation ();
348 virtual void update();
353 SGPropertyNode_ptr prop;
354 int subtype; // 0=translation, 1=rotation
359 SGInterpTable * table;
369 SGPropertyNode_ptr _prop;
370 TexTransform* _transform;
375 #endif // _SG_ANIMATION_HXX