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?
47 virtual ~FG3DModel ();
49 virtual void init (const string &path);
50 virtual void update (double dt);
52 virtual bool getVisible () const;
53 virtual void setVisible (bool visible);
55 virtual double getLongitudeDeg () const { return _lon_deg; }
56 virtual double getLatitudeDeg () const { return _lat_deg; }
57 virtual double getElevationFt () const { return _elev_ft; }
59 virtual void setLongitudeDeg (double lon_deg);
60 virtual void setLatitudeDeg (double lat_deg);
61 virtual void setElevationFt (double elev_ft);
62 virtual void setPosition (double lon_deg, double lat_deg, double elev_ft);
64 virtual double getRollDeg () const { return _roll_deg; }
65 virtual double getPitchDeg () const { return _pitch_deg; }
66 virtual double getHeadingDeg () const { return _heading_deg; }
68 virtual void setRollDeg (double roll_deg);
69 virtual void setPitchDeg (double pitch_deg);
70 virtual void setHeadingDeg (double heading_deg);
71 virtual void setOrientation (double roll_deg, double pitch_deg,
74 virtual ssgEntity * getSceneGraph () const { return (ssgEntity *)_selector; }
76 virtual FGLocation * getFGLocation () const { return _location; }
81 Animation * make_animation (const char * object_name, SGPropertyNode * node);
94 vector <Animation *> _animations;
98 ssgSelector * _selector;
99 ssgTransform * _position;
102 FGLocation * _location;
106 //////////////////////////////////////////////////////////////////////
107 // Internal classes for individual animations.
108 //////////////////////////////////////////////////////////////////////
111 * Abstract base class for all animations.
119 virtual ~Animation ();
122 * Initialize the animation.
124 * @param object The object to animate.
125 * @param props The property node with configuration information.
127 virtual void init (ssgEntity * object, SGPropertyNode * props) = 0;
131 * Update the animation.
133 * @param dt The elapsed time in seconds since the last call.
135 virtual void update (double dt) = 0;
143 class NullAnimation : public Animation
147 virtual ~NullAnimation ();
148 virtual void init (ssgEntity * object, SGPropertyNode * props);
149 virtual void update (double dt);
156 * A range, or level-of-detail (LOD) animation.
158 class RangeAnimation : public Animation
162 virtual ~RangeAnimation ();
163 virtual void init (ssgEntity * object, SGPropertyNode * props);
164 virtual void update (double dt);
166 ssgRangeSelector * _branch;
171 * Animation to turn and face the screen.
173 class BillboardAnimation : public Animation
176 BillboardAnimation ();
177 virtual ~BillboardAnimation ();
178 virtual void init (ssgEntity * object, SGPropertyNode * props);
179 virtual void update (double dt);
186 * Animation to select alternative versions of the same object.
188 class SelectAnimation : public Animation
192 virtual ~SelectAnimation ();
193 virtual void init (ssgEntity * object, SGPropertyNode * props);
194 virtual void update (double dt);
196 FGCondition * _condition;
197 ssgSelector * _selector;
202 * Animation to spin an object around a center point.
204 * This animation rotates at a specific velocity.
206 class SpinAnimation : public Animation
210 virtual ~SpinAnimation ();
211 virtual void init (ssgEntity * object, SGPropertyNode * props);
212 virtual void update (double dt);
214 SGPropertyNode * _prop;
216 double _position_deg;
220 ssgTransform * _transform;
225 * Animation to rotate an object around a center point.
227 * This animation rotates to a specific position.
229 class RotateAnimation : public Animation
233 virtual ~RotateAnimation ();
234 virtual void init (ssgEntity * object, SGPropertyNode * props);
235 virtual void update (double dt);
237 SGPropertyNode * _prop;
240 SGInterpTable * _table;
245 double _position_deg;
249 ssgTransform * _transform;
254 * Animation to slide along an axis.
256 class TranslateAnimation : public Animation
259 TranslateAnimation ();
260 virtual ~TranslateAnimation ();
261 virtual void init (ssgEntity * object, SGPropertyNode * props);
262 virtual void update (double dt);
264 SGPropertyNode * _prop;
267 SGInterpTable * _table;
275 ssgTransform * _transform;
281 #endif // __MODEL_HXX