]> git.mxchange.org Git - simgear.git/commitdiff
Stuart :
authorfredb <fredb>
Sun, 14 Dec 2008 18:47:30 +0000 (18:47 +0000)
committerfredb <fredb>
Sun, 14 Dec 2008 18:47:30 +0000 (18:47 +0000)
the 3D clouds now respect changes to the environment caused by updated METAR etc.

It also increases the AlphaFunc as suggested by Tim.

simgear/scene/sky/cloudfield.cxx
simgear/scene/sky/cloudfield.hxx
simgear/scene/sky/newcloud.cxx

index bb2bb5270d3ce05e3e78536c815a521e190f0e71..313e255a06fe68bc8faff49c039666f6df92deef 100644 (file)
@@ -80,6 +80,10 @@ bool SGCloudField::reposition( const SGVec3f& p, const SGVec3f& up, double lon,
 {
     osg::Matrix T, LON, LAT;
     
+    // Always update the altitude transform, as this allows
+    // the clouds to rise and fall smoothly depending on environment updates.
+    altitude_transform->setPosition(osg::Vec3d(0.0, 0.0, (double) asl));
+    
     // Calculating the reposition information is expensive. 
     // Only perform the reposition every 60 frames.
     reposition_count = (reposition_count + 1) % 60;
@@ -142,6 +146,7 @@ bool SGCloudField::reposition( const SGVec3f& p, const SGVec3f& up, double lon,
 SGCloudField::SGCloudField() :
         field_root(new osg::Group),
         field_transform(new osg::MatrixTransform),
+        altitude_transform(new osg::PositionAttitudeTransform),
        deltax(0.0),
        deltay(0.0),
        last_course(0.0),
@@ -179,7 +184,9 @@ SGCloudField::SGCloudField() :
             quad[i][j]->addChild(field_group[x][y].get(), 0.0f, view_distance);
         }
     }
-
+    
+    field_transform->addChild(altitude_transform.get());
+            
     // We duplicate the defined field group in a 3x3 array. This way,
     // we can simply shift entire groups around.
     // TODO: "Bend" the edge groups so when shifted they line up.
@@ -191,7 +198,7 @@ SGCloudField::SGCloudField() :
             transform->addChild(quad_root.get());
             transform->setPosition(osg::Vec3(x*fieldSize, y * fieldSize, 0.0));
             
-            field_transform->addChild(transform.get());
+            altitude_transform->addChild(transform.get());
         }
     }
 }
index 75a94091e6250f38f6229bd5b48cef0cba24a87d..f844a98df85b4b739794718e294fbc6164366d32 100644 (file)
@@ -74,6 +74,7 @@ private:
 
         osg::ref_ptr<osg::Group> field_root;
         osg::ref_ptr<osg::MatrixTransform> field_transform;
+        osg::ref_ptr<osg::PositionAttitudeTransform> altitude_transform;
         osg::ref_ptr<osg::Switch> field_group[QUADTREE_SIZE][QUADTREE_SIZE];
         osg::ref_ptr<osg::LOD> quad[BRANCH_SIZE][BRANCH_SIZE];
         
index 165e1268f2950dfc86a0b69ffd3c6bb930431f8f..43ed8e696b6a80f3c1599f042c793a5b1acfc85f 100644 (file)
@@ -192,7 +192,7 @@ SGNewCloud::SGNewCloud(string type,
         // Generate the shader etc, if we don't already have one.
         if (!program.valid()) {
             alphaFunc = new AlphaFunc;
-            alphaFunc->setFunction(AlphaFunc::GREATER,0.001f);
+            alphaFunc->setFunction(AlphaFunc::GREATER,0.05f);
             program  = new Program;
             baseTextureSampler = new osg::Uniform("baseTexture", 0);
             Shader* vertex_shader = new Shader(Shader::VERTEX, vertexShaderSource);