]> git.mxchange.org Git - flightgear.git/blobdiff - src/Environment/environment_mgr.cxx
Torsten DREYER:
[flightgear.git] / src / Environment / environment_mgr.cxx
index 08984463a015017c2f6f041a4b7321459836823a..b029316e1a597728b4774046f47708e6668a7b06 100644 (file)
 //
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //
 // $Id$
 
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
 #include <simgear/debug/logstream.hxx>
 #include <simgear/scene/sky/sky.hxx>
+#include <simgear/environment/visual_enviro.hxx>
 
 #include <Main/main.hxx>
 #include <Main/fg_props.hxx>
 #include "environment.hxx"
 #include "environment_ctrl.hxx"
 #include "environment_mgr.hxx"
+#include "fgclouds.hxx"
+
+class SGSky;
+extern SGSky *thesky;
+
 
 
 FGEnvironmentMgr::FGEnvironmentMgr ()
-  : _environment(new FGEnvironment),
-    _controller(new FGInterpolateEnvironmentCtrl)
+  : _environment(new FGEnvironment)
 {
+
+   if (fgGetBool("/environment/params/real-world-weather-fetch") == true)
+       _controller = new FGMetarEnvironmentCtrl;
+   else
+       _controller = new FGInterpolateEnvironmentCtrl;
+
   _controller->setEnvironment(_environment);
   set_subsystem("controller", _controller, 0.5);
+  fgClouds = new FGClouds( _controller );
 }
 
 FGEnvironmentMgr::~FGEnvironmentMgr ()
 {
   delete _environment;
+  remove_subsystem("controller");
   delete _controller;
+  delete fgClouds;
 }
 
 void
@@ -68,12 +86,16 @@ FGEnvironmentMgr::bind ()
   fgTie("/environment/visibility-m", _environment,
        &FGEnvironment::get_visibility_m, &FGEnvironment::set_visibility_m);
   fgSetArchivable("/environment/visibility-m");
+  fgTie("/environment/effective-visibility-m", thesky,
+       &SGSky::get_visibility );
   fgTie("/environment/temperature-sea-level-degc", _environment,
        &FGEnvironment::get_temperature_sea_level_degc,
        &FGEnvironment::set_temperature_sea_level_degc);
   fgSetArchivable("/environment/temperature-sea-level-degc");
   fgTie("/environment/temperature-degc", _environment,
        &FGEnvironment::get_temperature_degc); // FIXME: read-only for now
+  fgTie("/environment/temperature-degf", _environment,
+       &FGEnvironment::get_temperature_degf); // FIXME: read-only for now
   fgTie("/environment/dewpoint-sea-level-degc", _environment,
        &FGEnvironment::get_dewpoint_sea_level_degc,
        &FGEnvironment::set_dewpoint_sea_level_degc);
@@ -88,6 +110,16 @@ FGEnvironmentMgr::bind ()
        &FGEnvironment::get_pressure_inhg); // FIXME: read-only for now
   fgTie("/environment/density-slugft3", _environment,
        &FGEnvironment::get_density_slugft3); // read-only
+  fgTie("/environment/relative-humidity", _environment,
+       &FGEnvironment::get_relative_humidity); //ro
+  fgTie("/environment/atmosphere/density-tropo-avg", _environment,
+       &FGEnvironment::get_density_tropo_avg_kgm3); //ro
+  fgTie("/environment/atmosphere/altitude-half-to-sun", _environment,
+       &FGEnvironment::get_altitude_half_to_sun_m, 
+       &FGEnvironment::set_altitude_half_to_sun_m);
+  fgTie("/environment/atmosphere/altitude-troposphere-top", _environment,
+        &FGEnvironment::get_altitude_tropo_top_m,
+        &FGEnvironment::set_altitude_tropo_top_m);
   fgTie("/environment/wind-from-heading-deg", _environment,
        &FGEnvironment::get_wind_from_heading_deg,
        &FGEnvironment::set_wind_from_heading_deg);
@@ -142,12 +174,41 @@ FGEnvironmentMgr::bind ()
          &FGEnvironmentMgr::set_cloud_layer_coverage);
     fgSetArchivable(buf);
   }
+  fgTie("/sim/rendering/clouds3d-enable", &sgEnviro,
+         &SGEnviro::get_clouds_enable_state,
+         &SGEnviro::set_clouds_enable_state);
+  fgTie("/sim/rendering/clouds3d-vis-range", &sgEnviro,
+         &SGEnviro::get_clouds_visibility,
+         &SGEnviro::set_clouds_visibility);
+  fgTie("/sim/rendering/clouds3d-density", &sgEnviro,
+         &SGEnviro::get_clouds_density,
+         &SGEnviro::set_clouds_density);
+  fgTie("/sim/rendering/clouds3d-cache-size", &sgEnviro,
+         &SGEnviro::get_clouds_CacheSize,
+         &SGEnviro::set_clouds_CacheSize);
+  fgTie("/sim/rendering/clouds3d-cache-resolution", &sgEnviro,
+         &SGEnviro::get_CacheResolution,
+         &SGEnviro::set_CacheResolution);
+  fgTie("/sim/rendering/precipitation-enable", &sgEnviro,
+         &SGEnviro::get_precipitation_enable_state,
+         &SGEnviro::set_precipitation_enable_state);
+  fgTie("/environment/rebuild-layers", fgClouds,
+      &FGClouds::get_update_event,
+      &FGClouds::set_update_event);
+  fgTie("/sim/rendering/lightning-enable", &sgEnviro,
+      &SGEnviro::get_lightning_enable_state,
+      &SGEnviro::set_lightning_enable_state);
+  fgTie("/environment/turbulence/use-cloud-turbulence", &sgEnviro,
+      &SGEnviro::get_turbulence_enable_state,
+      &SGEnviro::set_turbulence_enable_state);
+  sgEnviro.config(fgGetNode("/sim/rendering/precipitation"));
 }
 
 void
 FGEnvironmentMgr::unbind ()
 {
   fgUntie("/environment/visibility-m");
+  fgUntie("/environment/effective-visibility-m");
   fgUntie("/environment/temperature-sea-level-degc");
   fgUntie("/environment/temperature-degc");
   fgUntie("/environment/dewpoint-sea-level-degc");
@@ -155,9 +216,13 @@ FGEnvironmentMgr::unbind ()
   fgUntie("/environment/pressure-sea-level-inhg");
   fgUntie("/environment/pressure-inhg");
   fgUntie("/environment/density-inhg");
+  fgUntie("/environment/relative-humidity");
+  fgUntie("/environment/atmosphere/density-tropo-avg");
   fgUntie("/environment/wind-from-north-fps");
   fgUntie("/environment/wind-from-east-fps");
   fgUntie("/environment/wind-from-down-fps");
+  fgUntie("/environment/atmosphere/altitude-half-to-sun");
+  fgUntie("/environment/atmosphere/altitude-troposphere-top");
   for (int i = 0; i < MAX_CLOUD_LAYERS; i++) {
     char buf[128];
     sprintf(buf, "/environment/clouds/layer[%d]/span-m", i);
@@ -171,6 +236,15 @@ FGEnvironmentMgr::unbind ()
     sprintf(buf, "/environment/clouds/layer[%d]/type", i);
     fgUntie(buf);
   }
+  fgUntie("/sim/rendering/clouds3d-enable");
+  fgUntie("/sim/rendering/clouds3d-vis-range");
+  fgUntie("/sim/rendering/clouds3d-density");
+  fgUntie("/sim/rendering/clouds3d-cache-size");
+  fgUntie("/sim/rendering/clouds3d-cache-resolution");
+  fgUntie("/sim/rendering/precipitation-enable");
+  fgUntie("/environment/rebuild-layers");
+  fgUntie("/sim/rendering/lightning-enable");
+  fgUntie("/environment/turbulence/use-cloud-turbulence");
 }
 
 void