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.
24 class ssgRangeSelector;
34 // Has anyone done anything *really* stupid, like making min and max macros?
48 virtual ~FG3DModel ();
50 virtual void init (const string &path);
51 virtual void update (double dt);
53 virtual ssgEntity * getSceneGraph () const { return (ssgEntity *)_model; }
58 Animation * make_animation (const char * object_name, SGPropertyNode * node);
61 vector<FG3DModel *> _children;
64 vector <Animation *> _animations;
71 //////////////////////////////////////////////////////////////////////
72 // Internal classes for individual animations.
73 //////////////////////////////////////////////////////////////////////
76 * Abstract base class for all animations.
84 virtual ~Animation ();
87 * Initialize the animation.
89 * @param object The object to animate.
90 * @param props The property node with configuration information.
92 virtual void init (ssgEntity * object, SGPropertyNode * props) = 0;
96 * Update the animation.
98 * @param dt The elapsed time in seconds since the last call.
100 virtual void update (double dt) = 0;
108 class NullAnimation : public Animation
112 virtual ~NullAnimation ();
113 virtual void init (ssgEntity * object, SGPropertyNode * props);
114 virtual void update (double dt);
121 * A range, or level-of-detail (LOD) animation.
123 class RangeAnimation : public Animation
127 virtual ~RangeAnimation ();
128 virtual void init (ssgEntity * object, SGPropertyNode * props);
129 virtual void update (double dt);
131 ssgRangeSelector * _branch;
136 * Animation to turn and face the screen.
138 class BillboardAnimation : public Animation
141 BillboardAnimation ();
142 virtual ~BillboardAnimation ();
143 virtual void init (ssgEntity * object, SGPropertyNode * props);
144 virtual void update (double dt);
151 * Animation to select alternative versions of the same object.
153 class SelectAnimation : public Animation
157 virtual ~SelectAnimation ();
158 virtual void init (ssgEntity * object, SGPropertyNode * props);
159 virtual void update (double dt);
161 FGCondition * _condition;
162 ssgSelector * _selector;
167 * Animation to spin an object around a center point.
169 * This animation rotates at a specific velocity.
171 class SpinAnimation : public Animation
175 virtual ~SpinAnimation ();
176 virtual void init (ssgEntity * object, SGPropertyNode * props);
177 virtual void update (double dt);
179 SGPropertyNode * _prop;
181 double _position_deg;
185 ssgTransform * _transform;
190 * Animation to rotate an object around a center point.
192 * This animation rotates to a specific position.
194 class RotateAnimation : public Animation
198 virtual ~RotateAnimation ();
199 virtual void init (ssgEntity * object, SGPropertyNode * props);
200 virtual void update (double dt);
202 SGPropertyNode * _prop;
205 SGInterpTable * _table;
210 double _position_deg;
214 ssgTransform * _transform;
219 * Animation to slide along an axis.
221 class TranslateAnimation : public Animation
224 TranslateAnimation ();
225 virtual ~TranslateAnimation ();
226 virtual void init (ssgEntity * object, SGPropertyNode * props);
227 virtual void update (double dt);
229 SGPropertyNode * _prop;
232 SGInterpTable * _table;
240 ssgTransform * _transform;
247 class FGModelPlacement
252 virtual ~FGModelPlacement ();
254 virtual void init (const string &path);
255 virtual void update (double dt);
257 virtual ssgEntity * getSceneGraph () { return (ssgEntity *)_selector; }
259 virtual FGLocation * getFGLocation () { return _location; }
261 virtual bool getVisible () const;
262 virtual void setVisible (bool visible);
264 virtual double getLongitudeDeg () const { return _lon_deg; }
265 virtual double getLatitudeDeg () const { return _lat_deg; }
266 virtual double getElevationFt () const { return _elev_ft; }
268 virtual void setLongitudeDeg (double lon_deg);
269 virtual void setLatitudeDeg (double lat_deg);
270 virtual void setElevationFt (double elev_ft);
271 virtual void setPosition (double lon_deg, double lat_deg, double elev_ft);
273 virtual double getRollDeg () const { return _roll_deg; }
274 virtual double getPitchDeg () const { return _pitch_deg; }
275 virtual double getHeadingDeg () const { return _heading_deg; }
277 virtual void setRollDeg (double roll_deg);
278 virtual void setPitchDeg (double pitch_deg);
279 virtual void setHeadingDeg (double heading_deg);
280 virtual void setOrientation (double roll_deg, double pitch_deg,
297 ssgSelector * _selector;
298 ssgTransform * _position;
301 FGLocation * _location;
305 #endif // __MODEL_HXX