globals->get_current_panel()->update(0);
}
- // Load the new 3D model
- //
- globals->get_aircraft_model()->unbind();
- delete globals->get_aircraft_model();
- globals->set_aircraft_model(new FGAircraftModel);
- globals->get_aircraft_model()->init();
- globals->get_aircraft_model()->bind();
-
+ globals->get_aircraft_model()->reinit();
+
// TODO:
// load new electrical system
//
t = fgInitTime();
globals->set_time_params( t );
- globals->get_viewmgr()->reinit();
- globals->get_controls()->reset_all();
- globals->get_aircraft_model()->reinit();
globals->get_subsystem("xml-autopilot")->reinit();
-
fgReInitSubsystems();
if ( !freeze ) {
// do nothing, fdm isn't inited yet
}
- globals->get_aircraft_model()->update(delta_time_sec);
-
// Update solar system
globals->get_ephem()->update( globals->get_time_params()->getMjd(),
globals->get_time_params()->getLst(),
SG_LOG( SG_ALL, SG_DEBUG,
"Elapsed time is zero ... we're zinging" );
}
-
+
+ globals->get_aircraft_model()->update(delta_time_sec);
globals->get_subsystem_mgr()->update(delta_time_sec);
//
// Initialize the 3D aircraft model subsystem (has a dependency on
// the scenery subsystem.)
////////////////////////////////////////////////////////////////////
- globals->set_aircraft_model(new FGAircraftModel);
- globals->get_aircraft_model()->init();
- globals->get_aircraft_model()->bind();
+ FGAircraftModel* acm = new FGAircraftModel;
+ globals->set_aircraft_model(acm);
+ //globals->add_subsystem("aircraft-model", acm);
+ acm->init();
+ acm->bind();
////////////////////////////////////////////////////////////////////
// Initialize the view manager subsystem.
FGAircraftModel::~FGAircraftModel ()
{
- osg::Node* node = _aircraft->getSceneGraph();
- globals->get_scenery()->get_aircraft_branch()->removeChild(node);
-
- delete _aircraft;
+ deinit();
}
void
globals->get_scenery()->get_aircraft_branch()->addChild(node);
}
+void
+FGAircraftModel::reinit()
+{
+ deinit();
+ 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 ()
{
#ifndef __ACMODEL_HXX
#define __ACMODEL_HXX 1
-#ifndef __cplusplus
-# error This library requires C++
-#endif
-
-#include <vector>
-#include <string>
-
-using std::string;
-using std::vector;
-
#include <osg/ref_ptr>
#include <osg/Group>
#include <osg/Switch>
virtual ~FGAircraftModel ();
virtual void init ();
+ virtual void reinit ();
virtual void bind ();
virtual void unbind ();
virtual void update (double dt);
virtual SGVec3d& getVelocity() { return _velocity; }
private:
-
+ void deinit ();
+
SGModelPlacement * _aircraft;
SGVec3d _velocity;
SGSharedPtr<FGFX> _fx;