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.
22 class ssgRangeSelector;
32 // Has anyone done anything *really* stupid, like making min and max macros?
45 virtual ~FG3DModel ();
47 virtual void init (const string &path);
48 virtual void update (int dt);
50 virtual bool getVisible () const;
51 virtual void setVisible (bool visible);
53 virtual double getLongitudeDeg () const { return _lon_deg; }
54 virtual double getLatitudeDeg () const { return _lat_deg; }
55 virtual double getElevationFt () const { return _elev_ft; }
57 virtual void setLongitudeDeg (double lon_deg);
58 virtual void setLatitudeDeg (double lat_deg);
59 virtual void setElevationFt (double elev_ft);
60 virtual void setPosition (double lon_deg, double lat_deg, double elev_ft);
62 virtual double getRollDeg () const { return _roll_deg; }
63 virtual double getPitchDeg () const { return _pitch_deg; }
64 virtual double getHeadingDeg () const { return _heading_deg; }
66 virtual void setRollDeg (double roll_deg);
67 virtual void setPitchDeg (double pitch_deg);
68 virtual void setHeadingDeg (double heading_deg);
69 virtual void setOrientation (double roll_deg, double pitch_deg,
72 virtual ssgEntity * getSceneGraph () const { return (ssgEntity *)_selector; }
74 virtual FGLocation * getFGLocation () const { return _location; }
79 Animation * make_animation (const char * object_name, SGPropertyNode * node);
93 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 milliseconds since the last call.
135 virtual void update (int dt) = 0;
143 class NullAnimation : public Animation
147 virtual ~NullAnimation ();
148 virtual void init (ssgEntity * object, SGPropertyNode * props);
149 virtual void update (int 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 (int dt);
166 ssgRangeSelector * _branch;
171 * Animation to select alternative versions of the same object.
173 class SelectAnimation : public Animation
177 virtual ~SelectAnimation ();
178 virtual void init (ssgEntity * object, SGPropertyNode * props);
179 virtual void update (int dt);
181 FGCondition * _condition;
182 ssgSelector * _selector;
187 * Animation to spin an object around a center point.
189 * This animation rotates at a specific velocity.
191 class SpinAnimation : public Animation
195 virtual ~SpinAnimation ();
196 virtual void init (ssgEntity * object, SGPropertyNode * props);
197 virtual void update (int dt);
199 SGPropertyNode * _prop;
201 double _position_deg;
205 ssgTransform * _transform;
210 * Animation to rotate an object around a center point.
212 * This animation rotates to a specific position.
214 class RotateAnimation : public Animation
218 virtual ~RotateAnimation ();
219 virtual void init (ssgEntity * object, SGPropertyNode * props);
220 virtual void update (int dt);
222 SGPropertyNode * _prop;
225 SGInterpTable * _table;
230 double _position_deg;
234 ssgTransform * _transform;
239 * Animation to slide along an axis.
241 class TranslateAnimation : public Animation
244 TranslateAnimation ();
245 virtual ~TranslateAnimation ();
246 virtual void init (ssgEntity * object, SGPropertyNode * props);
247 virtual void update (int dt);
249 SGPropertyNode * _prop;
252 SGInterpTable * _table;
260 ssgTransform * _transform;
265 #endif // __MODEL_HXX