1 // model.hxx - manage a 3D aircraft model.
2 // Written by David Megginson, started 2002.
4 // This file is in the Public Domain, and comes with no warranty.
10 # error This library requires C++
17 #include <Main/fg_props.hxx>
19 // Has anyone done anything *really* stupid, like making min and max macros?
32 virtual ~FG3DModel ();
34 virtual void init (const string &path);
35 virtual void update (int dt);
37 virtual bool getVisible () const;
38 virtual void setVisible (bool visible);
40 virtual double getLongitudeDeg () const { return _lon_deg; }
41 virtual double getLatitudeDeg () const { return _lat_deg; }
42 virtual double getElevationFt () const { return _elev_ft; }
44 virtual void setPosition (double lon_deg, double lat_deg, double elev_ft);
46 virtual double getRoll () const { return _roll_deg; }
47 virtual double getPitch () const { return _pitch_deg; }
48 virtual double getHeading () const { return _heading_deg; }
50 virtual void setOrientation (double roll_deg, double pitch_deg,
53 virtual ssgEntity * getSceneGraph () const { return _selector; }
58 Animation * make_animation (const char * object_name, SGPropertyNode * node);
72 vector <Animation *> _animations;
77 ssgSelector * _selector;
78 ssgTransform * _position;
82 //////////////////////////////////////////////////////////////////////
83 // Internal classes for individual animations.
84 //////////////////////////////////////////////////////////////////////
87 * Abstract base class for all animations.
95 virtual ~Animation ();
98 * Initialize the animation.
100 * @param object The object to animate.
101 * @param props The property node with configuration information.
103 virtual void init (ssgEntity * object, SGPropertyNode * props) = 0;
107 * Update the animation.
109 * @param dt The elapsed time in milliseconds since the last call.
111 virtual void update (int dt) = 0;
119 class NullAnimation : public Animation
123 virtual ~NullAnimation ();
124 virtual void init (ssgEntity * object, SGPropertyNode * props);
125 virtual void update (int dt);
132 * Animation to select alternative versions of the same object.
134 class SelectAnimation : public Animation
138 virtual ~SelectAnimation ();
139 virtual void init (ssgEntity * object, SGPropertyNode * props);
140 virtual void update (int dt);
142 FGCondition * _condition;
143 ssgSelector * _selector;
148 * Animation to spin an object around a center point.
150 * This animation rotates at a specific velocity.
152 class SpinAnimation : public Animation
156 virtual ~SpinAnimation ();
157 virtual void init (ssgEntity * object, SGPropertyNode * props);
158 virtual void update (int dt);
160 SGPropertyNode * _prop;
162 double _position_deg;
166 ssgTransform * _transform;
171 * Animation to rotate an object around a center point.
173 * This animation rotates to a specific position.
175 class RotateAnimation : public Animation
179 virtual ~RotateAnimation ();
180 virtual void init (ssgEntity * object, SGPropertyNode * props);
181 virtual void update (int dt);
183 SGPropertyNode * _prop;
190 double _position_deg;
194 ssgTransform * _transform;
199 * Animation to slide along an axis.
201 class TranslateAnimation : public Animation
204 TranslateAnimation ();
205 virtual ~TranslateAnimation ();
206 virtual void init (ssgEntity * object, SGPropertyNode * props);
207 virtual void update (int dt);
209 SGPropertyNode * _prop;
219 ssgTransform * _transform;
224 #endif // __MODEL_HXX