]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/sky/sky.hxx
Update the SoundSample api so we can request that a copy of the sample be
[simgear.git] / simgear / scene / sky / sky.hxx
index 95b5ecba150c7ed718cc6fd224ded32673b2a594..166e717f3605e4c821952b496203f32fbcd75e66 100644 (file)
 
 #include <vector>
 
-#include <simgear/sky/cloud.hxx>
-#include <simgear/sky/dome.hxx>
-#include <simgear/sky/moon.hxx>
-#include <simgear/sky/oursun.hxx>
-#include <simgear/sky/stars.hxx>
+#include <simgear/scene/sky/cloud.hxx>
+#include <simgear/scene/sky/dome.hxx>
+#include <simgear/scene/sky/moon.hxx>
+#include <simgear/scene/sky/oursun.hxx>
+#include <simgear/scene/sky/stars.hxx>
 
 SG_USING_STD(vector);
 
@@ -55,6 +55,21 @@ typedef vector < SGCloudLayer* > layer_list_type;
 typedef layer_list_type::iterator layer_list_iterator;
 typedef layer_list_type::const_iterator layer_list_const_iterator;
 
+typedef struct {
+       float *view_pos, *zero_elev, *view_up;
+       double lon, lat, alt, spin;
+       double gst;
+       double sun_ra, sun_dec, sun_dist;
+       double moon_ra, moon_dec, moon_dist;
+} SGSkyState;
+
+typedef struct {
+       float *sky_color, *fog_color, *cloud_color;
+       double sun_angle, moon_angle;
+       int nplanets, nstars;
+       sgdVec3 *planet_data, *star_data;
+} SGSkyColor;
+
 /**
  * A class to model a realistic (time/date/position) based sky.
  *
@@ -80,10 +95,10 @@ typedef layer_list_type::const_iterator layer_list_const_iterator;
  * texture_path() method.
 
  * The arguments you pass to the build() method allow you to specify
- * the size of your sun sphere and moon sphere, a number of planets,
- * and a multitude of stars.  For the planets and stars you pass in an
- * array of right ascensions, declinations, magnitudes, and the
- * distance from the view point.
+ * the horizontal and vertical radiuses of the sky dome, the size of
+ * your sun sphere and moon sphere, a number of planets, and a
+ * multitude of stars.  For the planets and stars you pass in an array
+ * of right ascensions, declinations, and magnitudes.
 
  * Cloud Layers 
 
@@ -128,22 +143,27 @@ typedef layer_list_type::const_iterator layer_list_const_iterator;
 
  * Rendering the Sky 
 
- * The sky is designed to be rendered in two stages. The first stage
+ * The sky is designed to be rendered in three stages. The first stage
  * renders the parts that form your back drop - the sky dome, the
  * stars and planets, the sun, and the moon.  These should be rendered
  * before the rest of your scene by calling the preDraw() method. The
- * second stage renders the clouds which are likely to be translucent
- * (depending on type) and should be drawn after your scene has been
- * rendered.  Use the postDraw() method to draw the second stage of
- * the sky.
+ * second stage renders the clouds that are above the viewer. This stage 
+ * is done before translucent objects in the main scene are drawn. It 
+ * is seperated from the preDraw routine to enable to implement a 
+ * multi passes technique and is located in the drawUpperClouds() method.
+ * The third stage renders the clouds that are below the viewer an which 
+ * are likely to be translucent (depending on type) and should be drawn 
+ * after your scene has been rendered.  Use the drawLowerClouds() method 
+ * to draw the second stage of the sky.
 
  * A typical application might do the following: 
 
- * <li> thesky->preDraw();
+ * <li> thesky->preDraw( my_altitude );
+ * <li> thesky->drawUpperClouds();
  * <li> ssgCullAndDraw ( myscene ) ;
- * <li> thesky->postDraw( my_altitude );
+ * <li> thesky->drawLowerClouds();
 
- * The current altitude in meters is passed to the postDraw() method
+ * The current altitude in meters is passed to the preDraw() method
  * so the clouds layers can be rendered correction from most distant
  * to closest.
 
@@ -204,6 +224,9 @@ private:
     float visibility;
     float effective_visibility;
 
+    int in_cloud;
+    int cur_layer_pos;
+
     // near cloud visibility state variables
     bool in_puff;
     double puff_length;                // in seconds
@@ -223,19 +246,21 @@ public:
      * Initialize the sky and connect the components to the scene
      * graph at the provided branch.  See discussion in detailed class
      * description.
+     * @param h_radius_m horizontal radius of sky dome
+     * @param v_radius_m vertical radius of sky dome
      * @param sun_size size of sun
      * @param moon_size size of moon
      * @param nplanets number of planets
      * @param planet_data an array of planet right ascensions, declinations,
      *        and magnitudes
-     * @param planet_dist distance from viewer to put the planets
      * @param nstars number of stars
      * @param star_data an array of star right ascensions, declinations,
      *        and magnitudes
-     * @param star_dist distance from viewer to put the stars */
-    void build( double sun_size, double moon_size,
-               int nplanets, sgdVec3 *planet_data, double planet_dist,
-               int nstars, sgdVec3 *star_data, double star_dist );
+     */
+    void build( double h_radius_m, double v_radius_m,
+                double sun_size, double moon_size,
+               int nplanets, sgdVec3 *planet_data,
+               int nstars, sgdVec3 *star_data );
 
     /**
      * Repaint the sky components based on current value of sun_angle,
@@ -261,10 +286,7 @@ public:
      * @param star_data an array of star right ascensions, declinations,
      *        and magnitudes
      */
-    bool repaint( sgVec4 sky_color, sgVec4 fog_color,
-                 double sun_angle, double moon_angle,
-                 int nplanets, sgdVec3 *planet_data,
-                 int nstars, sgdVec3 *star_data );
+    bool repaint( const SGSkyColor &sc );
 
     /**
      * Reposition the sky at the specified origin and orientation
@@ -294,11 +316,7 @@ public:
      * @param moon_dec the moon's current declination
      * @param moon_dist the moon's distance from the current view point. 
      */
-    bool reposition( sgVec3 view_pos, sgVec3 zero_elev, sgVec3 view_up,
-                    double lon, double lat, double alt, double spin,
-                    double gst, 
-                    double sun_ra, double sun_dec, double sun_dist,
-                    double moon_ra, double moon_dec, double moon_dist );
+    bool reposition( SGSkyState &st, double dt = 0.0 );
 
     /**
      * Modify the given visibility based on cloud layers, thickness,
@@ -314,16 +332,24 @@ public:
      * Draw background portions of the sky ... do this before you draw
      * the rest of your scene.  See discussion in detailed
      * class description.
+     * @param alt current altitude
+     */
+    void preDraw( float alt, float fog_exp2_density );
+
+    /**
+     * Draw upper translucent clouds ... do this before you've drawn 
+     * all the translucent elements of your scene.  See discussion in 
+     * detailed class description.
+     * @param fog_exp2_density fog density of the current cloud layer
      */
-    void preDraw();
+    void drawUpperClouds();
 
     /**
-     * Draw translucent clouds ... do this after you've drawn all the
-     * oapaque elements of your scene.  See discussion in detailed
+     * Draw lower translucent clouds ... do this after you've drawn 
+     * all the opaque elements of your scene.  See discussion in detailed
      * class description.
-     * @param alt current altitude
      */
-    void postDraw( float alt );
+    void drawLowerClouds();
 
     /** 
      * Specify the texture path (optional, defaults to current directory)
@@ -348,6 +374,13 @@ public:
        post_selector->select( 0 );
     }
 
+
+    /**
+     * Get the current sun color
+     */
+    inline float *get_sun_color() { return oursun->get_color(); }
+
+
     /**
      * Add a cloud layer.
      *
@@ -395,7 +428,7 @@ public:
      * @param v visibility in meters
      */
     inline void set_visibility( float v ) {
-       effective_visibility = visibility = v;
+       effective_visibility = visibility = (v <= 25.0) ? 25.0 : v;
     }
 };