]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/model/particles.hxx
Work around apparent OSG 3.2.0 normal binding bug.
[simgear.git] / simgear / scene / model / particles.hxx
index 4c9d5053f63bd55038ad14f57ffe0056612aea47..cdbb1f21af317e456b1fa8d42ddc0fedc9673731 100644 (file)
@@ -75,7 +75,7 @@ public:
     }
 
     virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);
-    
+
     static const osg::Vec3 &getGravityVector()
     {
         return gravity;
@@ -86,10 +86,22 @@ public:
         return wind;
     }
 
+    static void setSwitch(const SGPropertyNode* n)
+    {
+        enabledNode = n;
+    }
+
+    static bool getEnabled()
+    {
+        return enabled;
+    }
+
 private:
     static osg::Vec3 gravity;
     static osg::Vec3 wind;
-    const SGPropertyNode* modelRoot;
+    SGConstPropertyNode_ptr modelRoot;
+    static SGConstPropertyNode_ptr enabledNode;
+    static bool enabled;
 };
 
 
@@ -99,7 +111,7 @@ class Particles : public osg::NodeCallback
 public:
     Particles();
 
-    static osg::Group * appendParticles(const SGPropertyNode* configNode, SGPropertyNode* modelRoot, const osgDB::ReaderWriter::Options* options);
+    static osg::Group * appendParticles(const SGPropertyNode* configNode, SGPropertyNode* modelRoot, const osgDB::Options* options);
 
     virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);
 
@@ -237,12 +249,21 @@ public:
         return psu.get();
     }
 
+    static void setFrozen(bool e) { _frozen = e; }
+
     /**
      *  Set and get the wind vector for particles in the
      * atmosphere. This vector is in the Z-up Y-north frame, and the
      * magnitude is the velocity in meters per second.
      */
     static void setWindVector(const osg::Vec3& wind) { _wind = wind; }
+    static void setWindFrom(const double from_deg, const double speed_kt) {
+       double map_rad = -from_deg * SG_DEGREES_TO_RADIANS;
+       double speed_mps = speed_kt * SG_KT_TO_MPS;
+       _wind[0] = cos(map_rad) * speed_mps;
+       _wind[1] = sin(map_rad) * speed_mps;
+       _wind[2] = 0.0;
+    }
     static const osg::Vec3& getWindVector() { return _wind; }
 protected:
     float shooterExtraRange;
@@ -267,6 +288,7 @@ protected:
     
     bool useGravity;
     bool useWind;
+    static bool _frozen;
     static osg::ref_ptr<osgParticle::ParticleSystemUpdater> psu;
     static osg::ref_ptr<osg::Group> commonRoot;
     static osg::ref_ptr<osg::Geode> commonGeode;