*/
FGPrecipitationMgr::FGPrecipitationMgr()
{
- group = new osg::Group();
- transform = new osg::MatrixTransform();
- precipitation = new SGPrecipitation();
-
-
- // By default, no precipitation
- precipitation->setRainIntensity(0);
- precipitation->setSnowIntensity(0);
-
- // set the clip distance from the config
- precipitation->setClipDistance(fgGetFloat("/environment/precipitation-control/clip-distance",5.0));
- transform->addChild(precipitation->build());
- group->addChild(transform.get());
+ // Try to set up the scenegraph.
+ setupSceneGraph();
}
-
/**
* @brief FGPrecipitaiton Manager destructor
*/
osg::Matrix position(makeZUpFrame(geod));
// Move the precipitation object to player position
transform->setMatrix(position);
- // Add to scene graph
- osg::Group* scenery = globals->get_scenery()->get_scene_graph();
- scenery->addChild(getObject());
fgGetNode("environment/params/precipitation-level-ft", true);
}
_tiedProperties.Untie();
}
-void FGPrecipitationMgr::setPrecipitationLevel(double a)
+// Set up the precipitation manager scenegraph.
+void FGPrecipitationMgr::setupSceneGraph(void)
{
- fgSetDouble("environment/params/precipitation-level-ft",a);
+ FGScenery* scenery = globals->get_scenery();
+ osg::Group* group = scenery->get_precipitation_branch();
+ transform = new osg::MatrixTransform();
+ precipitation = new SGPrecipitation();
+
+
+ // By default, no precipitation
+ precipitation->setRainIntensity(0);
+ precipitation->setSnowIntensity(0);
+
+ // set the clip distance from the config
+ precipitation->setClipDistance(fgGetFloat("/environment/precipitation-control/clip-distance",5.0));
+ transform->addChild(precipitation->build());
+ group->addChild(transform.get());
}
-/**
- * @brief Get OSG precipitation object
- *
- * @returns A pointer on the OSG object (osg::Group *)
- */
-osg::Group * FGPrecipitationMgr::getObject(void)
+
+void FGPrecipitationMgr::setPrecipitationLevel(double a)
{
- return this->group.get();
+ fgSetDouble("environment/params/precipitation-level-ft",a);
}
/**
class FGPrecipitationMgr : public SGSubsystem
{
private:
- osg::ref_ptr<osg::Group> group;
osg::ref_ptr<osg::MatrixTransform> transform;
osg::ref_ptr<SGPrecipitation> precipitation;
float getPrecipitationAtAltitudeMax(void);
virtual void init ();
virtual void update (double dt);
+ void setupSceneGraph(void);
void setPrecipitationLevel(double l);
-
- osg::Group * getObject(void);
-
};
#endif
scene_graph->addChild(particles_branch.get());
simgear::GlobalParticleCallback::setSwitch(fgGetNode("/sim/rendering/particles", true));
+ // Set up the precipitation system.
+ precipitation_branch = new osg::Group;
+ precipitation_branch->setName("Precipitation");
+ scene_graph->addChild(precipitation_branch.get());
+
_listener = new ScenerySwitchListener(this);
// Toggle the setup flag.
models_branch = NULL;
aircraft_branch = NULL;
particles_branch = NULL;
+ precipitation_branch = NULL;
// Toggle the setup flag.
_inited = false;
osg::ref_ptr<osg::Group> aircraft_branch;
osg::ref_ptr<osg::Group> interior_branch;
osg::ref_ptr<osg::Group> particles_branch;
+ osg::ref_ptr<osg::Group> precipitation_branch;
osg::ref_ptr<flightgear::SceneryPager> _pager;
ScenerySwitchListener* _listener;
osg::Group *get_aircraft_branch () const { return aircraft_branch.get(); }
osg::Group *get_interior_branch () const { return interior_branch.get(); }
osg::Group *get_particles_branch () const { return particles_branch.get(); }
+ osg::Group *get_precipitation_branch () const { return precipitation_branch.get(); }
/// Returns true if scenery is available for the given lat, lon position
/// within a range of range_m.