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/math/point3d.hxx>
21 #include <simgear/props/props.hxx>
24 // Don't pull in the headers, since we don't need them here.
28 class ssgRangeSelector;
37 // Has anyone done anything *really* stupid, like making min and max macros?
47 * Load a 3D model with or without XML wrapper.
49 * If the path ends in ".xml", then it will be used as a property-
50 * list wrapper to add animations to the model.
52 * Subsystems should not normally invoke this function directly;
53 * instead, they should use the FGModelLoader declared in loader.hxx.
55 ssgBranch * fgLoad3DModel( const string& fg_root, const string &path,
56 SGPropertyNode *prop_root,
57 double sim_time_sec );
61 //////////////////////////////////////////////////////////////////////
63 //////////////////////////////////////////////////////////////////////
66 * Abstract base class for all animations.
68 class Animation : public ssgBase
72 Animation (SGPropertyNode_ptr props, ssgBranch * branch);
74 virtual ~Animation ();
77 * Get the SSG branch holding the animation.
79 virtual ssgBranch * getBranch () { return _branch; }
82 * Initialize the animation, after children have been added.
87 * Update the animation.
89 virtual void update ();
101 class NullAnimation : public Animation
104 NullAnimation (SGPropertyNode_ptr props);
105 virtual ~NullAnimation ();
110 * A range, or level-of-detail (LOD) animation.
112 class RangeAnimation : public Animation
115 RangeAnimation (SGPropertyNode_ptr props);
116 virtual ~RangeAnimation ();
121 * Animation to turn and face the screen.
123 class BillboardAnimation : public Animation
126 BillboardAnimation (SGPropertyNode_ptr props);
127 virtual ~BillboardAnimation ();
132 * Animation to select alternative versions of the same object.
134 class SelectAnimation : public Animation
137 SelectAnimation( SGPropertyNode *prop_root,
138 SGPropertyNode_ptr props );
139 virtual ~SelectAnimation ();
140 virtual void update ();
142 FGCondition * _condition;
147 * Animation to spin an object around a center point.
149 * This animation rotates at a specific velocity.
151 class SpinAnimation : public Animation
154 SpinAnimation( SGPropertyNode *prop_root,
155 SGPropertyNode_ptr props,
156 double sim_time_sec );
157 virtual ~SpinAnimation ();
158 virtual void update( double sim_time_sec );
160 SGPropertyNode_ptr _prop;
162 double _position_deg;
163 double _last_time_sec;
171 * Animation to draw objects for a specific amount of time each.
173 class TimedAnimation : public Animation
176 TimedAnimation (SGPropertyNode_ptr props);
177 virtual ~TimedAnimation ();
178 virtual void update( double sim_time_sec );
180 double _duration_sec;
181 double _last_time_sec;
187 * Animation to rotate an object around a center point.
189 * This animation rotates to a specific position.
191 class RotateAnimation : public Animation
194 RotateAnimation( SGPropertyNode *prop_root, SGPropertyNode_ptr props );
195 virtual ~RotateAnimation ();
196 virtual void update();
198 SGPropertyNode_ptr _prop;
201 SGInterpTable * _table;
206 double _position_deg;
214 * Animation to slide along an axis.
216 class TranslateAnimation : public Animation
219 TranslateAnimation( SGPropertyNode *prop_root,
220 SGPropertyNode_ptr props );
221 virtual ~TranslateAnimation ();
222 virtual void update ();
224 SGPropertyNode_ptr _prop;
227 SGInterpTable * _table;
239 ////////////////////////////////////////////////////////////////////////
241 ////////////////////////////////////////////////////////////////////////
244 * A wrapper for a model with a definite placement.
246 class FGModelPlacement
251 virtual ~FGModelPlacement ();
253 virtual void init( const string &fg_root,
255 SGPropertyNode *prop_root,
256 double sim_time_sec );
257 virtual void update( const Point3D scenery_center );
259 virtual ssgEntity * getSceneGraph () { return (ssgEntity *)_selector; }
261 virtual FGLocation * getFGLocation () { return _location; }
263 virtual bool getVisible () const;
264 virtual void setVisible (bool visible);
266 virtual double getLongitudeDeg () const { return _lon_deg; }
267 virtual double getLatitudeDeg () const { return _lat_deg; }
268 virtual double getElevationFt () const { return _elev_ft; }
270 virtual void setLongitudeDeg (double lon_deg);
271 virtual void setLatitudeDeg (double lat_deg);
272 virtual void setElevationFt (double elev_ft);
273 virtual void setPosition (double lon_deg, double lat_deg, double elev_ft);
275 virtual double getRollDeg () const { return _roll_deg; }
276 virtual double getPitchDeg () const { return _pitch_deg; }
277 virtual double getHeadingDeg () const { return _heading_deg; }
279 virtual void setRollDeg (double roll_deg);
280 virtual void setPitchDeg (double pitch_deg);
281 virtual void setHeadingDeg (double heading_deg);
282 virtual void setOrientation (double roll_deg, double pitch_deg,
285 // Addition by Diarmuid Tyson for Multiplayer Support
286 // Allows multiplayer to get players position transform
287 virtual const sgVec4 *get_POS() { return POS; }
301 ssgSelector * _selector;
302 ssgTransform * _position;
305 FGLocation * _location;
308 // Addition by Diarmuid Tyson for Multiplayer Support
309 // Moved from update method
310 // POS for transformation Matrix
315 #endif // __MODEL_HXX