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++
18 #include <Main/fg_props.hxx>
19 #include <Main/location.hxx>
21 // Has anyone done anything *really* stupid, like making min and max macros?
34 virtual ~FG3DModel ();
36 virtual void init (const string &path);
37 virtual void update (int dt);
39 virtual bool getVisible () const;
40 virtual void setVisible (bool visible);
42 virtual double getLongitudeDeg () const { return _lon_deg; }
43 virtual double getLatitudeDeg () const { return _lat_deg; }
44 virtual double getElevationFt () const { return _elev_ft; }
46 virtual void setLongitudeDeg (double lon_deg);
47 virtual void setLatitudeDeg (double lat_deg);
48 virtual void setElevationFt (double elev_ft);
49 virtual void setPosition (double lon_deg, double lat_deg, double elev_ft);
51 virtual double getRollDeg () const { return _roll_deg; }
52 virtual double getPitchDeg () const { return _pitch_deg; }
53 virtual double getHeadingDeg () const { return _heading_deg; }
55 virtual void setRollDeg (double roll_deg);
56 virtual void setPitchDeg (double pitch_deg);
57 virtual void setHeadingDeg (double heading_deg);
58 virtual void setOrientation (double roll_deg, double pitch_deg,
61 virtual ssgEntity * getSceneGraph () const { return _selector; }
63 virtual FGLocation * getFGLocation () const { return _location; }
68 Animation * make_animation (const char * object_name, SGPropertyNode * node);
82 vector <Animation *> _animations;
87 ssgSelector * _selector;
88 ssgTransform * _position;
91 FGLocation * _location;
94 //////////////////////////////////////////////////////////////////////
95 // Internal classes for individual animations.
96 //////////////////////////////////////////////////////////////////////
99 * Abstract base class for all animations.
107 virtual ~Animation ();
110 * Initialize the animation.
112 * @param object The object to animate.
113 * @param props The property node with configuration information.
115 virtual void init (ssgEntity * object, SGPropertyNode * props) = 0;
119 * Update the animation.
121 * @param dt The elapsed time in milliseconds since the last call.
123 virtual void update (int dt) = 0;
131 class NullAnimation : public Animation
135 virtual ~NullAnimation ();
136 virtual void init (ssgEntity * object, SGPropertyNode * props);
137 virtual void update (int dt);
144 * Animation to select alternative versions of the same object.
146 class SelectAnimation : public Animation
150 virtual ~SelectAnimation ();
151 virtual void init (ssgEntity * object, SGPropertyNode * props);
152 virtual void update (int dt);
154 FGCondition * _condition;
155 ssgSelector * _selector;
160 * Animation to spin an object around a center point.
162 * This animation rotates at a specific velocity.
164 class SpinAnimation : public Animation
168 virtual ~SpinAnimation ();
169 virtual void init (ssgEntity * object, SGPropertyNode * props);
170 virtual void update (int dt);
172 SGPropertyNode * _prop;
174 double _position_deg;
178 ssgTransform * _transform;
183 * Animation to rotate an object around a center point.
185 * This animation rotates to a specific position.
187 class RotateAnimation : public Animation
191 virtual ~RotateAnimation ();
192 virtual void init (ssgEntity * object, SGPropertyNode * props);
193 virtual void update (int dt);
195 SGPropertyNode * _prop;
202 double _position_deg;
206 ssgTransform * _transform;
211 * Animation to slide along an axis.
213 class TranslateAnimation : public Animation
216 TranslateAnimation ();
217 virtual ~TranslateAnimation ();
218 virtual void init (ssgEntity * object, SGPropertyNode * props);
219 virtual void update (int dt);
221 SGPropertyNode * _prop;
231 ssgTransform * _transform;
236 #endif // __MODEL_HXX