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;
115 * Animation to turn and face the screen.
117 class SGBillboardAnimation : public SGAnimation
120 SGBillboardAnimation (SGPropertyNode_ptr props);
121 virtual ~SGBillboardAnimation ();
126 * Animation to select alternative versions of the same object.
128 class SGSelectAnimation : public SGAnimation
131 SGSelectAnimation( SGPropertyNode *prop_root,
132 SGPropertyNode_ptr props );
133 virtual ~SGSelectAnimation ();
134 virtual void update();
136 SGCondition * _condition;
141 * Animation to spin an object around a center point.
143 * This animation rotates at a specific velocity.
145 class SGSpinAnimation : public SGAnimation
148 SGSpinAnimation( SGPropertyNode *prop_root,
149 SGPropertyNode_ptr props,
150 double sim_time_sec );
151 virtual ~SGSpinAnimation ();
152 virtual void update();
154 SGPropertyNode_ptr _prop;
156 double _position_deg;
157 double _last_time_sec;
165 * Animation to draw objects for a specific amount of time each.
167 class SGTimedAnimation : public SGAnimation
170 SGTimedAnimation (SGPropertyNode_ptr props);
171 virtual ~SGTimedAnimation ();
172 virtual void update();
174 double _duration_sec;
175 double _last_time_sec;
181 * Animation to rotate an object around a center point.
183 * This animation rotates to a specific position.
185 class SGRotateAnimation : public SGAnimation
188 SGRotateAnimation( SGPropertyNode *prop_root, SGPropertyNode_ptr props );
189 virtual ~SGRotateAnimation ();
190 virtual void update();
192 SGPropertyNode_ptr _prop;
195 SGInterpTable * _table;
200 double _position_deg;
208 * Animation to slide along an axis.
210 class SGTranslateAnimation : public SGAnimation
213 SGTranslateAnimation( SGPropertyNode *prop_root,
214 SGPropertyNode_ptr props );
215 virtual ~SGTranslateAnimation ();
216 virtual void update();
218 SGPropertyNode_ptr _prop;
221 SGInterpTable * _table;
232 * Animation to blend an object.
234 class SGBlendAnimation : public SGAnimation
237 SGBlendAnimation( SGPropertyNode *prop_root,
238 SGPropertyNode_ptr props );
239 virtual ~SGBlendAnimation ();
240 virtual void update();
242 SGPropertyNode_ptr _prop;
243 SGInterpTable * _table;
254 * Animation to scale an object.
256 class SGScaleAnimation : public SGAnimation
259 SGScaleAnimation( SGPropertyNode *prop_root,
260 SGPropertyNode_ptr props );
261 virtual ~SGScaleAnimation ();
262 virtual void update();
264 SGPropertyNode_ptr _prop;
271 SGInterpTable * _table;
291 * Animation to rotate texture mappings around a center point.
293 * This animation rotates to a specific position.
295 class SGTexRotateAnimation : public SGAnimation
298 SGTexRotateAnimation( SGPropertyNode *prop_root, SGPropertyNode_ptr props );
299 virtual ~SGTexRotateAnimation ();
300 virtual void update();
302 SGPropertyNode_ptr _prop;
305 SGInterpTable * _table;
310 double _position_deg;
318 * Animation to slide texture mappings along an axis.
320 class SGTexTranslateAnimation : public SGAnimation
323 SGTexTranslateAnimation( SGPropertyNode *prop_root,
324 SGPropertyNode_ptr props );
325 virtual ~SGTexTranslateAnimation ();
326 virtual void update();
328 SGPropertyNode_ptr _prop;
333 SGInterpTable * _table;
346 * Classes for handling multiple types of Texture translations on one object
349 class SGTexMultipleAnimation : public SGAnimation
352 SGTexMultipleAnimation( SGPropertyNode *prop_root,
353 SGPropertyNode_ptr props );
354 virtual ~SGTexMultipleAnimation ();
355 virtual void update();
360 SGPropertyNode_ptr prop;
361 int subtype; // 0=translation, 1=rotation
366 SGInterpTable * table;
376 SGPropertyNode_ptr _prop;
377 TexTransform* _transform;
382 #endif // _SG_ANIMATION_HXX