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 Animation : public ssgBase
50 Animation (SGPropertyNode_ptr props, ssgBranch * branch);
52 virtual ~Animation ();
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 NullAnimation : public Animation
90 NullAnimation (SGPropertyNode_ptr props);
91 virtual ~NullAnimation ();
96 * A range, or level-of-detail (LOD) animation.
98 class RangeAnimation : public Animation
101 RangeAnimation (SGPropertyNode_ptr props);
102 virtual ~RangeAnimation ();
107 * Animation to turn and face the screen.
109 class BillboardAnimation : public Animation
112 BillboardAnimation (SGPropertyNode_ptr props);
113 virtual ~BillboardAnimation ();
118 * Animation to select alternative versions of the same object.
120 class SelectAnimation : public Animation
123 SelectAnimation( SGPropertyNode *prop_root,
124 SGPropertyNode_ptr props );
125 virtual ~SelectAnimation ();
126 virtual void update();
128 FGCondition * _condition;
133 * Animation to spin an object around a center point.
135 * This animation rotates at a specific velocity.
137 class SpinAnimation : public Animation
140 SpinAnimation( SGPropertyNode *prop_root,
141 SGPropertyNode_ptr props,
142 double sim_time_sec );
143 virtual ~SpinAnimation ();
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 TimedAnimation : public Animation
162 TimedAnimation (SGPropertyNode_ptr props);
163 virtual ~TimedAnimation ();
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 RotateAnimation : public Animation
180 RotateAnimation( SGPropertyNode *prop_root, SGPropertyNode_ptr props );
181 virtual ~RotateAnimation ();
182 virtual void update();
184 SGPropertyNode_ptr _prop;
187 SGInterpTable * _table;
192 double _position_deg;
200 * Animation to slide along an axis.
202 class TranslateAnimation : public Animation
205 TranslateAnimation( SGPropertyNode *prop_root,
206 SGPropertyNode_ptr props );
207 virtual ~TranslateAnimation ();
208 virtual void update();
210 SGPropertyNode_ptr _prop;
213 SGInterpTable * _table;
224 #endif // _SG_ANIMATION_HXX