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.
71 * Restore the state after the animation.
73 virtual void restore();
76 * Set the value of sim_time_sec. This needs to be called every
77 * frame in order for the time based animations to work correctly.
79 static void set_sim_time_sec( double val ) { sim_time_sec = val; }
83 static double sim_time_sec;
93 class SGNullAnimation : public SGAnimation
96 SGNullAnimation (SGPropertyNode_ptr props);
97 virtual ~SGNullAnimation ();
102 * A range, or level-of-detail (LOD) animation.
104 class SGRangeAnimation : public SGAnimation
107 SGRangeAnimation (SGPropertyNode *prop_root,
108 SGPropertyNode_ptr props);
109 virtual ~SGRangeAnimation ();
110 virtual int update();
112 SGPropertyNode_ptr _min_prop;
113 SGPropertyNode_ptr _max_prop;
122 * Animation to turn and face the screen.
124 class SGBillboardAnimation : public SGAnimation
127 SGBillboardAnimation (SGPropertyNode_ptr props);
128 virtual ~SGBillboardAnimation ();
133 * Animation to select alternative versions of the same object.
135 class SGSelectAnimation : public SGAnimation
138 SGSelectAnimation( SGPropertyNode *prop_root,
139 SGPropertyNode_ptr props );
140 virtual ~SGSelectAnimation ();
141 virtual int update();
143 SGCondition * _condition;
148 * Animation to spin an object around a center point.
150 * This animation rotates at a specific velocity.
152 class SGSpinAnimation : public SGAnimation
155 SGSpinAnimation( SGPropertyNode *prop_root,
156 SGPropertyNode_ptr props,
157 double sim_time_sec );
158 virtual ~SGSpinAnimation ();
159 virtual int update();
161 SGPropertyNode_ptr _prop;
163 double _position_deg;
164 double _last_time_sec;
172 * Animation to draw objects for a specific amount of time each.
174 class SGTimedAnimation : public SGAnimation
177 SGTimedAnimation (SGPropertyNode_ptr props);
178 virtual ~SGTimedAnimation ();
179 virtual int update();
181 double _duration_sec;
182 double _last_time_sec;
188 * Animation to rotate an object around a center point.
190 * This animation rotates to a specific position.
192 class SGRotateAnimation : public SGAnimation
195 SGRotateAnimation( SGPropertyNode *prop_root, SGPropertyNode_ptr props );
196 virtual ~SGRotateAnimation ();
197 virtual int update();
199 SGPropertyNode_ptr _prop;
202 SGInterpTable * _table;
207 double _position_deg;
215 * Animation to slide along an axis.
217 class SGTranslateAnimation : public SGAnimation
220 SGTranslateAnimation( SGPropertyNode *prop_root,
221 SGPropertyNode_ptr props );
222 virtual ~SGTranslateAnimation ();
223 virtual int update();
225 SGPropertyNode_ptr _prop;
228 SGInterpTable * _table;
239 * Animation to blend an object.
241 class SGBlendAnimation : public SGAnimation
244 SGBlendAnimation( SGPropertyNode *prop_root,
245 SGPropertyNode_ptr props );
246 virtual ~SGBlendAnimation ();
247 virtual int update();
249 SGPropertyNode_ptr _prop;
250 SGInterpTable * _table;
261 * Animation to scale an object.
263 class SGScaleAnimation : public SGAnimation
266 SGScaleAnimation( SGPropertyNode *prop_root,
267 SGPropertyNode_ptr props );
268 virtual ~SGScaleAnimation ();
269 virtual int update();
271 SGPropertyNode_ptr _prop;
278 SGInterpTable * _table;
298 * Animation to rotate texture mappings around a center point.
300 * This animation rotates to a specific position.
302 class SGTexRotateAnimation : public SGAnimation
305 SGTexRotateAnimation( SGPropertyNode *prop_root, SGPropertyNode_ptr props );
306 virtual ~SGTexRotateAnimation ();
307 virtual int update();
309 SGPropertyNode_ptr _prop;
312 SGInterpTable * _table;
317 double _position_deg;
325 * Animation to slide texture mappings along an axis.
327 class SGTexTranslateAnimation : public SGAnimation
330 SGTexTranslateAnimation( SGPropertyNode *prop_root,
331 SGPropertyNode_ptr props );
332 virtual ~SGTexTranslateAnimation ();
333 virtual int update();
335 SGPropertyNode_ptr _prop;
340 SGInterpTable * _table;
353 * Classes for handling multiple types of Texture translations on one object
356 class SGTexMultipleAnimation : public SGAnimation
359 SGTexMultipleAnimation( SGPropertyNode *prop_root,
360 SGPropertyNode_ptr props );
361 virtual ~SGTexMultipleAnimation ();
362 virtual int update();
367 SGPropertyNode_ptr prop;
368 int subtype; // 0=translation, 1=rotation
373 SGInterpTable * table;
383 SGPropertyNode_ptr _prop;
384 TexTransform* _transform;
390 * An "animation" to enable the alpha test
392 class SGAlphaTestAnimation : public SGAnimation
395 SGAlphaTestAnimation(SGPropertyNode_ptr props);
396 virtual ~SGAlphaTestAnimation ();
399 void setAlphaClampToBranch(ssgBranch *b, float clamp);
405 * An "animation" that compute a scale according to
406 * the angle between an axis and the view direction
408 class SGFlashAnimation : public SGAnimation
411 SGFlashAnimation(SGPropertyNode_ptr props);
412 virtual ~SGFlashAnimation ();
416 #endif // _SG_ANIMATION_HXX