{
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;
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),
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.
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());
}
}
}
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];
// 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);