33#include <osg/MatrixTransform>
35#include <simgear/constants.h>
36#include <simgear/scene/sky/sky.hxx>
37#include <simgear/scene/sky/cloud.hxx>
38#include <simgear/scene/util/OsgMath.hxx>
72 SGGeod geod = SGGeod::fromDegM(
fgGetDouble(
"/position/longitude-deg", 0.0),
75 osg::Matrix position(makeZUpFrame(geod));
77 transform->setMatrix(position);
78 fgGetNode(
"environment/params/precipitation-level-ft",
true);
83 _tiedProperties.setRoot(
fgGetNode(
"/sim/rendering",
true ) );
84 _tiedProperties.Tie(
"precipitation-enable", precipitation.get(),
85 &SGPrecipitation::getEnabled,
86 &SGPrecipitation::setEnabled);
91 _tiedProperties.Untie();
99 transform =
new osg::MatrixTransform();
100 precipitation =
new SGPrecipitation();
104 precipitation->setRainIntensity(0);
105 precipitation->setSnowIntensity(0);
108 precipitation->setClipDistance(
fgGetFloat(
"/environment/precipitation-control/clip-distance",5.0));
109 transform->addChild(precipitation->build());
110 group->addChild(transform.get());
116 fgSetDouble(
"environment/params/precipitation-level-ft",a);
127float FGPrecipitationMgr::getPrecipitationAtAltitudeMax(
void)
132 SGPropertyNode *boundaryNode, *boundaryEntry;
134 if (
fgGetBool(
"/environment/params/use-external-precipitation-level",
false)) {
137 return fgGetFloat(
"/environment/params/external-precipitation-level-m", 0.0);
142 max = SGCloudLayer::SG_MAX_CLOUD_COVERAGES;
152 for (
i=0;
i<thesky->get_cloud_layer_count();
i++) {
163 q = thesky->get_cloud_layer(
i)->getCoverage();
168 result = thesky->get_cloud_layer(
i)->getElevation_m();
179 boundaryNode =
fgGetNode(
"/environment/config/boundary");
181 if (boundaryNode != NULL) {
185 while ( ( boundaryEntry = boundaryNode->getNode(
"entry",
i ) ) != NULL ) {
186 double elev = boundaryEntry->getDoubleValue(
"elevation-ft" );
196 result = result * SG_FEET_TO_METER;
214 double rain_intensity;
215 double snow_intensity;
217 float altitudeAircraft;
218 float altitudeCloudLayer;
219 float rainDropletSize;
223 altitudeCloudLayer = this->getPrecipitationAtAltitudeMax() * SG_METER_TO_FEET;
229 if (!precipitation->getEnabled() ) {
231 precipitation->setRainIntensity(0);
232 precipitation->setSnowIntensity(0);
235 precipitation->update();
242 if (
fgGetBool(
"/environment/precipitation-control/detailed-precipitation",
false)) {
243 precipitation->setDropletExternal(
true);
244 rainDropletSize =
fgGetFloat(
"/environment/precipitation-control/rain-droplet-size", 0.015);
245 snowFlakeSize =
fgGetFloat(
"/environment/precipitation-control/snow-flake-size", 0.03);
246 illumination =
fgGetFloat(
"/environment/precipitation-control/illumination", 1.0);
247 precipitation->setRainDropletSize(rainDropletSize);
248 precipitation->setSnowFlakeSize(snowFlakeSize);
249 precipitation->setIllumination(illumination);
253 altitudeAircraft =
fgGetDouble(
"/position/altitude-ft", 0.0);
255 if ((altitudeCloudLayer > 0) && (altitudeAircraft > altitudeCloudLayer)) {
262 rain_intensity =
fgGetDouble(
"/environment/rain-norm", 0.0);
263 snow_intensity =
fgGetDouble(
"/environment/snow-norm", 0.0);
267 dewtemp =
fgGetDouble(
"/environment/dewpoint-degc", 0.0);
268 currtemp =
fgGetDouble(
"/environment/temperature-degc", 0.0);
270 if (currtemp < dewtemp) {
272 if (rain_intensity == 0)
273 rain_intensity = 0.15;
278 precipitation->setFreezing(
true);
280 precipitation->setFreezing(
false);
284 precipitation->setWindProperty(
285 fgGetDouble(
"/environment/wind-from-heading-deg", 0.0),
289 precipitation->setRainIntensity(rain_intensity);
290 precipitation->setSnowIntensity(snow_intensity);
293 precipitation->update();
299 SGSubsystemMgr::GENERAL,
300 {{
"FGScenery", SGSubsystemMgr::Dependency::HARD},
301 {
"SGSky", SGSubsystemMgr::Dependency::NONSUBSYSTEM_HARD}});
virtual FGRenderer * get_renderer() const
virtual ~FGPrecipitationMgr()
FGPrecipitaiton Manager destructor.
void init() override
SGSubsystem initialization.
void setPrecipitationLevel(double l)
FGPrecipitationMgr()
FGPrecipitation Manager constructor.
void setupSceneGraph(void)
void update(double dt) override
Update the precipitation drawing.
osg::Group * get_precipitation_branch() const
SGSubsystemMgr::Registrant< FGPrecipitationMgr > registrantFGPrecipitationMgr(SGSubsystemMgr::GENERAL, {{"FGScenery", SGSubsystemMgr::Dependency::HARD}, {"SGSky", SGSubsystemMgr::Dependency::NONSUBSYSTEM_HARD}})
Precipitation manager This manager calculate the intensity of precipitation in function of the altitu...
bool fgSetDouble(const char *name, double defaultValue)
Set a double value for a property.
bool fgGetBool(char const *name, bool def)
Get a bool value for a property.
double fgGetDouble(const char *name, double defaultValue)
Get a double value for a property.
SGPropertyNode * fgGetNode(const char *path, bool create)
Get a property node.
float fgGetFloat(const char *name, float defaultValue)
Get a float value for a property.