]> 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 b639560a00873868a1511077a41aef16ff9fa84f..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>
@@ -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 ) {
@@ -641,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() {
@@ -648,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");
+  
 }
 
 
@@ -740,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.
     ////////////////////////////////////////////////////////////////////
 
-    globals->get_scenery()->init();
-    globals->get_scenery()->bind();
-
     if ( global_tile_mgr.init() ) {
        // Load the local scenery data
        double visibility_meters = fgGetDouble("/environment/visibility-m");
@@ -760,6 +788,11 @@ 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 " <<
            globals->get_scenery()->get_cur_elev() );
@@ -783,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.
     ////////////////////////////////////////////////////////////////////
@@ -888,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
     ////////////////////////////////////////////////////////////////////
@@ -985,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.
     ////////////////////////////////////////////////////////////////////
@@ -1027,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",
@@ -1060,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.
     ////////////////////////////////////////////////////////////////////
@@ -1094,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 ) {