#include <Main/main.hxx>
#include <Main/fg_props.hxx>
-#include <Aircraft/aircraft.hxx>
#include <FDM/flight.hxx>
#include "environment.hxx"
-#include "environment_ctrl.hxx"
#include "environment_mgr.hxx"
+#include "environment_ctrl.hxx"
#include "fgclouds.hxx"
#include "precipitation_mgr.hxx"
: _environment(new FGEnvironment)
{
- if (fgGetBool("/environment/params/real-world-weather-fetch") == true)
- _controller = new FGMetarEnvironmentCtrl;
- else
- _controller = new FGInterpolateEnvironmentCtrl;
-
+ _controller = new FGInterpolateEnvironmentCtrl;
_controller->setEnvironment(_environment);
- set_subsystem("controller", _controller, 0.5);
- fgClouds = new FGClouds( _controller );
+ set_subsystem("controller", _controller, 0.1 );
+
+ fgClouds = new FGClouds();
+
+ _metarcontroller = new FGMetarCtrl(_controller );
+ set_subsystem("metarcontroller", _metarcontroller, 0.1 );
+
+ _metarfetcher = new FGMetarFetcher();
+ set_subsystem("metarfetcher", _metarfetcher, 1.0 );
+
_precipitationManager = new FGPrecipitationMgr;
set_subsystem("precipitation", _precipitationManager);
}
FGEnvironmentMgr::~FGEnvironmentMgr ()
{
- delete _environment;
- remove_subsystem("controller");
remove_subsystem("precipitation");
- delete _controller;
- delete fgClouds;
delete _precipitationManager;
+
+ remove_subsystem("metarcontroller");
+ delete _metarfetcher;
+
+ remove_subsystem("metarfetcher");
+ delete _metarcontroller;
+
+ delete fgClouds;
+
+ remove_subsystem("controller");
+ delete _controller;
+
+ delete _environment;
}
void
{
SG_LOG( SG_GENERAL, SG_INFO, "Initializing environment subsystem");
SGSubsystemGroup::init();
- _update_fdm();
+ //_update_fdm();
}
void
{
SG_LOG( SG_GENERAL, SG_INFO, "Reinitializing environment subsystem");
SGSubsystemGroup::reinit();
- _update_fdm();
+ //_update_fdm();
}
void
FGEnvironmentMgr::bind ()
{
+ SGSubsystemGroup::bind();
fgTie("/environment/visibility-m", _environment,
&FGEnvironment::get_visibility_m, &FGEnvironment::set_visibility_m);
fgSetArchivable("/environment/visibility-m");
&FGEnvironment::get_wind_from_down_fps,
&FGEnvironment::set_wind_from_down_fps);
fgSetArchivable("/environment/wind-from-down-fps");
+
+ fgTie("/environment/thermal-lift-fps", _environment,
+ &FGEnvironment::get_thermal_lift_fps,
+ &FGEnvironment::set_thermal_lift_fps);
+ fgSetArchivable("/environment/thermal-lift-fps");
+ fgTie("/environment/ridge-lift-fps", _environment,
+ &FGEnvironment::get_ridge_lift_fps,
+ &FGEnvironment::set_ridge_lift_fps);
+ fgSetArchivable("/environment/ridge-lift-fps");
+
+ fgTie("/environment/local-weather-lift", _environment,
+ &FGEnvironment::get_local_weather_lift_fps); //read-only
+
fgTie("/environment/turbulence/magnitude-norm", _environment,
&FGEnvironment::get_turbulence_magnitude_norm,
&FGEnvironment::set_turbulence_magnitude_norm);
&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("/environment/metar/data", _metarcontroller,
+ &FGMetarCtrl::get_metar, &FGMetarCtrl::set_metar );
+
+ fgTie("/sim/rendering/clouds3d-enable", fgClouds,
+ &FGClouds::get_3dClouds,
+ &FGClouds::set_3dClouds);
+ fgTie("/sim/rendering/clouds3d-density", thesky,
+ &SGSky::get_3dCloudDensity,
+ &SGSky::set_3dCloudDensity);
+ fgTie("/sim/rendering/clouds3d-vis-range", thesky,
+ &SGSky::get_3dCloudVisRange,
+ &SGSky::set_3dCloudVisRange);
+
fgTie("/sim/rendering/precipitation-enable", &sgEnviro,
- &SGEnviro::get_precipitation_enable_state,
+ &SGEnviro::get_precipitation_enable_state,
&SGEnviro::set_precipitation_enable_state);
fgTie("/environment/rebuild-layers", fgClouds,
&FGClouds::get_update_event,
fgUntie("/environment/wind-from-north-fps");
fgUntie("/environment/wind-from-east-fps");
fgUntie("/environment/wind-from-down-fps");
+
+ fgUntie("/environment/thermal-lift-fps");
+ fgUntie("/environment/ridge-lift-fps");
+ fgUntie("/environment/local-weather-lift");
+
fgUntie("/environment/atmosphere/altitude-half-to-sun");
fgUntie("/environment/atmosphere/altitude-troposphere-top");
for (int i = 0; i < MAX_CLOUD_LAYERS; i++) {
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("/environment/weather-scenario");
fgUntie("/sim/rendering/lightning-enable");
fgUntie("/environment/turbulence/use-cloud-turbulence");
+ SGSubsystemGroup::unbind();
}
void
FGEnvironmentMgr::update (double dt)
{
SGSubsystemGroup::update(dt);
-
- // FIXME: the FDMs should update themselves
- current_aircraft.fdm_state
- ->set_Velocities_Local_Airmass(_environment->get_wind_from_north_fps(),
- _environment->get_wind_from_east_fps(),
- _environment->get_wind_from_down_fps());
+
_environment->set_elevation_ft(fgGetDouble("/position/altitude-ft"));
- osg::Vec3 windVec(-_environment->get_wind_from_north_fps(),
+ _environment->set_local_weather_lift_fps(fgGetDouble("/local-weather/current/thermal-lift"));
+ osg::Vec3 windVec(_environment->get_wind_from_north_fps(),
-_environment->get_wind_from_east_fps(),
- _environment->get_wind_from_down_fps());
- simgear::Particles::setWindVector(windVec * SG_FEET_TO_METER);
+ 0);
+ // SG_LOG(SG_GENERAL, SG_ALERT, "-_environment->get_wind_from_north_mps() " <<
+ //_environment->get_wind_from_north_fps() * SG_FEET_TO_METER
+ //<< " -_environment->get_wind_from_east_mps() "
+ //<< -_environment->get_wind_from_east_fps() * SG_FEET_TO_METER
+ //);
+
+ // simgear::Particles::setWindVector(windVec * SG_FEET_TO_METER);
+ simgear::Particles::setWindFrom( _environment->get_wind_from_heading_deg(),
+ _environment->get_wind_speed_kt() );
+ //double wind_true_deg = _environment->get_wind_from_heading_deg();
+ //simgear::Particles::setWindFrom( wind_true_deg,
+ // _environment->get_wind_speed_kt() );
- _update_fdm();
}
FGEnvironment
}
-void
-FGEnvironmentMgr::_update_fdm () const
-{
- //
- // Pass atmosphere on to FDM
- // FIXME: have FDMs read properties directly.
- //
- if (fgGetBool("/environment/params/control-fdm-atmosphere")) {
- // convert from Rankine to Celsius
- cur_fdm_state
- ->set_Static_temperature((9.0/5.0)
- * (_environment->get_temperature_degc() + 273.15));
- // convert from inHG to PSF
- cur_fdm_state
- ->set_Static_pressure(_environment->get_pressure_inhg() * 70.726566);
- // keep in slugs/ft^3
- cur_fdm_state
- ->set_Density(_environment->get_density_slugft3());
- }
-}
-
double
FGEnvironmentMgr::get_cloud_layer_span_m (int index) const
{