SG_LOG(SG_AUTOPILOT, SG_INFO, "loaded initial waypoints:" << _route.size());
}
- weightOnWheels = fgGetNode("/gear/gear[0]/wow", false);
+ weightOnWheels = fgGetNode("/gear/gear[0]/wow", true);
// check airbone flag agrees with presets
}
double sPitch = sin(pitch), cPitch = cos(pitch),
sYaw = sin(yaw), cYaw = cos(yaw);
- //Assuming that the "Cockpit View" is always at position zero!!!
- if (curr_view_id != 0) {
- globals->get_viewmgr()->set_view(0);
- globals->get_viewmgr()->copyToCurrent();
- }
//Set the camera to the cockpit view to get the view of the runway from the cockpit
// OSGFIXME
// ssgSetCamera((sgVec4 *)cockpit_view->get_VIEW());
drawArrow(); //draw indication arrow
}
- //Restore the current view and any offsets
- if (curr_view_id != 0) {
- globals->get_viewmgr()->set_view(curr_view_id);
- globals->get_viewmgr()->copyToCurrent();
- curr_view->setHeadingOffset_deg(ho);
- curr_view->setPitchOffset_deg(po);
- curr_view->setGoalHeadingOffset_deg(gho);
- curr_view->setGoalPitchOffset_deg(gpo);
- }
//Set the camera back to the current view
// OSGFIXME
// ssgSetCamera((sgVec4 *)curr_view);
double sPitch = sin(pitch), cPitch = cos(pitch),
sYaw = sin(yaw), cYaw = cos(yaw);
- //Assuming that the "Cockpit View" is always at position zero!!!
- if (curr_view_id != 0) {
- globals->get_viewmgr()->set_view(0);
- globals->get_viewmgr()->copyToCurrent();
- }
//Set the camera to the cockpit view to get the view of the runway from the cockpit
// OSGFIXME
// ssgSetCamera((sgVec4 *)_cockpit_view->get_VIEW());
drawArrow(); //draw indication arrow
}
- //Restore the current view and any offsets
- if (curr_view_id != 0) {
- globals->get_viewmgr()->set_view(curr_view_id);
- globals->get_viewmgr()->copyToCurrent();
- curr_view->setHeadingOffset_deg(ho);
- curr_view->setPitchOffset_deg(po);
- curr_view->setGoalHeadingOffset_deg(gho);
- curr_view->setGoalPitchOffset_deg(gpo);
- }
//Set the camera back to the current view
// OSGFIXME
// ssgSetCamera((sgVec4 *)curr_view);
#include <Input/input.hxx>
#include <Instrumentation/instrument_mgr.hxx>
#include <Model/acmodel.hxx>
+#include <Model/modelmgr.hxx>
#include <AIModel/submodel.hxx>
#include <AIModel/AIManager.hxx>
#include <Navaids/navdb.hxx>
// Initialize the scenery management subsystem.
////////////////////////////////////////////////////////////////////
- globals->add_subsystem("tile-manager", globals->get_tile_mgr(),
- SGSubsystemMgr::DISPLAY);
-
globals->get_scenery()->get_scene_graph()
->addChild(simgear::Particles::getCommonRoot());
simgear::GlobalParticleCallback::setSwitch(fgGetNode("/sim/rendering/particles", true));
globals->add_subsystem("gui", new NewGUI, SGSubsystemMgr::INIT);
- ////////////////////////////////////////////////////////////////////
- // Initialize the lighting subsystem.
- ////////////////////////////////////////////////////////////////////
-
- globals->add_subsystem("lighting", new FGLight, SGSubsystemMgr::DISPLAY);
-
//////////////////////////////////////////////////////////////////////
// Initialize the 2D cloud subsystem.
////////////////////////////////////////////////////////////////////
fgGetBool("/sim/rendering/bump-mapping", false);
-#ifdef ENABLE_AUDIO_SUPPORT
- ////////////////////////////////////////////////////////////////////
- // Initialize the sound-effects subsystem.
- ////////////////////////////////////////////////////////////////////
- globals->add_subsystem("voice", new FGVoiceMgr, SGSubsystemMgr::DISPLAY);
-#endif
+
////////////////////////////////////////////////////////////////////
// Initialise the ATC Manager
////////////////////////////////////////////////////////////////////
globals->add_subsystem("replay", new FGReplay);
+#ifdef ENABLE_AUDIO_SUPPORT
+ ////////////////////////////////////////////////////////////////////
+ // Initialize the sound-effects subsystem.
+ ////////////////////////////////////////////////////////////////////
+ globals->add_subsystem("voice", new FGVoiceMgr, SGSubsystemMgr::DISPLAY);
+#endif
+ ////////////////////////////////////////////////////////////////////
+ // Initialize the lighting subsystem.
+ ////////////////////////////////////////////////////////////////////
+
+ globals->add_subsystem("lighting", new FGLight, SGSubsystemMgr::DISPLAY);
+
+ // ordering here is important : Nasal (via events), then models, then views
+ globals->add_subsystem("events", globals->get_event_mgr(), SGSubsystemMgr::DISPLAY);
+
+ FGAircraftModel* acm = new FGAircraftModel;
+ globals->set_aircraft_model(acm);
+ globals->add_subsystem("aircraft-model", acm, SGSubsystemMgr::DISPLAY);
+
+ FGModelMgr* mm = new FGModelMgr;
+ globals->set_model_mgr(mm);
+ globals->add_subsystem("model-manager", mm, SGSubsystemMgr::DISPLAY);
+
+ FGViewMgr *viewmgr = new FGViewMgr;
+ globals->set_viewmgr( viewmgr );
+ globals->add_subsystem("view-manager", viewmgr, SGSubsystemMgr::DISPLAY);
+
+ globals->add_subsystem("tile-manager", globals->get_tile_mgr(),
+ SGSubsystemMgr::DISPLAY);
+
////////////////////////////////////////////////////////////////////
// Bind and initialize subsystems.
////////////////////////////////////////////////////////////////////
subsystem_mgr->unbind();
delete subsystem_mgr;
- delete event_mgr;
delete time_params;
delete mag;
delete ATC_mgr;
delete controls;
- delete viewmgr;
-// delete commands;
- delete model_mgr;
delete channel_options_list;
delete initial_waypoints;
delete scenery;
#include <Cockpit/cockpit.hxx>
#include <Cockpit/hud.hxx>
#include <Model/panelnode.hxx>
-#include <Model/modelmgr.hxx>
#include <Model/acmodel.hxx>
#include <Scenery/scenery.hxx>
#include <Scenery/tilemgr.hxx>
globals->get_subsystem_mgr()->update(sim_dt);
- // run Nasal's settimer() loops right before the view manager
- globals->get_event_mgr()->update(sim_dt);
-
- // pick up model coordidnates that Nasal code may have set relative to the
- // aircraft's
- globals->get_model_mgr()->update(sim_dt);
-
- // update the view angle as late as possible, but before sound calculations
- globals->get_viewmgr()->update(real_dt);
-
// Update the sound manager last so it can use the CPU while the GPU
// is processing the scenery (doubled the frame-rate for me) -EMH-
#ifdef ENABLE_AUDIO_SUPPORT
globals->set_tile_mgr( new FGTileMgr );
- ////////////////////////////////////////////////////////////////////
- // Initialize the general model subsystem.
- ////////////////////////////////////////////////////////////////////
- globals->set_model_mgr(new FGModelMgr);
- globals->get_model_mgr()->init();
- globals->get_model_mgr()->bind();
fgSplashProgress("loading aircraft");
} else if ( idle_state == 5 ) {
idle_state++;
- ////////////////////////////////////////////////////////////////////
- // Initialize the 3D aircraft model subsystem (has a dependency on
- // the scenery subsystem.)
- ////////////////////////////////////////////////////////////////////
- FGAircraftModel* acm = new FGAircraftModel;
- globals->set_aircraft_model(acm);
- globals->add_subsystem("aircraft-model", acm, SGSubsystemMgr::DISPLAY);
-
- ////////////////////////////////////////////////////////////////////
- // Initialize the view manager subsystem.
- ////////////////////////////////////////////////////////////////////
- FGViewMgr *viewmgr = new FGViewMgr;
- globals->set_viewmgr( viewmgr );
- viewmgr->init();
- viewmgr->bind();
fgSplashProgress("generating sky elements");
FGViewMgr::FGViewMgr( void ) :
axis_long(0),
axis_lat(0),
+ inited(false),
view_number(fgGetNode("/sim/current-view/view-number", true)),
config_list(fgGetNode("/sim", true)->getChildren("view")),
current(0)
void
FGViewMgr::init ()
{
+ if (inited) {
+ SG_LOG(SG_GENERAL, SG_WARN, "duplicate init of view manager");
+ return;
+ }
+
+ inited = true;
+
double aspect_ratio_multiplier
= fgGetDouble("/sim/current-view/aspect-ratio-multiplier");
}
copyToCurrent();
+ do_bind();
}
void
typedef double (FGViewMgr::*double_getter)() const;
void
-FGViewMgr::bind ()
+FGViewMgr::bind()
+{
+ // view-manager code was designed to init before bind, so
+ // this is a no-op; init() calls the real bind() impl below
+}
+
+void
+FGViewMgr::do_bind()
{
// these are bound to the current view properties
fgTie("/sim/current-view/heading-offset-deg", this,
void
FGViewMgr::copyToCurrent()
{
+ if (!inited) {
+ return;
+ }
+
SGPropertyNode *n = config_list[current];
fgSetString("/sim/current-view/name", n->getStringValue("name"));
fgSetString("/sim/current-view/type", n->getStringValue("type"));
newview = 0;
// set new view
- set_view(newview);
+ current = newview;
// copy in view data
copyToCurrent();
-
- // Copy the fdm's position into the SGLocation which is shared with
- // some views ...
- globals->get_aircraft_model()->update(0);
- // Do the update ...
- update(0);
}
void
FGViewMgr::setARM_deg (double aspect_ratio_multiplier)
-{
+{
FGViewer * view = get_current_view();
if (view != 0)
view->set_aspect_ratio_multiplier(aspect_ratio_multiplier);
// setters
void clear();
- inline void set_view( const int v ) { current = v; }
+
void add_view( FGViewer * v );
- // copies current offset settings to current-view path...
- void copyToCurrent ();
-
private:
-
+ void do_bind();
+
list<const char*> tied_props;
double axis_long;
bool stationary () const;
+ // copies current offset settings to current-view path...
+ void copyToCurrent ();
+
+ bool inited;
SGPropertyNode_ptr view_number;
vector<SGPropertyNode_ptr> config_list;
typedef std::vector<FGViewerPtr> viewer_list;