1 // Visual environment helper class
3 // Written by Harald JOHNSEN, started April 2005.
5 // Copyright (C) 2005 Harald JOHNSEN - hjohnsen@evc.net
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
22 #ifndef _VISUAL_ENVIRO_HXX
23 #define _VISUAL_ENVIRO_HXX
25 #include <simgear/compiler.h>
34 * Simulate some echo on a weather radar.
35 * Container class for the wx radar instrument.
39 SGWxRadarEcho(float _heading, float _alt, float _radius, float _dist, double _LWC, bool _lightning, int _cloudId) :
45 lightning ( _lightning ),
49 /** the heading in radian is versus north */
51 float alt, radius, dist;
52 /** reflectivity converted to liquid water content. */
54 /** if true then this data is for a lightning else it is for water echo. */
56 /** Unique identifier of cloud */
60 typedef vector<SGWxRadarEcho> list_of_SGWxRadarEcho;
63 * Visual environment helper class.
66 friend class SGLightning;
68 void DrawCone2(float baseRadius, float height, int slices, bool down, double rain_norm, double speed);
72 bool precipitation_enable_state;
73 float precipitation_density;
74 float precipitation_max_alt;
75 bool turbulence_enable_state;
76 double last_cloud_turbulence, cloud_turbulence;
77 bool lightning_enable_state;
78 double elapsed_time, dt;
81 double last_lon, last_lat, last_alt;
83 bool snd_active, snd_playing;
84 double snd_timer, snd_wait, snd_pos_lat, snd_pos_lon, snd_dist;
85 double min_time_before_lt;
87 float fov_width, fov_height;
89 /** a list of all the radar echo. */
90 list_of_SGWxRadarEcho radarEcho;
97 * Forward a few states used for renderings.
99 void startOfFrame( sgVec3 p, sgVec3 up, double lon, double lat, double alt, double delta_time);
101 void endOfFrame(void);
104 * Whenever a cloud is drawn we check his 'impact' on the environment.
105 * @param heading direction of cloud in radians
106 * @param alt asl of cloud in meters
107 * @param radius radius of cloud in meters
108 * @param familly cloud familly
109 * @param dist squared dist to cloud in meters
111 void callback_cloud(float heading, float alt, float radius, int familly, float dist, int cloudId);
113 void drawRain(double pitch, double roll, double heading, double speed, double rain_norm);
115 * Draw rain or snow precipitation around the viewer.
116 * @param rain_norm rain normalized intensity given by metar class
117 * @param snow_norm snow normalized intensity given by metar class
118 * @param hail_norm hail normalized intensity given by metar class
119 * @param pitch pitch rotation of viewer
120 * @param roll roll rotation of viewer
121 * @param speed moving speed of viewer in kt
123 void drawPrecipitation(double rain_norm, double snow_norm, double hail_norm,
124 double pitch, double roll, double heading, double speed);
127 * Draw the lightnings spawned by cumulo nimbus.
129 void drawLightning(void);
132 * Forward the fog color used by the rain rendering.
133 * @param adj_fog_color color of the fog
135 void setLight(sgVec4 adj_fog_color);
137 // this can be queried to add some turbulence for example
138 bool is_view_in_cloud(void) const;
139 void set_view_in_cloud(bool incloud);
140 double get_cloud_turbulence(void) const;
143 // return the size of the memory pool used by texture impostors
144 int get_clouds_CacheSize(void) const;
145 int get_CacheResolution(void) const;
146 float get_clouds_visibility(void) const;
147 float get_clouds_density(void) const;
148 bool get_clouds_enable_state(void) const;
149 bool get_turbulence_enable_state(void) const;
152 * Set the size of the impostor texture cache for 3D clouds.
153 * @param sizeKb size of the texture pool in Kb
155 void set_clouds_CacheSize(int sizeKb);
157 * Set the resolution of the impostor texture for 3D clouds.
158 * @param resolutionPixels size of each texture in pixels (64|128|256)
160 void set_CacheResolution(int resolutionPixels);
162 * Set the maximum range used when drawing clouds.
163 * Clouds are blended from totaly transparent at max range to totaly opaque around the viewer
164 * @param distance in meters
166 void set_clouds_visibility(float distance);
168 * Set the proportion of clouds that will be rendered to limit drop in FPS.
169 * @param density 0..100 no clouds drawn when density == 0, all are drawn when density == 100
171 void set_clouds_density(float density);
173 * Enable or disable the use of 3D clouds.
174 * @param enable when false we draw the 2D layers
176 void set_clouds_enable_state(bool enable);
178 * Enable or disable the use of proximity cloud turbulence.
179 * @param enable when true the turbulence is computed based on type of cloud around the AC
181 void set_turbulence_enable_state(bool enable);
184 float get_precipitation_density(void) const;
185 bool get_precipitation_enable_state(void) const;
187 void set_precipitation_density(float density);
189 * Enable or disable the rendering of precipitation around the viewer.
190 * @param enable when true we will draw precipitation depending on metar data
192 void set_precipitation_enable_state(bool enable);
195 bool get_lightning_enable_state(void) const;
197 * Enable or disable the rendering of lightning and the thunder sound.
198 * @param enable when true we will draw lightning spwaned by cumulonimbus
200 void set_lightning_enable_state(bool enable);
203 * Spawn a new lighning at specified lon/lat.
204 * @param lon position of the new lightning
205 * @param lat position of the new lightning
206 * @param alt asl of the starting point of the lightning in meters
208 void addLightning(double lon, double lat, double alt);
211 * Forward the sound manager instance to be able to play samples.
212 * @param mgr a running sound manager
214 void set_soundMgr(SGSoundMgr *mgr);
216 void setFOV( float w, float h );
217 void getFOV( float &w, float &h );
219 list_of_SGWxRadarEcho *get_radar_echo(void);
222 extern SGEnviro sgEnviro;
224 #endif // _VISUAL_ENVIRO_HXX