]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/sky/cloud.hxx
Frederic Bouvier:
[simgear.git] / simgear / scene / sky / cloud.hxx
index 36746d888ca1f586cacff210e549fd080d6a91e9..cda7245f3a75ee45e36316f1d3a50b2061a77661 100644 (file)
@@ -1,5 +1,8 @@
-// cloud.hxx -- model a single cloud layer
-//
+/**
+ * \file cloud.hxx
+ * Provides a class to model a single cloud layer
+ */
+
 // Written by Curtis Olson, started June 2000.
 //
 // Copyright (C) 2000  Curtis L. Olson  - curt@flightgear.org
 #include STL_STRING
 SG_USING_STD(string);
 
+// #include <iostream>
+// SG_USING_STD(cout);
+// SG_USING_STD(endl);
 
-class SGCloudLayer {
 
+/**
+ * A class layer to model a single cloud layer
+ */
+class SGCloudLayer {
 public:
 
-    enum Type {
+    /**
+     * This is the list of available cloud coverages/textures
+     */
+    enum Coverage {
        SG_CLOUD_OVERCAST = 0,
-       SG_CLOUD_MOSTLY_CLOUDY,
-       SG_CLOUD_MOSTLY_SUNNY,
+       SG_CLOUD_BROKEN,
+       SG_CLOUD_SCATTERED,
+       SG_CLOUD_FEW,
        SG_CLOUD_CIRRUS,
        SG_CLOUD_CLEAR,
-       SG_MAX_CLOUD_TYPES
+       SG_MAX_CLOUD_COVERAGES
     };
 
-    // Constructors
+    /**
+     * Constructor
+     * @param tex_path the path to the set of cloud textures
+     */
     SGCloudLayer( const string &tex_path );
 
-    // Destructor
+    /**
+     * Destructor
+     */
     ~SGCloudLayer( void );
 
+    /** get the cloud span (in meters) */
     float getSpan_m () const;
+    /**
+     * set the cloud span
+     * @param span_m the cloud span in meters
+     */
     void setSpan_m (float span_m);
 
+    /** get the layer elevation (in meters) */
     float getElevation_m () const;
-    void setElevation_m (float elevation_m);
-
+    /**
+     * set the layer elevation.  Note that this specifies the bottom
+     * of the cloud layer.  The elevation of the top of the layer is
+     * elevation_m + thickness_m.
+     * @param elevation_m the layer elevation in meters
+     * @param set_span defines whether it is allowed to adjust the span
+     */
+    void setElevation_m (float elevation_m, bool set_span = true);
+
+    /** get the layer thickness */
     float getThickness_m () const;
+    /**
+     * set the layer thickness.
+     * @param thickness_m the layer thickness in meters.
+     */
     void setThickness_m (float thickness_m);
 
+    /**
+     * get the transition/boundary layer depth in meters.  This
+     * allows gradual entry/exit from the cloud layer via adjusting
+     * visibility.
+     */
     float getTransition_m () const;
-    void setTransition_m (float transition_m);
 
-    Type getType () const;
-    void setType (Type type);
+    /**
+     * set the transition layer size in meters
+     * @param transition_m the transition layer size in meters
+     */
+    void setTransition_m (float transition_m);
 
-    // build the cloud object
+    /** get coverage type */
+    Coverage getCoverage () const;
+
+    /**
+     * set coverage type
+     * @param coverage the coverage type
+     */
+    void setCoverage (Coverage coverage);
+
+    /**
+     * set the cloud movement direction
+     * @param dir the cloud movement direction
+     */
+    inline void setDirection(float dir) { 
+        // cout << "cloud dir = " << dir << endl;
+        direction = dir;
+    }
+
+    /** get the cloud movement direction */
+    inline float getDirection() { return direction; }
+
+    /**
+     * set the cloud movement speed 
+     * @param sp the cloud movement speed
+     */
+    inline void setSpeed(float sp) {
+        // cout << "cloud speed = " << sp << endl;
+        speed = sp;
+    }
+
+    /** get the cloud movement speed */
+    inline float getSpeed() { return speed; }
+
+    /** build the cloud object */
     void rebuild();
 
-    // repaint the cloud colors based on current value of sun_angle,
-    // sky, and fog colors.  This updates the color arrays for
-    // ssgVtxTable.
-    // sun angle in degrees relative to verticle
-    // 0 degrees = high noon
-    // 90 degrees = sun rise/set
-    // 180 degrees = darkest midnight
+    /**
+     * repaint the cloud colors based on the specified fog_color
+     * @param fog_color the fog color
+     */
     bool repaint( sgVec3 fog_color );
 
-    // reposition the cloud layer at the specified origin and
-    // orientation
-    // lon specifies a rotation about the Z axis
-    // lat specifies a rotation about the new Y axis
-    // spin specifies a rotation about the new Z axis (and orients the
-    // sunrise/set effects
-    bool reposition( sgVec3 p, sgVec3 up, double lon, double lat, double alt );
-
-    // draw the cloud layer
-    void draw();
+    /**
+     * reposition the cloud layer at the specified origin and
+     * orientation.
+     * @param p position vector
+     * @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
+     */
+    bool reposition( sgVec3 p, sgVec3 up, double lon, double lat, double alt,
+                     double dt = 0.0 );
+
+    /** draw the cloud layer */
+    void draw( bool top );
 
 private:
 
-    static ssgSimpleState *layer_states[SG_MAX_CLOUD_TYPES];
-    static int layer_sizes[SG_MAX_CLOUD_TYPES];
-
     ssgRoot *layer_root;
     ssgTransform *layer_transform;
-    ssgLeaf * layer;
+    ssgLeaf *layer[4];
+    ssgStateSelector *state_sel;
 
-    ssgColourArray *cl; 
-    ssgVertexArray *vl;
-    ssgTexCoordArray *tl;
+    ssgColourArray *cl[4]
+    ssgVertexArray *vl[4];
+    ssgTexCoordArray *tl[4];
 
     // height above sea level (meters)
     SGPath texture_path;
@@ -109,20 +186,21 @@ private:
     float layer_asl;
     float layer_thickness;
     float layer_transition;
-    Type layer_type;
+    Coverage layer_coverage;
     float scale;
+    float speed;
+    float direction;
 
     // for handling texture coordinates to simulate cloud movement
     // from winds, and to simulate the clouds being tied to ground
     // position, not view position
     // double xoff, yoff;
-    double last_lon, last_lat;
-
+    double last_lon, last_lat, last_course;
 };
 
 
 // make an ssgSimpleState for a cloud layer given the named texture
-ssgSimpleState *SGCloudMakeState( const string &path );
+ssgSimpleState *sgCloudMakeState( const string &path );
 
 
 #endif // _SG_CLOUD_HXX_