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 #include <simgear/misc/props.hxx>
23 // Don't pull in the headers, since we don't need them here.
27 class ssgRangeSelector;
36 // Has anyone done anything *really* stupid, like making min and max macros?
46 * Load a 3D model with or without XML wrapper.
48 * If the path ends in ".xml", then it will be used as a property-
49 * list wrapper to add animations to the model.
51 * Subsystems should not normally invoke this function directly;
52 * instead, they should use the FGModelLoader declared in loader.hxx.
54 ssgBranch * fgLoad3DModel (const string &path);
58 //////////////////////////////////////////////////////////////////////
60 //////////////////////////////////////////////////////////////////////
63 * Abstract base class for all animations.
65 class Animation : public ssgBase
69 Animation (SGPropertyNode_ptr props, ssgBranch * branch);
71 virtual ~Animation ();
74 * Get the SSG branch holding the animation.
76 virtual ssgBranch * getBranch () { return _branch; }
79 * Initialize the animation, after children have been added.
84 * Update the animation.
86 virtual void update ();
98 class NullAnimation : public Animation
101 NullAnimation (SGPropertyNode_ptr props);
102 virtual ~NullAnimation ();
107 * A range, or level-of-detail (LOD) animation.
109 class RangeAnimation : public Animation
112 RangeAnimation (SGPropertyNode_ptr props);
113 virtual ~RangeAnimation ();
118 * Animation to turn and face the screen.
120 class BillboardAnimation : public Animation
123 BillboardAnimation (SGPropertyNode_ptr props);
124 virtual ~BillboardAnimation ();
129 * Animation to select alternative versions of the same object.
131 class SelectAnimation : public Animation
134 SelectAnimation (SGPropertyNode_ptr props);
135 virtual ~SelectAnimation ();
136 virtual void update ();
138 FGCondition * _condition;
143 * Animation to spin an object around a center point.
145 * This animation rotates at a specific velocity.
147 class SpinAnimation : public Animation
150 SpinAnimation (SGPropertyNode_ptr props);
151 virtual ~SpinAnimation ();
152 virtual void update ();
154 SGPropertyNode_ptr _prop;
156 double _position_deg;
157 double _last_time_sec;
165 * Animation to draw objects for a specific amount of time each.
167 class TimedAnimation : public Animation
170 TimedAnimation (SGPropertyNode_ptr props);
171 virtual ~TimedAnimation ();
172 virtual void update ();
174 double _duration_sec;
175 double _last_time_sec;
181 * Animation to rotate an object around a center point.
183 * This animation rotates to a specific position.
185 class RotateAnimation : public Animation
188 RotateAnimation (SGPropertyNode_ptr props);
189 virtual ~RotateAnimation ();
190 virtual void update ();
192 SGPropertyNode_ptr _prop;
195 SGInterpTable * _table;
200 double _position_deg;
208 * Animation to slide along an axis.
210 class TranslateAnimation : public Animation
213 TranslateAnimation (SGPropertyNode_ptr props);
214 virtual ~TranslateAnimation ();
215 virtual void update ();
217 SGPropertyNode_ptr _prop;
220 SGInterpTable * _table;
232 ////////////////////////////////////////////////////////////////////////
234 ////////////////////////////////////////////////////////////////////////
237 * A wrapper for a model with a definite placement.
239 class FGModelPlacement
244 virtual ~FGModelPlacement ();
246 virtual void init (const string &path);
247 virtual void update ();
249 virtual ssgEntity * getSceneGraph () { return (ssgEntity *)_selector; }
251 virtual FGLocation * getFGLocation () { return _location; }
253 virtual bool getVisible () const;
254 virtual void setVisible (bool visible);
256 virtual double getLongitudeDeg () const { return _lon_deg; }
257 virtual double getLatitudeDeg () const { return _lat_deg; }
258 virtual double getElevationFt () const { return _elev_ft; }
260 virtual void setLongitudeDeg (double lon_deg);
261 virtual void setLatitudeDeg (double lat_deg);
262 virtual void setElevationFt (double elev_ft);
263 virtual void setPosition (double lon_deg, double lat_deg, double elev_ft);
265 virtual double getRollDeg () const { return _roll_deg; }
266 virtual double getPitchDeg () const { return _pitch_deg; }
267 virtual double getHeadingDeg () const { return _heading_deg; }
269 virtual void setRollDeg (double roll_deg);
270 virtual void setPitchDeg (double pitch_deg);
271 virtual void setHeadingDeg (double heading_deg);
272 virtual void setOrientation (double roll_deg, double pitch_deg,
275 // Addition by Diarmuid Tyson for Multiplayer Support
276 // Allows multiplayer to get players position transform
277 virtual const sgVec4 *get_POS() { return POS; }
291 ssgSelector * _selector;
292 ssgTransform * _position;
295 FGLocation * _location;
298 // Addition by Diarmuid Tyson for Multiplayer Support
299 // Moved from update method
300 // POS for transformation Matrix
305 #endif // __MODEL_HXX