]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/sky/cloudfield.hxx
Merge branch 'ehofman/sound'
[simgear.git] / simgear / scene / sky / cloudfield.hxx
index dd43669b95e382072655d2af529c467574b05144..1b2f97f187bdaf5ed5a76bd4cdab2de803179e8f 100644 (file)
@@ -26,7 +26,7 @@
 #include <plib/sg.h>
 #include <simgear/compiler.h>
 #include <vector>
-#include <osgSim/Impostor>
+
 #include <osgDB/ReaderWriter>
 
 #include <osg/ref_ptr>
 #include <osg/Geometry>
 #include <osg/Group>
 #include <osg/Switch>
-#include <osg/Billboard>
+
+namespace osg
+{
+        class Fog;
+        class StateSet;
+        class Vec4f;
+}
 
 #include <simgear/misc/sg_path.hxx>
+#include <simgear/structure/Singleton.hxx>
 
 using std::vector;
 
@@ -56,6 +63,10 @@ private:
        };
 
         float Rnd(float);
+        
+        // We create a quadtree two levels deep
+        static const int BRANCH_SIZE = 16;
+        static const int QUADTREE_SIZE = 32;
 
        // this is a relative position only, with that we can move all clouds at once
        sgVec3 relative_position;
@@ -63,14 +74,24 @@ private:
 
         osg::ref_ptr<osg::Group> field_root;
         osg::ref_ptr<osg::MatrixTransform> field_transform;
-        osg::ref_ptr<osg::Switch> field_group;
+        osg::ref_ptr<osg::PositionAttitudeTransform> altitude_transform;
+        osg::ref_ptr<osg::Switch> field_group[QUADTREE_SIZE][QUADTREE_SIZE];
+        osg::ref_ptr<osg::LOD> quad[BRANCH_SIZE][BRANCH_SIZE];
+        
+        osg::ref_ptr<osg::LOD> field_lod;
 
        double deltax, deltay, alt;
-        double last_lon, last_lat, last_course;
+        double last_course;
         sgSphere field_sphere;
-       float   last_density;
-        osg::Vec3 last_pos;
-
+       float last_coverage;
+        float coverage;
+        SGGeoc cld_pos;
+        int reposition_count;
+        struct CloudFog : public simgear::Singleton<CloudFog>
+        {
+                CloudFog();
+                osg::ref_ptr<osg::Fog> fog;
+        };
 public:
 
        SGCloudField();
@@ -88,12 +109,11 @@ public:
         * @param up the local up vector
         * @param lon specifies a rotation about the Z axis
         * @param lat specifies a rotation about the new Y axis
-        * @param spin specifies a rotation about the new Z axis
-        *        (and orients the sunrise/set effects)
         * @param dt the time elapsed since the last call
+        * @param asl altitude of the layer
         */
         bool reposition( const SGVec3f& p, const SGVec3f& up,
-                        double lon, double lat, double dt = 0.0 );
+                        double lon, double lat, double dt, int asl);
 
         osg::Group* getNode() { return field_root.get(); }
 
@@ -102,17 +122,26 @@ public:
 
        static sgVec3 view_vec, view_X, view_Y;
 
-       static float density;
-       static double timer_dt;
-       static double fieldSize;
+        static float view_distance;
+        static double timer_dt;
+       static float fieldSize;
        
         bool defined3D;
 
-       static float get_density(void) { return density; }
-
-       static void set_density(float density);
-
-        void applyDensity(void);
+       float getCoverage(void) { return coverage; }
+       void setCoverage(float c) { coverage = c; }
+
+        static float getVisRange(void) { return view_distance; }
+        static void setVisRange(float d) { view_distance = d; }
+        
+        void applyCoverage(void);
+        void applyVisRange(void);
+        
+        static osg::Fog* getFog()
+        {
+                return CloudFog::instance()->fog.get();
+        }
+        static void updateFog(double visibility, const osg::Vec4f& color);
 };
 
 #endif // _CLOUDFIELD_HXX