]> git.mxchange.org Git - simgear.git/blobdiff - simgear/environment/visual_enviro.hxx
Optionally use HTTP repository.
[simgear.git] / simgear / environment / visual_enviro.hxx
index 695e14440532d983cc824ab5fbf3a4c0d6a11871..9f6788e8260df754f71c345c41e03ef65de11757 100644 (file)
 //
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
-// Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //
 //
 #ifndef _VISUAL_ENVIRO_HXX
 #define _VISUAL_ENVIRO_HXX
 
 #include <simgear/compiler.h>
-#include STL_STRING
+#include <string>
+#include <vector>
 
-SG_USING_STD(string);
+#include <simgear/math/SGMath.hxx>
 
 class SGLightning;
-class SGSoundMgr;
+class SGSampleGroup;
+
+/**
+ * Simulate some echo on a weather radar.
+ * Container class for the wx radar instrument.
+ */
+class SGWxRadarEcho {
+public:
+       SGWxRadarEcho(float _heading, float _alt, float _radius, float _dist,
+                       double _LWC, bool _lightning, int _cloudId ) :
+         heading( _heading ),
+         alt ( _alt ),
+         radius ( _radius ),
+         dist ( _dist ),
+         LWC ( _LWC ),
+         lightning ( _lightning ),
+         cloudId ( _cloudId )
+       {}
+
+       /** the heading in radian is versus north */
+       float heading;
+       float alt, radius, dist;
+       /** reflectivity converted to liquid water content. */
+       double LWC;
+       /** if true then this data is for a lightning else it is for water echo. */
+       bool lightning;
+       /** Unique identifier of cloud */
+       int cloudId;
+};
+
+typedef std::vector<SGWxRadarEcho> list_of_SGWxRadarEcho;
 
 /**
  * Visual environment helper class.
  */
 class SGEnviro {
-friend SGLightning;
+friend class SGLightning;
 private:
        void DrawCone2(float baseRadius, float height, int slices, bool down, double rain_norm, double speed);
        void lt_update(void);
@@ -42,42 +73,67 @@ private:
        bool view_in_cloud;
        bool precipitation_enable_state;
        float precipitation_density;
+       float precipitation_max_alt;
        bool turbulence_enable_state;
        double last_cloud_turbulence, cloud_turbulence;
        bool lightning_enable_state;
        double elapsed_time, dt;
-       sgVec4  fog_color;
-       sgMat4 transform;
+       SGVec4f fog_color;
+       SGMatrixf transform;
        double last_lon, last_lat, last_alt;
-       SGSoundMgr      *soundMgr;
+       SGSampleGroup   *sampleGroup;
        bool            snd_active, snd_playing;
        double          snd_timer, snd_wait, snd_pos_lat, snd_pos_lon, snd_dist;
        double          min_time_before_lt;
 
        float fov_width, fov_height;
 
+       /** a list of all the radar echo. */
+       list_of_SGWxRadarEcho radarEcho;
+       static SGVec3f min_light;
+       static float streak_bright_nearmost_layer,
+                                  streak_bright_farmost_layer,
+                                  streak_period_max,
+                                  streak_period_change_per_kt,
+                                  streak_period_min,
+                                  streak_length_min,
+                                  streak_length_change_per_kt,
+                                  streak_length_max;
+       static int streak_count_min, streak_count_max;
+       static float cone_base_radius,
+                                  cone_height;
+
 public:
        SGEnviro();
        ~SGEnviro();
 
+       /** Read the config from the precipitation rendering config properties.
+        * @param precip_rendering_cfgNode "/sim/rendering/precipitation" in fg
+        * Set from whatever info present in the
+        * subnodes passed, substituting hardwired defaults for missing fields.
+        * If NULL is given, do nothing.
+        */
+       void config(const class SGPropertyNode* precip_rendering_cfgNode);
+
     /**
      * Forward a few states used for renderings.
      */
-       void startOfFrame( sgVec3 p, sgVec3 up, double lon, double lat, double alt, double delta_time);
+       void startOfFrame( SGVec3f p, SGVec3f up, double lon, double lat, double alt, double delta_time);
 
        void endOfFrame(void);
 
+#if 0
     /**
      * Whenever a cloud is drawn we check his 'impact' on the environment.
      * @param heading direction of cloud in radians
      * @param alt asl of cloud in meters
      * @param radius radius of cloud in meters
-     * @param familly cloud familly
+     * @param family cloud family
      * @param dist  squared dist to cloud in meters
      */
-       void callback_cloud(float heading, float alt, float radius, int familly, float dist);
-
-       void drawRain(double pitch, double roll, double speed, double rain_norm);
+       void callback_cloud(float heading, float alt, float radius, int family, float dist, int cloudId);
+#endif
+       void drawRain(double pitch, double roll, double heading, double hspeed, double rain_norm);
     /**
      * Draw rain or snow precipitation around the viewer.
      * @param rain_norm rain normalized intensity given by metar class
@@ -85,10 +141,10 @@ public:
      * @param hail_norm hail normalized intensity given by metar class
      * @param pitch pitch rotation of viewer
      * @param roll roll rotation of viewer
-     * @param speed moving speed of viewer in kt
+     * @param hspeed moving horizontal speed of viewer in kt
      */
        void drawPrecipitation(double rain_norm, double snow_norm, double hail_norm,
-                                                       double pitch, double roll, double speed);
+                                                       double pitch, double roll, double heading, double hspeed);
 
     /**
      * Draw the lightnings spawned by cumulo nimbus.
@@ -99,7 +155,7 @@ public:
      * Forward the fog color used by the rain rendering.
      * @param adj_fog_color color of the fog
      */
-       void setLight(sgVec4 adj_fog_color);
+       void setLight(SGVec4f adj_fog_color);
 
        // this can be queried to add some turbulence for example
        bool is_view_in_cloud(void) const;
@@ -151,6 +207,12 @@ public:
        float get_precipitation_density(void) const;
        bool get_precipitation_enable_state(void) const;
 
+       /** 
+        * Decrease the precipitation density to the given percentage.
+        * (Only show the given percentage of rain streaks etc.)
+        * Default precipitation density upon construction is 100.0.
+        * @param density 0.0 to 100.0
+        */
        void set_precipitation_density(float density);
     /**
      * Enable or disable the rendering of precipitation around the viewer.
@@ -178,11 +240,14 @@ public:
      * Forward the sound manager instance to be able to play samples.
      * @param mgr a running sound manager
      */
-       void set_soundMgr(SGSoundMgr *mgr);
+       void set_sampleGroup(SGSampleGroup *sgr);
 
        void setFOV( float w, float h );
        void getFOV( float &w, float &h );
 
+       list_of_SGWxRadarEcho *get_radar_echo(void);
+
+       SGMatrixf *get_transform(void) { return &transform; }
 };
 
 extern SGEnviro sgEnviro;