1 // animation.hxx - classes to manage model animation.
2 // Written by David Megginson, started 2002.
4 // This file is in the Public Domain, and comes with no warranty.
6 #ifndef _SG_ANIMATION_HXX
7 #define _SG_ANIMATION_HXX 1
10 # error This library requires C++
20 #include <simgear/math/point3d.hxx>
21 #include <simgear/props/props.hxx>
24 // Don't pull in the headers, since we don't need them here.
29 // Has anyone done anything *really* stupid, like making min and max macros?
39 //////////////////////////////////////////////////////////////////////
41 //////////////////////////////////////////////////////////////////////
44 * Abstract base class for all animations.
46 class SGAnimation : public ssgBase
50 SGAnimation (SGPropertyNode_ptr props, ssgBranch * branch);
52 virtual ~SGAnimation ();
55 * Get the SSG branch holding the animation.
57 virtual ssgBranch * getBranch () { return _branch; }
60 * Initialize the animation, after children have been added.
65 * Update the animation.
67 virtual void update();
70 * Set the value of sim_time_sec. This needs to be called every
71 * frame in order for the time based animations to work correctly.
73 static void set_sim_time_sec( double val ) { sim_time_sec = val; }
77 static double sim_time_sec;
87 class SGNullAnimation : public SGAnimation
90 SGNullAnimation (SGPropertyNode_ptr props);
91 virtual ~SGNullAnimation ();
96 * A range, or level-of-detail (LOD) animation.
98 class SGRangeAnimation : public SGAnimation
101 SGRangeAnimation (SGPropertyNode_ptr props);
102 virtual ~SGRangeAnimation ();
107 * Animation to turn and face the screen.
109 class SGBillboardAnimation : public SGAnimation
112 SGBillboardAnimation (SGPropertyNode_ptr props);
113 virtual ~SGBillboardAnimation ();
118 * Animation to select alternative versions of the same object.
120 class SGSelectAnimation : public SGAnimation
123 SGSelectAnimation( SGPropertyNode *prop_root,
124 SGPropertyNode_ptr props );
125 virtual ~SGSelectAnimation ();
126 virtual void update();
128 SGCondition * _condition;
133 * Animation to spin an object around a center point.
135 * This animation rotates at a specific velocity.
137 class SGSpinAnimation : public SGAnimation
140 SGSpinAnimation( SGPropertyNode *prop_root,
141 SGPropertyNode_ptr props,
142 double sim_time_sec );
143 virtual ~SGSpinAnimation ();
144 virtual void update();
146 SGPropertyNode_ptr _prop;
148 double _position_deg;
149 double _last_time_sec;
157 * Animation to draw objects for a specific amount of time each.
159 class SGTimedAnimation : public SGAnimation
162 SGTimedAnimation (SGPropertyNode_ptr props);
163 virtual ~SGTimedAnimation ();
164 virtual void update();
166 double _duration_sec;
167 double _last_time_sec;
173 * Animation to rotate an object around a center point.
175 * This animation rotates to a specific position.
177 class SGRotateAnimation : public SGAnimation
180 SGRotateAnimation( SGPropertyNode *prop_root, SGPropertyNode_ptr props );
181 virtual ~SGRotateAnimation ();
182 virtual void update();
184 SGPropertyNode_ptr _prop;
187 SGInterpTable * _table;
192 double _position_deg;
200 * Animation to slide along an axis.
202 class SGTranslateAnimation : public SGAnimation
205 SGTranslateAnimation( SGPropertyNode *prop_root,
206 SGPropertyNode_ptr props );
207 virtual ~SGTranslateAnimation ();
208 virtual void update();
210 SGPropertyNode_ptr _prop;
213 SGInterpTable * _table;
224 #endif // _SG_ANIMATION_HXX