// Constructor
SGSky::SGSky( void ) {
effective_visibility = visibility = 10000.0;
- minimum_sky_visibility = 1000;
// near cloud visibility state variables
in_puff = false;
cloud_root = new osg::Group;
cloud_root->setNodeMask(simgear::MODEL_BIT);
cloud_root->setName("SGSky-cloud-root");
- pre_selector = new osg::Switch;
pre_transform = new osg::Group;
-
_ephTransform = new osg::MatrixTransform;
// Set up a RNG that is repeatable within 10 minutes to ensure that clouds
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 )
{
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 ) {
tex_path = SGPath( path );
}
#include <osg/ref_ptr>
#include <osg/MatrixTransform>
#include <osg/Node>
-#include <osg/Switch>
#include <simgear/ephemeris/ephemeris.hxx>
#include <simgear/math/SGMath.hxx>
layer_list_type cloud_layers;
osg::ref_ptr<osg::Group> pre_root, cloud_root;
- osg::ref_ptr<osg::Switch> pre_selector;
osg::ref_ptr<osg::Group> pre_transform;
osg::ref_ptr<osg::MatrixTransform> _ephTransform;
// visibility
float visibility;
float effective_visibility;
- float minimum_sky_visibility;
int in_cloud;
*/
void texture_path( const string& path );
- /** Enable drawing of the sky. */
- inline void enable() {
- pre_selector->setValue(0, 1);
- }
-
- /**
- * Disable drawing of the sky in the scene graph. The leaf node is still
- * there, how ever it won't be traversed on by ssgCullandRender()
- */
- inline void disable() {
- pre_selector->setValue(0, 0);
- }
-
/**
* Get the current sun color
*/
/** @return current effective visibility */
- inline float get_visibility() const { return effective_visibility; }
+ float get_visibility() const { return effective_visibility; }
/** Set desired clear air visibility.
* @param v visibility in meters
*/
- inline void set_visibility( float v ) {
- effective_visibility = visibility = (v <= 25.0) ? 25.0 : v;
- }
+ void set_visibility( float v );
/** Get 3D cloud density */
double get_3dCloudDensity() const;
void set_3dCloudWrap(bool wrap);
- /** Get minimum sky visibility */
- float get_minimum_sky_visibility() const;
-
- /** Set minimum sky visibility */
- void set_minimum_sky_visibility( float value );
};
#endif // _SG_SKY_HXX