#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 <Main/renderer.hxx>
#include <Aircraft/aircraft.hxx>
#include "environment.hxx"
#include "environment_ctrl.hxx"
#include "environment_mgr.hxx"
-extern SGSky *thesky; // FIXME: from main.cxx
-
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);
}
FGEnvironmentMgr::init ()
{
SG_LOG( SG_GENERAL, SG_INFO, "Initializing environment subsystem");
- FGSubsystemGroup::init();
+ SGSubsystemGroup::init();
_update_fdm();
}
FGEnvironmentMgr::reinit ()
{
SG_LOG( SG_GENERAL, SG_INFO, "Reinitializing environment subsystem");
- FGSubsystemGroup::reinit();
+ SGSubsystemGroup::reinit();
_update_fdm();
}
&FGEnvironment::get_wind_from_down_fps,
&FGEnvironment::set_wind_from_down_fps);
fgSetArchivable("/environment/wind-from-down-fps");
- fgTie("/environment/turbulence-norm", _environment,
- &FGEnvironment::get_turbulence_norm,
- &FGEnvironment::set_turbulence_norm);
- fgSetArchivable("/environment/turbulence-norm");
+ fgTie("/environment/turbulence/magnitude-norm", _environment,
+ &FGEnvironment::get_turbulence_magnitude_norm,
+ &FGEnvironment::set_turbulence_magnitude_norm);
+ fgSetArchivable("/environment/turbulence/magnitude-norm");
+ fgTie("/environment/turbulence/rate-hz", _environment,
+ &FGEnvironment::get_turbulence_rate_hz,
+ &FGEnvironment::set_turbulence_rate_hz);
+ fgSetArchivable("/environment/turbulence/rate-hz");
for (int i = 0; i < MAX_CLOUD_LAYERS; i++) {
char buf[128];
&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/precipitation-enable", &sgEnviro,
+ &SGEnviro::get_precipitation_enable_state,
+ &SGEnviro::set_precipitation_enable_state);
}
void
void
FGEnvironmentMgr::update (double dt)
{
- FGSubsystemGroup::update(dt);
+ SGSubsystemGroup::update(dt);
// FIXME: the FDMs should update themselves
current_aircraft.fdm_state
void
FGEnvironmentMgr::set_cloud_layer_elevation_ft (int index, double elevation_ft)
{
+ FGEnvironment env = *_environment;
+ env.set_elevation_ft(elevation_ft);
+
thesky->get_cloud_layer(index)
->setElevation_m(elevation_ft * SG_FEET_TO_METER);
+
+ thesky->get_cloud_layer(index)
+ ->setSpeed(env.get_wind_speed_kt() * 0.5151); // 1 kt = 0.5151 m/s
+
+ thesky->get_cloud_layer(index)
+ ->setDirection(env.get_wind_from_heading_deg());
}
double