-// model.cxx - manage a 3D aircraft model.
+// acmodel.cxx - manage a 3D aircraft model.
// Written by David Megginson, started 2002.
//
// This file is in the Public Domain, and comes with no warranty.
FGAircraftModel::~FGAircraftModel ()
{
- osg::Node* node = _aircraft->getSceneGraph();
- globals->get_scenery()->get_aircraft_branch()->removeChild(node);
-
- delete _aircraft;
+ // drop reference
+ _fx = 0;
+ deinit();
}
void
osg::Node *model = fgLoad3DModelPanel( path, globals->get_props());
_aircraft->init( model );
} catch (const sg_exception &ex) {
- SG_LOG(SG_GENERAL, SG_ALERT, "Failed to load aircraft from " << path << ':');
- SG_LOG(SG_GENERAL, SG_ALERT, " " << ex.getFormattedMessage());
- SG_LOG(SG_GENERAL, SG_ALERT, "(Falling back to glider.ac.)");
+ SG_LOG(SG_AIRCRAFT, SG_ALERT, "Failed to load aircraft from " << path << ':');
+ SG_LOG(SG_AIRCRAFT, SG_ALERT, " " << ex.getFormattedMessage());
+ SG_LOG(SG_AIRCRAFT, SG_ALERT, "(Falling back to glider.ac.)");
osg::Node *model = fgLoad3DModelPanel( "Models/Geometry/glider.ac",
globals->get_props());
_aircraft->init( model );
globals->get_scenery()->get_aircraft_branch()->addChild(node);
}
+void
+FGAircraftModel::reinit()
+{
+ deinit();
+ _fx->reinit();
+ init();
+}
+
+void
+FGAircraftModel::deinit()
+{
+ if (!_aircraft) {
+ return;
+ }
+
+ osg::Node* node = _aircraft->getSceneGraph();
+ globals->get_scenery()->get_aircraft_branch()->removeChild(node);
+
+ delete _aircraft;
+ _aircraft = NULL;
+}
+
void
FGAircraftModel::bind ()
{
_roll->getDoubleValue());
_fx->set_orientation( orient );
- SGVec3d vel = SGVec3d( _speed_n->getFloatValue(),
- _speed_e->getFloatValue(),
- _speed_d->getFloatValue() );
- if ( vel[0] || vel[1] || vel[2] ) {
- SGQuatd hlOr = SGQuatd::fromLonLat(position);
- _velocity = 100.0 * toVec3f( hlOr.rotateBack( vel * SG_FEET_TO_METER ) );
- }
- else
- _velocity = SGVec3f::zeros();
+ _velocity = SGVec3d( _speed_n->getDoubleValue(),
+ _speed_e->getDoubleValue(),
+ _speed_d->getDoubleValue() );
_fx->set_velocity( _velocity );
}