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 rotate texture mappings around a center point.
227 * This animation rotates to a specific position.
229 class SGTexRotateAnimation : public SGAnimation
232 SGTexRotateAnimation( SGPropertyNode *prop_root, SGPropertyNode_ptr props );
233 virtual ~SGTexRotateAnimation ();
234 virtual void update();
236 SGPropertyNode_ptr _prop;
239 SGInterpTable * _table;
244 double _position_deg;
252 * Animation to slide texture mappings along an axis.
254 class SGTexTranslateAnimation : public SGAnimation
257 SGTexTranslateAnimation( SGPropertyNode *prop_root,
258 SGPropertyNode_ptr props );
259 virtual ~SGTexTranslateAnimation ();
260 virtual void update();
262 SGPropertyNode_ptr _prop;
266 SGInterpTable * _table;
276 #endif // _SG_ANIMATION_HXX