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.
28 class ssgRangeSelector;
37 // Has anyone done anything *really* stupid, like making min and max macros?
47 //////////////////////////////////////////////////////////////////////
49 //////////////////////////////////////////////////////////////////////
52 * Abstract base class for all animations.
54 class Animation : public ssgBase
58 Animation (SGPropertyNode_ptr props, ssgBranch * branch);
60 virtual ~Animation ();
63 * Get the SSG branch holding the animation.
65 virtual ssgBranch * getBranch () { return _branch; }
68 * Initialize the animation, after children have been added.
73 * Update the animation.
75 virtual void update();
78 * Set the value of sim_time_sec. This needs to be called every
79 * frame in order for the time based animations to work correctly.
81 static void set_sim_time_sec( double val ) { sim_time_sec = val; }
85 static double sim_time_sec;
95 class NullAnimation : public Animation
98 NullAnimation (SGPropertyNode_ptr props);
99 virtual ~NullAnimation ();
104 * A range, or level-of-detail (LOD) animation.
106 class RangeAnimation : public Animation
109 RangeAnimation (SGPropertyNode_ptr props);
110 virtual ~RangeAnimation ();
115 * Animation to turn and face the screen.
117 class BillboardAnimation : public Animation
120 BillboardAnimation (SGPropertyNode_ptr props);
121 virtual ~BillboardAnimation ();
126 * Animation to select alternative versions of the same object.
128 class SelectAnimation : public Animation
131 SelectAnimation( SGPropertyNode *prop_root,
132 SGPropertyNode_ptr props );
133 virtual ~SelectAnimation ();
134 virtual void update();
136 FGCondition * _condition;
141 * Animation to spin an object around a center point.
143 * This animation rotates at a specific velocity.
145 class SpinAnimation : public Animation
148 SpinAnimation( SGPropertyNode *prop_root,
149 SGPropertyNode_ptr props,
150 double sim_time_sec );
151 virtual ~SpinAnimation ();
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 TimedAnimation : public Animation
170 TimedAnimation (SGPropertyNode_ptr props);
171 virtual ~TimedAnimation ();
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 RotateAnimation : public Animation
188 RotateAnimation( SGPropertyNode *prop_root, SGPropertyNode_ptr props );
189 virtual ~RotateAnimation ();
190 virtual void update();
192 SGPropertyNode_ptr _prop;
195 SGInterpTable * _table;
200 double _position_deg;
208 * Animation to slide along an axis.
210 class TranslateAnimation : public Animation
213 TranslateAnimation( SGPropertyNode *prop_root,
214 SGPropertyNode_ptr props );
215 virtual ~TranslateAnimation ();
216 virtual void update();
218 SGPropertyNode_ptr _prop;
221 SGInterpTable * _table;
232 #endif // _SG_ANIMATION_HXX