]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/sky/newcloud.hxx
Fix path in include directive
[simgear.git] / simgear / scene / sky / newcloud.hxx
index b3a2846f2739f60780aa5c886006ded922ddb1b1..f6e55733dec0bff9479867eb2182bb657c108523 100644 (file)
 #ifndef _NEWCLOUD_HXX
 #define _NEWCLOUD_HXX
 
-#include <plib/sg.h>
 #include <simgear/compiler.h>
 #include <string>
 #include <vector>
+#include <osg/Fog>
 
-#include "bbcache.hxx"
+#include <simgear/scene/material/Effect.hxx>
+#include <simgear/scene/material/EffectGeode.hxx>
 
 using std::string;
 using std::vector;
@@ -39,137 +40,71 @@ using std::vector;
 class SGNewCloud {
 
 public:
-       enum CLFamilly_type {
-               CLFamilly_cu = 0,
-               CLFamilly_cb,
-               CLFamilly_st,
-               CLFamilly_ns,
-               CLFamilly_sc,
-               CLFamilly_as,
-               CLFamilly_ac,
-               CLFamilly_ci,
-               CLFamilly_cc,
-               CLFamilly_cs,
-               CLFamilly_nn
-       };
-       SGNewCloud(CLFamilly_type classification=CLFamilly_nn);
-       SGNewCloud(string classification);
-       ~SGNewCloud();
-
-       enum CLbox_type {
-               CLbox_standard = 0,
-               CLbox_sc = 1,
-               CLbox_cumulus = 2,
-               CLbox_stratus = 3
-       };
-
-       enum CLTexture_type {
-               CLTexture_cumulus = 1,
-               CLTexture_stratus = 2,
-               CLTexture_max
-       };
+        SGNewCloud(const SGPath &texture_root, const SGPropertyNode *cld_def);
 
-private:
-
-       class spriteDef {
-       public:
-               sgVec3          pos;
-               float           r;
-               CLbox_type      sprite_type;
-               sgVec4          l0, l1, l2, l3;
-               sgVec3          normal, n0, n1, n2, n3;
-               int                     rank;
-               int                     box;
-               float           dist;           // distance used during sort
-               bool operator<(const spriteDef &b) const {
-                       return (this->dist < b.dist);
-               }
-       };
-
-       typedef struct {
-               sgVec3          pos;
-               float           r;
-               // the type defines how the sprites can be positioned inside the box, their size, etc
-               CLbox_type      cont_type;
-               sgVec3          center;
-       } spriteContainer;
-
-       typedef vector<spriteDef>               list_of_spriteDef;
-       typedef vector<spriteContainer> list_of_spriteContainer;
-
-       void init(void);
-
-       void computeSimpleLight(sgVec3 eyePos);
-       void addSprite(float x, float y, float z, float r, CLbox_type type, int box);
-
-       // sort on distance to eye because of transparency
-       void sortSprite( sgVec3 eyePos );
-
-       // render the cloud on screen or on the RTT texture to build the impostor
-       void Render3Dcloud( bool drawBB, sgVec3 eyePos, sgVec3 deltaPos, float dist_center );
-
-       // compute rotations so that a quad is facing the camera
-       void CalcAngles(sgVec3 refpos, sgVec3 eyePos, float *angleY, float *angleX);
-
-       // draw a cloud but this time we use the impostor texture
-       void RenderBB(sgVec3 deltaPos, bool first_time, float dist_center);
-
-       // determine if it is a good idea to use an impostor to render the cloud
-       bool isBillboardable(float dist);
-
-       int             cloudId, bbId;
-       sgVec3  rotX, rotY;
-
-//     int             rank;
-       sgVec3  cloudpos, center;
-       float   delta_base;
-       list_of_spriteDef               list_spriteDef;
-       list_of_spriteContainer list_spriteContainer;
-       float radius;
-       CLFamilly_type familly;
-
-       // fading data
-       bool direction, fadeActive;
-       float duration, pauseLength, fadetimer;
-       float last_step;
-
-public:
-       // add a new box to the cloud
-       void addContainer(float x, float y, float z, float r, CLbox_type type);
-
-       // generate all sprite with defined boxes
-       void genSprites(void);
+        ~SGNewCloud();
 
-       // debug only, define a cumulus
-       void new_cu(void);
+        // Generate a Cloud
+        osg::ref_ptr<simgear::EffectGeode> genCloud ();
 
-       // debug only
-       void drawContainers(void);
+        static float getDensity(void)
+        {
+            return sprite_density;
+        }
+    
+        // Set the sprite density
+        static void setDensity(double d)
+        {
+            sprite_density = d;
+        }
+        
 
-       // define the new position of the cloud (inside the cloud field, not on sphere)
-       void SetPos(sgVec3 newPos);
-
-       // render the cloud, fakepos is a relative position inside the cloud field
-       void Render(sgVec3 fakepos);
+private:
 
-       // 
-       void startFade(bool direction, float duration, float pauseLength);
-       void setFade(float howMuch);
+        float min_width;
+        float max_width;
+        float min_height;
+        float max_height;
+        float min_sprite_width;
+        float max_sprite_width;
+        float min_sprite_height;
+        float max_sprite_height;
+        
+        // Minimum and maximum bottom, middle, top, sunny, shade lighting
+        // factors. For individual clouds we choose a bottom/middle/top
+        // shade from between each min/max value
+        float min_bottom_lighting_factor;
+        float max_bottom_lighting_factor;
+        float min_middle_lighting_factor;
+        float max_middle_lighting_factor;
+        float min_top_lighting_factor;
+        float max_top_lighting_factor;
+        float min_shade_lighting_factor;
+        float max_shade_lighting_factor;
+        
+        // The density of the cloud is the shading applied
+        // to cloud sprites on the opposite side of the cloud
+        // from the sun. For an invidual cloud instance a value
+        // between min_density and max_density is chosen.
+        float min_density;
+        float max_density;
+        
+        // zscale indicates how sprites should be scaled vertically
+        // after billboarding. 
+        float zscale;
+        bool height_map_texture;
+        int num_sprites;
+        int num_textures_x;
+        int num_textures_y;
+        string texture;
+        osg::Geometry* quad;
+        osg::ref_ptr<simgear::Effect> effect;
+        static float sprite_density;
+
+        osg::Geometry* createOrthQuad(float w, float h, int varieties_x, int varieties_y);
 
-       inline float getRadius() { return radius; }
-       inline sgVec3 *getCenter() { return &center; }
-       inline int getId() { return cloudId; }
+};
 
-       inline CLFamilly_type getFamilly(void) { return familly; }
 
-       // load all textures used to draw cloud sprites
-       static void loadTextures( const string &tex_path );
-       static sgVec3 modelSunDir;
-       static sgVec3 sunlight, ambLight;
-       static bool useAnisotropic;
-       static float nearRadius;
-       static bool lowQuality;
-       static SGBbCache        *cldCache;
-};
 
 #endif // _NEWCLOUD_HXX