1
0
Fork 0

Expose precipitation property

from Vivian Meazza
This commit is contained in:
timoore 2008-11-25 22:50:04 +00:00
parent 77318b23a5
commit 19d9287d3a
2 changed files with 13 additions and 5 deletions

View file

@ -44,7 +44,6 @@
#include "precipitation_mgr.hxx" #include "precipitation_mgr.hxx"
extern SGSky *thesky; extern SGSky *thesky;
@ -63,7 +62,6 @@ FGPrecipitationMgr::FGPrecipitationMgr()
// By default, no precipitation // By default, no precipitation
precipitation->setRainIntensity(0); precipitation->setRainIntensity(0);
precipitation->setSnowIntensity(0); precipitation->setSnowIntensity(0);
transform->addChild(precipitation->build()); transform->addChild(precipitation->build());
group->addChild(transform.get()); group->addChild(transform.get());
} }
@ -92,6 +90,12 @@ void FGPrecipitationMgr::init()
// Add to scene graph // Add to scene graph
osg::Group* scenery = globals->get_scenery()->get_scene_graph(); osg::Group* scenery = globals->get_scenery()->get_scene_graph();
scenery->addChild(getObject()); scenery->addChild(getObject());
fgGetNode("environment/params/precipitation-level-ft", true);
}
void FGPrecipitationMgr::setPrecipitationLevel(double a)
{
fgSetDouble("environment/params/precipitation-level-ft",a);
} }
/** /**
@ -104,7 +108,6 @@ osg::Group * FGPrecipitationMgr::getObject(void)
return this->group.get(); return this->group.get();
} }
/** /**
* @brief Calculate the max alitutude with precipitation * @brief Calculate the max alitutude with precipitation
* *
@ -199,6 +202,9 @@ void FGPrecipitationMgr::update(double dt)
float altitudeAircraft; float altitudeAircraft;
float altitudeCloudLayer; float altitudeCloudLayer;
altitudeCloudLayer = this->getPrecipitationAtAltitudeMax() * SG_METER_TO_FEET;
setPrecipitationLevel(altitudeCloudLayer);
// Does the user enable the precipitation ? // Does the user enable the precipitation ?
if (!sgEnviro.get_precipitation_enable_state()) { if (!sgEnviro.get_precipitation_enable_state()) {
// Disable precipitations // Disable precipitations
@ -214,7 +220,6 @@ void FGPrecipitationMgr::update(double dt)
// Get the elevation of aicraft and of the cloud layer // Get the elevation of aicraft and of the cloud layer
altitudeAircraft = fgGetDouble("/position/altitude-ft", 0.0); altitudeAircraft = fgGetDouble("/position/altitude-ft", 0.0);
altitudeCloudLayer = this->getPrecipitationAtAltitudeMax() * SG_METER_TO_FEET;
if ((altitudeCloudLayer > 0) && (altitudeAircraft > altitudeCloudLayer)) { if ((altitudeCloudLayer > 0) && (altitudeAircraft > altitudeCloudLayer)) {
// The aircraft is above the cloud layer // The aircraft is above the cloud layer

View file

@ -32,6 +32,7 @@
#include <simgear/structure/subsystem_mgr.hxx> #include <simgear/structure/subsystem_mgr.hxx>
#include <simgear/environment/precipitation.hxx> #include <simgear/environment/precipitation.hxx>
class FGPrecipitationMgr : public SGSubsystem class FGPrecipitationMgr : public SGSubsystem
{ {
private: private:
@ -40,7 +41,6 @@ private:
osg::ref_ptr<SGPrecipitation> precipitation; osg::ref_ptr<SGPrecipitation> precipitation;
float getPrecipitationAtAltitudeMax(void); float getPrecipitationAtAltitudeMax(void);
public: public:
FGPrecipitationMgr(); FGPrecipitationMgr();
virtual ~FGPrecipitationMgr(); virtual ~FGPrecipitationMgr();
@ -49,7 +49,10 @@ public:
virtual void init (); virtual void init ();
virtual void update (double dt); virtual void update (double dt);
void setPrecipitationLevel(double l);
osg::Group * getObject(void); osg::Group * getObject(void);
}; };
#endif #endif