00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _VISUAL_ENVIRO_HXX
00023 #define _VISUAL_ENVIRO_HXX
00024
00025 #include <plib/sg.h>
00026
00027 #include <simgear/compiler.h>
00028 #include <string>
00029 #include <vector>
00030
00031 using std::vector;
00032 using std::string;
00033
00034 class SGLightning;
00035 class SGSampleGroup;
00036
00041 class SGWxRadarEcho {
00042 public:
00043 SGWxRadarEcho(float _heading, float _alt, float _radius, float _dist,
00044 double _LWC, bool _lightning, int _cloudId ) :
00045 heading( _heading ),
00046 alt ( _alt ),
00047 radius ( _radius ),
00048 dist ( _dist ),
00049 LWC ( _LWC ),
00050 lightning ( _lightning ),
00051 cloudId ( _cloudId )
00052 {}
00053
00055 float heading;
00056 float alt, radius, dist;
00058 double LWC;
00060 bool lightning;
00062 int cloudId;
00063 };
00064
00065 typedef vector<SGWxRadarEcho> list_of_SGWxRadarEcho;
00066
00070 class SGEnviro {
00071 friend class SGLightning;
00072 private:
00073 void DrawCone2(float baseRadius, float height, int slices, bool down, double rain_norm, double speed);
00074 void lt_update(void);
00075
00076 bool view_in_cloud;
00077 bool precipitation_enable_state;
00078 float precipitation_density;
00079 float precipitation_max_alt;
00080 bool turbulence_enable_state;
00081 double last_cloud_turbulence, cloud_turbulence;
00082 bool lightning_enable_state;
00083 double elapsed_time, dt;
00084 sgVec4 fog_color;
00085 sgMat4 transform;
00086 double last_lon, last_lat, last_alt;
00087 SGSampleGroup *sampleGroup;
00088 bool snd_active, snd_playing;
00089 double snd_timer, snd_wait, snd_pos_lat, snd_pos_lon, snd_dist;
00090 double min_time_before_lt;
00091
00092 float fov_width, fov_height;
00093
00095 list_of_SGWxRadarEcho radarEcho;
00096 static sgVec3 min_light;
00097 static SGfloat streak_bright_nearmost_layer,
00098 streak_bright_farmost_layer,
00099 streak_period_max,
00100 streak_period_change_per_kt,
00101 streak_period_min,
00102 streak_length_min,
00103 streak_length_change_per_kt,
00104 streak_length_max;
00105 static int streak_count_min, streak_count_max;
00106 static SGfloat cone_base_radius,
00107 cone_height;
00108
00109 public:
00110 SGEnviro();
00111 ~SGEnviro();
00112
00119 void config(const class SGPropertyNode* precip_rendering_cfgNode);
00120
00124 void startOfFrame( sgVec3 p, sgVec3 up, double lon, double lat, double alt, double delta_time);
00125
00126 void endOfFrame(void);
00127
00128 #if 0
00129
00137 void callback_cloud(float heading, float alt, float radius, int family, float dist, int cloudId);
00138 #endif
00139 void drawRain(double pitch, double roll, double heading, double hspeed, double rain_norm);
00149 void drawPrecipitation(double rain_norm, double snow_norm, double hail_norm,
00150 double pitch, double roll, double heading, double hspeed);
00151
00155 void drawLightning(void);
00156
00161 void setLight(sgVec4 adj_fog_color);
00162
00163
00164 bool is_view_in_cloud(void) const;
00165 void set_view_in_cloud(bool incloud);
00166 double get_cloud_turbulence(void) const;
00167
00168
00169
00170 int get_clouds_CacheSize(void) const;
00171 int get_CacheResolution(void) const;
00172 float get_clouds_visibility(void) const;
00173 float get_clouds_density(void) const;
00174 bool get_clouds_enable_state(void) const;
00175 bool get_turbulence_enable_state(void) const;
00176
00181 void set_clouds_CacheSize(int sizeKb);
00186 void set_CacheResolution(int resolutionPixels);
00192 void set_clouds_visibility(float distance);
00197 void set_clouds_density(float density);
00202 void set_clouds_enable_state(bool enable);
00207 void set_turbulence_enable_state(bool enable);
00208
00209
00210 float get_precipitation_density(void) const;
00211 bool get_precipitation_enable_state(void) const;
00212
00219 void set_precipitation_density(float density);
00224 void set_precipitation_enable_state(bool enable);
00225
00226
00227 bool get_lightning_enable_state(void) const;
00232 void set_lightning_enable_state(bool enable);
00233
00240 void addLightning(double lon, double lat, double alt);
00241
00246 void set_sampleGroup(SGSampleGroup *sgr);
00247
00248 void setFOV( float w, float h );
00249 void getFOV( float &w, float &h );
00250
00251 list_of_SGWxRadarEcho *get_radar_echo(void);
00252
00253 sgMat4 *get_transform(void) { return &transform; }
00254 };
00255
00256 extern SGEnviro sgEnviro;
00257
00258 #endif // _VISUAL_ENVIRO_HXX