X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fenvironment%2Fprecipitation.cxx;h=073c06d81869012a6af592b737a949c6abdec7b6;hb=d4310a7f3b27b8403ba1ec030cfd3b4c6c565f24;hp=05b1b447091e83f2e4514bbe438d9d0d605cc6d8;hpb=cc17cc4af754197c504f61abbbef1b4ec8c7263a;p=simgear.git diff --git a/simgear/environment/precipitation.cxx b/simgear/environment/precipitation.cxx index 05b1b447..073c06d8 100644 --- a/simgear/environment/precipitation.cxx +++ b/simgear/environment/precipitation.cxx @@ -25,9 +25,11 @@ */ #include "precipitation.hxx" -#include "visual_enviro.hxx" +//#include "visual_enviro.hxx" #include +#include +#include /** * @brief SGPrecipitation constructor @@ -35,11 +37,20 @@ * Build a new OSG object from osgParticle. */ SGPrecipitation::SGPrecipitation() : - _freeze(false), _snow_intensity(0.0), _rain_intensity(0.0) + _freeze(false), _enabled(true), _snow_intensity(0.0), _rain_intensity(0.0), _clip_distance(5.0) { _precipitationEffect = new osgParticle::PrecipitationEffect; } +void SGPrecipitation::setEnabled( bool value ) +{ + _enabled = value; +} + +bool SGPrecipitation::getEnabled() const +{ + return _enabled; +} /** * @brief Build and add the object "precipitationEffect" @@ -54,7 +65,22 @@ osg::Group* SGPrecipitation::build(void) _precipitationEffect->snow(0); _precipitationEffect->rain(0); - group->addChild(_precipitationEffect.get()); + if (_clip_distance!=0.0) + { + osg::ref_ptr clipNode = new osg::ClipNode; + clipNode->addClipPlane( new osg::ClipPlane( 0 ) ); + clipNode->getClipPlane(0)->setClipPlane( 0.0, 0.0, -1.0, -_clip_distance ); + clipNode->setReferenceFrame(osg::ClipNode::ABSOLUTE_RF); + clipNode->addChild(_precipitationEffect.get()); + + group->addChild(clipNode.get()); + } + else + { + group->addChild(_precipitationEffect.get()); + } + + group->setNodeMask( ~(simgear::CASTSHADOW_BIT | simgear::MODELLIGHT_BIT) ); return group; } @@ -147,8 +173,7 @@ bool SGPrecipitation::update(void) this->_snow_intensity = this->_rain_intensity; } - bool enabled = sgEnviro.get_precipitation_enable_state(); - if (enabled && this->_snow_intensity > 0) { + if (_enabled && this->_snow_intensity > 0) { _precipitationEffect->setWind(_wind_vec); _precipitationEffect->setParticleSpeed( -0.75f - 0.25f*_snow_intensity); @@ -160,7 +185,7 @@ bool SGPrecipitation::update(void) _precipitationEffect->setFarTransition(100.0f - 60.0f*sqrtf(_snow_intensity)); _precipitationEffect->setParticleColor(osg::Vec4(0.85, 0.85, 0.85, 1.0) - osg::Vec4(0.1, 0.1, 0.1, 1.0) * _snow_intensity); - } else if (enabled && this->_rain_intensity > 0) { + } else if (_enabled && this->_rain_intensity > 0) { _precipitationEffect->setWind(_wind_vec); _precipitationEffect->setParticleSpeed( -2.0f + -5.0f*_rain_intensity);