]> git.mxchange.org Git - simgear.git/commitdiff
Allow clouds to be toggled on/off
authorJames Turner <zakalawe@mac.com>
Fri, 28 Feb 2014 11:06:47 +0000 (11:06 +0000)
committerJames Turner <zakalawe@mac.com>
Fri, 28 Feb 2014 11:06:47 +0000 (11:06 +0000)
- Change the cloud-root Group to a Switch

simgear/scene/sky/sky.cxx
simgear/scene/sky/sky.hxx

index ed7b13e05df2d1c2ff3d3fb8ab815750809b1e96..e5535059e991b9a601496f1cc19ee124c712661d 100644 (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();
+    }
+}
index 5c239b9e10576c157d192ac78a185bd6ebec83cc..09d9b4cace8154aaba7a5748c88d6ed7a3ff56e6 100644 (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