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 setPosition (double lon_deg, double lat_deg, double elev_ft);
48 virtual double getRoll () const { return _roll_deg; }
49 virtual double getPitch () const { return _pitch_deg; }
50 virtual double getHeading () const { return _heading_deg; }
52 virtual void setOrientation (double roll_deg, double pitch_deg,
55 virtual ssgEntity * getSceneGraph () const { return _selector; }
57 virtual FGLocation * getFGLocation () const { return _location; }
62 Animation * make_animation (const char * object_name, SGPropertyNode * node);
76 vector <Animation *> _animations;
81 ssgSelector * _selector;
82 ssgTransform * _position;
85 FGLocation * _location;
88 //////////////////////////////////////////////////////////////////////
89 // Internal classes for individual animations.
90 //////////////////////////////////////////////////////////////////////
93 * Abstract base class for all animations.
101 virtual ~Animation ();
104 * Initialize the animation.
106 * @param object The object to animate.
107 * @param props The property node with configuration information.
109 virtual void init (ssgEntity * object, SGPropertyNode * props) = 0;
113 * Update the animation.
115 * @param dt The elapsed time in milliseconds since the last call.
117 virtual void update (int dt) = 0;
125 class NullAnimation : public Animation
129 virtual ~NullAnimation ();
130 virtual void init (ssgEntity * object, SGPropertyNode * props);
131 virtual void update (int dt);
138 * Animation to select alternative versions of the same object.
140 class SelectAnimation : public Animation
144 virtual ~SelectAnimation ();
145 virtual void init (ssgEntity * object, SGPropertyNode * props);
146 virtual void update (int dt);
148 FGCondition * _condition;
149 ssgSelector * _selector;
154 * Animation to spin an object around a center point.
156 * This animation rotates at a specific velocity.
158 class SpinAnimation : public Animation
162 virtual ~SpinAnimation ();
163 virtual void init (ssgEntity * object, SGPropertyNode * props);
164 virtual void update (int dt);
166 SGPropertyNode * _prop;
168 double _position_deg;
172 ssgTransform * _transform;
177 * Animation to rotate an object around a center point.
179 * This animation rotates to a specific position.
181 class RotateAnimation : public Animation
185 virtual ~RotateAnimation ();
186 virtual void init (ssgEntity * object, SGPropertyNode * props);
187 virtual void update (int dt);
189 SGPropertyNode * _prop;
196 double _position_deg;
200 ssgTransform * _transform;
205 * Animation to slide along an axis.
207 class TranslateAnimation : public Animation
210 TranslateAnimation ();
211 virtual ~TranslateAnimation ();
212 virtual void init (ssgEntity * object, SGPropertyNode * props);
213 virtual void update (int dt);
215 SGPropertyNode * _prop;
225 ssgTransform * _transform;
230 #endif // __MODEL_HXX