the 3D clouds now respect changes to the environment caused by updated METAR etc.

It also increases the AlphaFunc as suggested by Tim.
This commit is contained in:
fredb 2008-12-14 18:47:30 +00:00
parent 15893bc558
commit 53f7743678
3 changed files with 11 additions and 3 deletions

View 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),
@ -180,6 +185,8 @@ SGCloudField::SGCloudField() :
}
}
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());
}
}
}

View 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];

View 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);