// Constructor
SGSky::SGSky( void ) {
effective_visibility = visibility = 10000.0;
- minimum_sky_visibility = 1000;
// near cloud visibility state variables
in_puff = false;
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);
-
- pre_selector = new osg::Switch;
+ cloud_root->setName("SGSky-cloud-root");
pre_transform = new osg::Group;
-
_ephTransform = new osg::MatrixTransform;
// Set up a RNG that is repeatable within 10 minutes to ensure that clouds
// initialize the sky and connect the components to the scene graph at
// the provided branch
-void SGSky::build( double h_radius_m, double v_radius_m,
- double sun_size, double moon_size,
- const SGEphemeris& eph, SGPropertyNode *property_tree_node,
+void SGSky::build( double h_radius_m,
+ double v_radius_m,
+ double sun_size,
+ double moon_size,
+ const SGEphemeris& eph,
+ SGPropertyNode *property_tree_node,
simgear::SGReaderWriterOptions* options )
{
dome = new SGSkyDome;
oursun = new SGSun;
_ephTransform->addChild( oursun->build(tex_path, sun_size, property_tree_node ) );
- pre_selector->addChild( pre_transform.get() );
-
- pre_root->addChild( pre_selector.get() );
+ pre_root->addChild( pre_transform.get() );
}
// 180 degrees = darkest midnight
bool SGSky::repaint( const SGSkyColor &sc, const SGEphemeris& eph )
{
- if ( effective_visibility > minimum_sky_visibility ) {
- enable();
dome->repaint( sc.adj_sky_color, sc.sky_color, sc.fog_color,
sc.sun_angle, effective_visibility );
cloud_layers[i]->repaint( sc.cloud_color );
}
}
- } else {
- // turn off sky
- disable();
- }
+
SGCloudField::updateFog((double)effective_visibility,
osg::Vec4f(toOsg(sc.fog_color), 1.0f));
return true;
return true;
}
+void
+SGSky::set_visibility( float v )
+{
+ visibility = std::max(v, 25.0f);
+}
+
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);
}
SGCloudField::setUseImpostors(imp);
}
-float SGSky::get_minimum_sky_visibility() const
-{
- return minimum_sky_visibility;
-}
-
-void SGSky::set_minimum_sky_visibility( float value )
-{
- minimum_sky_visibility = value;
-}
-
-void SGSky::texture_path( const string& path ) {
+void SGSky::texture_path( const std::string& path ) {
tex_path = SGPath( path );
}
effective_visibility = effvis;
}
-
+void SGSky::set_clouds_enabled(bool enabled)
+{
+ if (enabled) {
+ cloud_root->setAllChildrenOn();
+ } else {
+ cloud_root->setAllChildrenOff();
+ }
+}