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++
20 // Don't pull in the headers, since we don't need them here.
23 class ssgRangeSelector;
33 // Has anyone done anything *really* stupid, like making min and max macros?
46 virtual ~FG3DModel ();
48 virtual void init (const string &path);
49 virtual void update (int dt);
51 virtual bool getVisible () const;
52 virtual void setVisible (bool visible);
54 virtual double getLongitudeDeg () const { return _lon_deg; }
55 virtual double getLatitudeDeg () const { return _lat_deg; }
56 virtual double getElevationFt () const { return _elev_ft; }
58 virtual void setLongitudeDeg (double lon_deg);
59 virtual void setLatitudeDeg (double lat_deg);
60 virtual void setElevationFt (double elev_ft);
61 virtual void setPosition (double lon_deg, double lat_deg, double elev_ft);
63 virtual double getRollDeg () const { return _roll_deg; }
64 virtual double getPitchDeg () const { return _pitch_deg; }
65 virtual double getHeadingDeg () const { return _heading_deg; }
67 virtual void setRollDeg (double roll_deg);
68 virtual void setPitchDeg (double pitch_deg);
69 virtual void setHeadingDeg (double heading_deg);
70 virtual void setOrientation (double roll_deg, double pitch_deg,
73 virtual ssgEntity * getSceneGraph () const { return (ssgEntity *)_selector; }
75 virtual FGLocation * getFGLocation () const { return _location; }
80 Animation * make_animation (const char * object_name, SGPropertyNode * node);
93 vector <Animation *> _animations;
97 ssgSelector * _selector;
98 ssgTransform * _position;
101 FGLocation * _location;
105 //////////////////////////////////////////////////////////////////////
106 // Internal classes for individual animations.
107 //////////////////////////////////////////////////////////////////////
110 * Abstract base class for all animations.
118 virtual ~Animation ();
121 * Initialize the animation.
123 * @param object The object to animate.
124 * @param props The property node with configuration information.
126 virtual void init (ssgEntity * object, SGPropertyNode * props) = 0;
130 * Update the animation.
132 * @param dt The elapsed time in milliseconds since the last call.
134 virtual void update (int dt) = 0;
142 class NullAnimation : public Animation
146 virtual ~NullAnimation ();
147 virtual void init (ssgEntity * object, SGPropertyNode * props);
148 virtual void update (int dt);
155 * A range, or level-of-detail (LOD) animation.
157 class RangeAnimation : public Animation
161 virtual ~RangeAnimation ();
162 virtual void init (ssgEntity * object, SGPropertyNode * props);
163 virtual void update (int dt);
165 ssgRangeSelector * _branch;
170 * Animation to select alternative versions of the same object.
172 class SelectAnimation : public Animation
176 virtual ~SelectAnimation ();
177 virtual void init (ssgEntity * object, SGPropertyNode * props);
178 virtual void update (int dt);
180 FGCondition * _condition;
181 ssgSelector * _selector;
186 * Animation to spin an object around a center point.
188 * This animation rotates at a specific velocity.
190 class SpinAnimation : public Animation
194 virtual ~SpinAnimation ();
195 virtual void init (ssgEntity * object, SGPropertyNode * props);
196 virtual void update (int dt);
198 SGPropertyNode * _prop;
200 double _position_deg;
204 ssgTransform * _transform;
209 * Animation to rotate an object around a center point.
211 * This animation rotates to a specific position.
213 class RotateAnimation : public Animation
217 virtual ~RotateAnimation ();
218 virtual void init (ssgEntity * object, SGPropertyNode * props);
219 virtual void update (int dt);
221 SGPropertyNode * _prop;
224 SGInterpTable * _table;
229 double _position_deg;
233 ssgTransform * _transform;
238 * Animation to slide along an axis.
240 class TranslateAnimation : public Animation
243 TranslateAnimation ();
244 virtual ~TranslateAnimation ();
245 virtual void init (ssgEntity * object, SGPropertyNode * props);
246 virtual void update (int dt);
248 SGPropertyNode * _prop;
251 SGInterpTable * _table;
259 ssgTransform * _transform;
264 #endif // __MODEL_HXX