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 *prop_root,
103 SGPropertyNode_ptr props);
104 virtual ~SGRangeAnimation ();
105 virtual void update();
107 SGPropertyNode_ptr _min_prop;
108 SGPropertyNode_ptr _max_prop;
117 * Animation to turn and face the screen.
119 class SGBillboardAnimation : public SGAnimation
122 SGBillboardAnimation (SGPropertyNode_ptr props);
123 virtual ~SGBillboardAnimation ();
128 * Animation to select alternative versions of the same object.
130 class SGSelectAnimation : public SGAnimation
133 SGSelectAnimation( SGPropertyNode *prop_root,
134 SGPropertyNode_ptr props );
135 virtual ~SGSelectAnimation ();
136 virtual void update();
138 SGCondition * _condition;
143 * Animation to spin an object around a center point.
145 * This animation rotates at a specific velocity.
147 class SGSpinAnimation : public SGAnimation
150 SGSpinAnimation( SGPropertyNode *prop_root,
151 SGPropertyNode_ptr props,
152 double sim_time_sec );
153 virtual ~SGSpinAnimation ();
154 virtual void update();
156 SGPropertyNode_ptr _prop;
158 double _position_deg;
159 double _last_time_sec;
167 * Animation to draw objects for a specific amount of time each.
169 class SGTimedAnimation : public SGAnimation
172 SGTimedAnimation (SGPropertyNode_ptr props);
173 virtual ~SGTimedAnimation ();
174 virtual void update();
176 double _duration_sec;
177 double _last_time_sec;
183 * Animation to rotate an object around a center point.
185 * This animation rotates to a specific position.
187 class SGRotateAnimation : public SGAnimation
190 SGRotateAnimation( SGPropertyNode *prop_root, SGPropertyNode_ptr props );
191 virtual ~SGRotateAnimation ();
192 virtual void update();
194 SGPropertyNode_ptr _prop;
197 SGInterpTable * _table;
202 double _position_deg;
210 * Animation to slide along an axis.
212 class SGTranslateAnimation : public SGAnimation
215 SGTranslateAnimation( SGPropertyNode *prop_root,
216 SGPropertyNode_ptr props );
217 virtual ~SGTranslateAnimation ();
218 virtual void update();
220 SGPropertyNode_ptr _prop;
223 SGInterpTable * _table;
234 * Animation to blend an object.
236 class SGBlendAnimation : public SGAnimation
239 SGBlendAnimation( SGPropertyNode *prop_root,
240 SGPropertyNode_ptr props );
241 virtual ~SGBlendAnimation ();
242 virtual void update();
244 SGPropertyNode_ptr _prop;
245 SGInterpTable * _table;
256 * Animation to scale an object.
258 class SGScaleAnimation : public SGAnimation
261 SGScaleAnimation( SGPropertyNode *prop_root,
262 SGPropertyNode_ptr props );
263 virtual ~SGScaleAnimation ();
264 virtual void update();
266 SGPropertyNode_ptr _prop;
273 SGInterpTable * _table;
293 * Animation to rotate texture mappings around a center point.
295 * This animation rotates to a specific position.
297 class SGTexRotateAnimation : public SGAnimation
300 SGTexRotateAnimation( SGPropertyNode *prop_root, SGPropertyNode_ptr props );
301 virtual ~SGTexRotateAnimation ();
302 virtual void update();
304 SGPropertyNode_ptr _prop;
307 SGInterpTable * _table;
312 double _position_deg;
320 * Animation to slide texture mappings along an axis.
322 class SGTexTranslateAnimation : public SGAnimation
325 SGTexTranslateAnimation( SGPropertyNode *prop_root,
326 SGPropertyNode_ptr props );
327 virtual ~SGTexTranslateAnimation ();
328 virtual void update();
330 SGPropertyNode_ptr _prop;
335 SGInterpTable * _table;
348 * Classes for handling multiple types of Texture translations on one object
351 class SGTexMultipleAnimation : public SGAnimation
354 SGTexMultipleAnimation( SGPropertyNode *prop_root,
355 SGPropertyNode_ptr props );
356 virtual ~SGTexMultipleAnimation ();
357 virtual void update();
362 SGPropertyNode_ptr prop;
363 int subtype; // 0=translation, 1=rotation
368 SGInterpTable * table;
378 SGPropertyNode_ptr _prop;
379 TexTransform* _transform;
385 * An animation to enable the alpha test
387 class SGAlphaTestAnimation : public SGAnimation
390 SGAlphaTestAnimation(SGPropertyNode_ptr props);
391 virtual ~SGAlphaTestAnimation ();
394 void setAlphaClampToBranch(ssgBranch *b, float clamp);
399 #endif // _SG_ANIMATION_HXX