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++
21 // Don't pull in the headers, since we don't need them here.
25 class ssgRangeSelector;
35 // Has anyone done anything *really* stupid, like making min and max macros?
45 * Load a 3D model with or without XML wrapper.
47 * If the path ends in ".xml", then it will be used as a property-
48 * list wrapper to add animations to the model.
50 * Subsystems should not normally invoke this function directly;
51 * instead, they should use the FGModelLoader declared in loader.hxx.
53 ssgBranch * fgLoad3DModel (const string &path);
57 //////////////////////////////////////////////////////////////////////
59 //////////////////////////////////////////////////////////////////////
62 * Abstract base class for all animations.
64 class Animation : public ssgBase
68 Animation (SGPropertyNode_ptr props, ssgBranch * branch);
70 virtual ~Animation ();
73 * Get the SSG branch holding the animation.
75 virtual ssgBranch * getBranch () { return _branch; }
78 * Update the animation.
80 virtual void update () = 0;
92 class NullAnimation : public Animation
95 NullAnimation (SGPropertyNode_ptr props);
96 virtual ~NullAnimation ();
97 virtual void update ();
102 * A range, or level-of-detail (LOD) animation.
104 class RangeAnimation : public Animation
107 RangeAnimation (SGPropertyNode_ptr props);
108 virtual ~RangeAnimation ();
109 virtual void update ();
114 * Animation to turn and face the screen.
116 class BillboardAnimation : public Animation
119 BillboardAnimation (SGPropertyNode_ptr props);
120 virtual ~BillboardAnimation ();
121 virtual void update ();
126 * Animation to select alternative versions of the same object.
128 class SelectAnimation : public Animation
131 SelectAnimation (SGPropertyNode_ptr props);
132 virtual ~SelectAnimation ();
133 virtual void update ();
135 FGCondition * _condition;
140 * Animation to spin an object around a center point.
142 * This animation rotates at a specific velocity.
144 class SpinAnimation : public Animation
147 SpinAnimation (SGPropertyNode_ptr props);
148 virtual ~SpinAnimation ();
149 virtual void update ();
151 SGPropertyNode * _prop;
153 double _position_deg;
154 double _last_time_sec;
162 * Animation to rotate an object around a center point.
164 * This animation rotates to a specific position.
166 class RotateAnimation : public Animation
169 RotateAnimation (SGPropertyNode_ptr props);
170 virtual ~RotateAnimation ();
171 virtual void update ();
173 SGPropertyNode * _prop;
176 SGInterpTable * _table;
181 double _position_deg;
189 * Animation to slide along an axis.
191 class TranslateAnimation : public Animation
194 TranslateAnimation (SGPropertyNode_ptr props);
195 virtual ~TranslateAnimation ();
196 virtual void update ();
198 SGPropertyNode * _prop;
201 SGInterpTable * _table;
213 ////////////////////////////////////////////////////////////////////////
215 ////////////////////////////////////////////////////////////////////////
218 * A wrapper for a model with a definite placement.
220 class FGModelPlacement
225 virtual ~FGModelPlacement ();
227 virtual void init (const string &path);
228 virtual void update ();
230 virtual ssgEntity * getSceneGraph () { return (ssgEntity *)_selector; }
232 virtual FGLocation * getFGLocation () { return _location; }
234 virtual bool getVisible () const;
235 virtual void setVisible (bool visible);
237 virtual double getLongitudeDeg () const { return _lon_deg; }
238 virtual double getLatitudeDeg () const { return _lat_deg; }
239 virtual double getElevationFt () const { return _elev_ft; }
241 virtual void setLongitudeDeg (double lon_deg);
242 virtual void setLatitudeDeg (double lat_deg);
243 virtual void setElevationFt (double elev_ft);
244 virtual void setPosition (double lon_deg, double lat_deg, double elev_ft);
246 virtual double getRollDeg () const { return _roll_deg; }
247 virtual double getPitchDeg () const { return _pitch_deg; }
248 virtual double getHeadingDeg () const { return _heading_deg; }
250 virtual void setRollDeg (double roll_deg);
251 virtual void setPitchDeg (double pitch_deg);
252 virtual void setHeadingDeg (double heading_deg);
253 virtual void setOrientation (double roll_deg, double pitch_deg,
268 ssgSelector * _selector;
269 ssgTransform * _position;
272 FGLocation * _location;
276 #endif // __MODEL_HXX