Allow clouds to be toggled on/off

- Change the cloud-root Group to a Switch
This commit is contained in:
James Turner 2014-02-28 11:06:47 +00:00
parent 5a5ba08c23
commit 081aafb914
2 changed files with 13 additions and 5 deletions

View File

@ -58,7 +58,7 @@ SGSky::SGSky( void ) {
preStateSet->setAttribute(new osg::Depth(osg::Depth::LESS, 0.0, 1.0,
false));
pre_root->setStateSet(preStateSet);
cloud_root = new osg::Group;
cloud_root = new osg::Switch;
cloud_root->setNodeMask(simgear::MODEL_BIT);
cloud_root->setName("SGSky-cloud-root");
@ -195,7 +195,7 @@ void
SGSky::add_cloud_layer( SGCloudLayer * layer )
{
cloud_layers.push_back(layer);
cloud_root->addChild(layer->getNode());
cloud_root->addChild(layer->getNode(), true);
layer->set_enable3dClouds(clouds_3d_enabled);
}
@ -426,4 +426,11 @@ void SGSky::modify_vis( float alt, float time_factor ) {
effective_visibility = effvis;
}
void SGSky::set_clouds_enabled(bool enabled)
{
if (enabled) {
cloud_root->setAllChildrenOn();
} else {
cloud_root->setAllChildrenOff();
}
}

View File

@ -222,8 +222,8 @@ private:
SGSharedPtr<SGStars> stars;
layer_list_type cloud_layers;
osg::ref_ptr<osg::Group> pre_root, cloud_root;
osg::ref_ptr<osg::Group> pre_transform;
osg::ref_ptr<osg::Group> pre_root, pre_transform;
osg::ref_ptr<osg::Switch> cloud_root;
osg::ref_ptr<osg::MatrixTransform> _ephTransform;
@ -468,6 +468,7 @@ public:
*/
void set_3dCloudWrap(bool wrap);
void set_clouds_enabled(bool enabled);
};
#endif // _SG_SKY_HXX