]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/fg_init.cxx
Added static port system and a new altimeter model connected to it.
[flightgear.git] / src / Main / fg_init.cxx
index 229fe271895bd7783cd5b6d139febc582aaac27f..b5c3f1afe35d28129909201e2a5af0535e02e161 100644 (file)
@@ -63,6 +63,8 @@
 #include <simgear/math/polar3d.hxx>
 #include <simgear/math/sg_geodesy.hxx>
 #include <simgear/misc/sg_path.hxx>
+#include <simgear/sky/clouds3d/SkySceneLoader.hpp>
+#include <simgear/sky/clouds3d/SkyUtil.hpp>
 #include <simgear/timing/sg_time.hxx>
 #include <simgear/timing/lowleveltime.h>
 
@@ -80,6 +82,7 @@
 #include <Autopilot/newauto.hxx>
 #include <Cockpit/cockpit.hxx>
 #include <Cockpit/radiostack.hxx>
+#include <Cockpit/steam.hxx>
 #include <Cockpit/panel.hxx>
 #include <Cockpit/panel_io.hxx>
 #include <FDM/ADA.hxx>
@@ -94,6 +97,7 @@
 #include <FDM/YASim/YASim.hxx>
 #include <Include/general.hxx>
 #include <Input/input.hxx>
+#include <Instrumentation/instrument_mgr.hxx>
 // #include <Joystick/joystick.hxx>
 #include <Objects/matlib.hxx>
 #include <Model/acmodel.hxx>
 #include <Scenery/tilemgr.hxx>
 #include <Sound/fg_fx.hxx>
 #include <Sound/soundmgr.hxx>
+#include <Systems/system_mgr.hxx>
 #include <Time/FGEventMgr.hxx>
 #include <Time/light.hxx>
 #include <Time/sunpos.hxx>
 #include <Time/moonpos.hxx>
 #include <Time/tmp.hxx>
 
-#ifndef FG_NEW_ENVIRONMENT
+#ifdef FG_WEATHERCM
 #  include <WeatherCM/FGLocalWeatherDatabase.h>
 #else
 #  include <Environment/environment_mgr.hxx>
@@ -134,6 +139,7 @@ SG_USING_STD(string);
 
 extern const char *default_root;
 
+SkySceneLoader *sgCloud3d;
 
 // Read in configuration (file and command line) and just set fg_root
 bool fgInitFGRoot ( int argc, char **argv ) {
@@ -493,6 +499,7 @@ bool fgSetPosFromAirportIDandHdg( const string& id, double tgt_hdg ) {
     return true;
 }
 
+
 void fgSetPosFromGlideSlope(void) {
     double gs = fgGetDouble("/velocities/glideslope");
     double od = fgGetDouble("/sim/startup/offset-distance");
@@ -591,7 +598,7 @@ void fgInitFDM() {
            cur_fdm_state = new FGUFO( dt );
        } else if ( model == "external" ) {
            cur_fdm_state = new FGExternal( dt );
-       } else if ( model.find("network,") == 0 ) {
+       } else if ( model.find("network") == 0 ) {
             string host = "localhost";
             int port1 = 5501;
             int port2 = 5502;
@@ -640,6 +647,15 @@ void fgInitFDM() {
     }
 }
 
+static void printMat(const sgVec4 *mat, char *name="")
+{
+    int i;
+    cout << name << endl;
+    for(i=0; i<4; i++) {
+        cout <<"  "<<mat[i][0]<<" "<<mat[i][1]<<" "<<mat[i][2]<<" "<<mat[i][3]<<endl;
+    }
+    cout << endl;
+}
 
 // Initialize view parameters
 void fgInitView() {
@@ -647,6 +663,11 @@ void fgInitView() {
   globals->get_aircraft_model()->update(0);
   // run update for current view so that data is current...
   globals->get_viewmgr()->update(0);
+
+  printMat(globals->get_current_view()->get_VIEW(),"VIEW");
+  printMat(globals->get_current_view()->get_UP(),"UP");
+  // printMat(globals->get_current_view()->get_LOCAL(),"LOCAL");
+  
 }
 
 
@@ -739,14 +760,22 @@ bool fgInitSubsystems( void ) {
        exit(-1);
     }
 
+    ////////////////////////////////////////////////////////////////////
+    // Initialize the event manager subsystem.
+    ////////////////////////////////////////////////////////////////////
+
+    global_events.init();
+
+    // Output event stats every 60 seconds
+    global_events.Register( "FGEventMgr::print_stats()",
+                           &global_events, &FGEventMgr::print_stats,
+                           60000 );
+
 
     ////////////////////////////////////////////////////////////////////
     // Initialize the scenery management subsystem.
     ////////////////////////////////////////////////////////////////////
 
-    scenery.init();
-    scenery.bind();
-
     if ( global_tile_mgr.init() ) {
        // Load the local scenery data
        double visibility_meters = fgGetDouble("/environment/visibility-m");
@@ -759,9 +788,14 @@ bool fgInitSubsystems( void ) {
        exit(-1);
     }
 
+    // cause refresh of viewer scenery timestamps every 15 seconds...
+    global_events.Register( "FGTileMgr::refresh_view_timestamps()",
+                           &global_tile_mgr, &FGTileMgr::refresh_view_timestamps,
+                           15000 );
+
     SG_LOG( SG_GENERAL, SG_DEBUG,
            "Current terrain elevation after tile mgr init " <<
-           scenery.get_cur_elev() );
+           globals->get_scenery()->get_cur_elev() );
 
 
     ////////////////////////////////////////////////////////////////////
@@ -782,18 +816,6 @@ bool fgInitSubsystems( void ) {
     fgInitView();
 
 
-    ////////////////////////////////////////////////////////////////////
-    // Initialize the event manager subsystem.
-    ////////////////////////////////////////////////////////////////////
-
-    global_events.init();
-
-    // Output event stats every 60 seconds
-    global_events.Register( "FGEventMgr::print_stats()",
-                           &global_events, &FGEventMgr::print_stats,
-                           60000 );
-
-
     ////////////////////////////////////////////////////////////////////
     // Initialize the lighting subsystem.
     ////////////////////////////////////////////////////////////////////
@@ -842,7 +864,7 @@ bool fgInitSubsystems( void ) {
     ////////////////////////////////////////////////////////////////////
 
     // Initialize the weather modeling subsystem
-#ifndef FG_NEW_ENVIRONMENT
+#ifdef FG_WEATHERCM
     // Initialize the WeatherDatabase
     SG_LOG(SG_GENERAL, SG_INFO, "Creating LocalWeatherDatabase");
     sgVec3 position;
@@ -887,6 +909,20 @@ bool fgInitSubsystems( void ) {
     globals->get_environment_mgr()->bind();
 #endif
 
+    ////////////////////////////////////////////////////////////////////
+    // Initialize the 3D cloud subsystem.
+    ////////////////////////////////////////////////////////////////////
+    if ( fgGetBool("/sim/rendering/clouds3d") ) {
+        SGPath cloud_path(globals->get_fg_root());
+        cloud_path.append("large.sky");
+        SG_LOG(SG_GENERAL, SG_INFO, "Loading CLOUDS3d from: " << cloud_path.c_str());
+        if ( !sgCloud3d->Load( cloud_path.str() ) ) {
+            fgSetBool("/sim/rendering/clouds3d", false);
+            SG_LOG(SG_GENERAL, SG_INFO, "CLOUDS3d FAILED: ");
+        }
+        SG_LOG(SG_GENERAL, SG_INFO, "CLOUDS3d Loaded: ");
+    }
+
     ////////////////////////////////////////////////////////////////////
     // Initialize vor/ndb/ils/fix list management and query systems
     ////////////////////////////////////////////////////////////////////
@@ -984,6 +1020,18 @@ bool fgInitSubsystems( void ) {
 
 #endif
 
+    ////////////////////////////////////////////////////////////////////
+    // Initialize the aircraft systems.
+    ////////////////////////////////////////////////////////////////////
+    globals->get_systemmgr()->init();
+    globals->get_systemmgr()->bind();
+
+    ////////////////////////////////////////////////////////////////////
+    // Initialize the instrumentation.
+    ////////////////////////////////////////////////////////////////////
+    globals->get_instrumentmgr()->init();
+    globals->get_instrumentmgr()->bind();
+
     ////////////////////////////////////////////////////////////////////
     // Initialize the radio stack subsystem.
     ////////////////////////////////////////////////////////////////////
@@ -1026,9 +1074,8 @@ bool fgInitSubsystems( void ) {
     // Initialize I/O subsystem.
     ////////////////////////////////////////////////////////////////////
 
-#if ! defined( macintosh )
-    fgIOInit();
-#endif
+    globals->get_io()->init();
+    globals->get_io()->bind();
 
     // Initialize the 2D panel.
     string panel_path = fgGetString("/sim/panel/path",
@@ -1059,6 +1106,14 @@ bool fgInitSubsystems( void ) {
     globals->get_controls()->bind();
 
 
+    ////////////////////////////////////////////////////////////////////
+    // Initialize the steam subsystem.
+    ////////////////////////////////////////////////////////////////////
+
+    globals->get_steam()->init();
+    globals->get_steam()->bind();
+
+
     ////////////////////////////////////////////////////////////////////
     // Initialize the input subsystem.
     ////////////////////////////////////////////////////////////////////
@@ -1093,7 +1148,8 @@ void fgReInitSubsystems( void )
        = fgGetNode("/sim/freeze/master");
 
     SG_LOG( SG_GENERAL, SG_INFO,
-           "/position/altitude = " << altitude->getDoubleValue() );
+           "fgReInitSubsystems(): /position/altitude = "
+            << altitude->getDoubleValue() );
 
     bool freeze = master_freeze->getBoolValue();
     if ( !freeze ) {
@@ -1101,18 +1157,9 @@ void fgReInitSubsystems( void )
     }
     
     // Initialize the Scenery Management subsystem
-    scenery.init();
-
-#if 0
-    if( global_tile_mgr.init() ) {
-       Load the local scenery data
-       global_tile_mgr.update( longitude->getDoubleValue(),
-                               latitude->getDoubleValue() );
-    } else {
-       SG_LOG( SG_GENERAL, SG_ALERT, "Error in Tile Manager initialization!" );
-        exit(-1);
-    }
-#endif
+    // FIXME, what really needs to get initialized here, at the time
+    // this was commented out, scenery.init() was a noop
+    // scenery.init();
 
     fgInitFDM();