]> git.mxchange.org Git - simgear.git/commitdiff
Precipitation inside cockpit temporary fix.
authorfredb <fredb>
Sun, 14 Mar 2010 09:24:12 +0000 (09:24 +0000)
committerTim Moore <timoore33@gmail.com>
Tue, 16 Mar 2010 13:21:45 +0000 (14:21 +0100)
Needs a clip distance settable to take account of views and different cockpit size.

simgear/environment/precipitation.cxx
simgear/environment/precipitation.hxx

index 05b1b447091e83f2e4514bbe438d9d0d605cc6d8..075fac1d868744611c8183b66201feeef0c46d39 100644 (file)
@@ -28,6 +28,7 @@
 #include "visual_enviro.hxx"
 
 #include <simgear/constants.h>
+#include <osg/ClipNode>
 
 /**
  * @brief SGPrecipitation constructor
@@ -35,7 +36,7 @@
  * Build a new OSG object from osgParticle.
  */
 SGPrecipitation::SGPrecipitation() :
-    _freeze(false), _snow_intensity(0.0), _rain_intensity(0.0)
+    _freeze(false), _snow_intensity(0.0), _rain_intensity(0.0), _clip_distance(5.0)
 {
     _precipitationEffect = new osgParticle::PrecipitationEffect;
 }
@@ -54,7 +55,20 @@ osg::Group* SGPrecipitation::build(void)
     _precipitationEffect->snow(0);     
     _precipitationEffect->rain(0);     
 
-    group->addChild(_precipitationEffect.get());
+    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;
 }
index 80a08aeae1d14590e0e4f9ebef6072619283cd6b..bcf568c63708c2a5cc6e3ed71c82bf1b2d4a5faa 100644 (file)
@@ -39,6 +39,7 @@ private:
 
     float _snow_intensity;
     float _rain_intensity;
+    float _clip_distance;
        
     int _wind_dir;
     osg::Vec3 _wind_vec;