-osg::Group* SGPrecipitation::build(void) {
- group = new osg::Group;
-
- precipitationEffect->snow(0);
- precipitationEffect->rain(0);
-
- group->addChild(precipitationEffect.get());
-
- return group;
+osg::Group* SGPrecipitation::build(void)
+{
+ osg::Group* group = new osg::Group;
+
+ _precipitationEffect->snow(0);
+ _precipitationEffect->rain(0);
+
+ if (_clip_distance!=0.0)
+ {
+ osg::ref_ptr<osg::ClipNode> 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());
+ }
+
+ return group;