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 * Visual environment helper class.
39 void DrawCone2(float baseRadius, float height, int slices, bool down, double rain_norm, double speed);
43 bool precipitation_enable_state;
44 float precipitation_density;
45 bool turbulence_enable_state;
46 double last_cloud_turbulence, cloud_turbulence;
47 bool lightning_enable_state;
48 double elapsed_time, dt;
51 double last_lon, last_lat, last_alt;
53 bool snd_active, snd_playing;
54 double snd_timer, snd_wait, snd_pos_lat, snd_pos_lon, snd_dist;
55 double min_time_before_lt;
57 float fov_width, fov_height;
64 * Forward a few states used for renderings.
66 void startOfFrame( sgVec3 p, sgVec3 up, double lon, double lat, double alt, double delta_time);
68 void endOfFrame(void);
71 * Whenever a cloud is drawn we check his 'impact' on the environment.
72 * @param heading direction of cloud in radians
73 * @param alt asl of cloud in meters
74 * @param radius radius of cloud in meters
75 * @param familly cloud familly
76 * @param dist squared dist to cloud in meters
78 void callback_cloud(float heading, float alt, float radius, int familly, float dist);
80 void drawRain(double pitch, double roll, double speed, double rain_norm);
82 * Draw rain or snow precipitation around the viewer.
83 * @param rain_norm rain normalized intensity given by metar class
84 * @param snow_norm snow normalized intensity given by metar class
85 * @param hail_norm hail normalized intensity given by metar class
86 * @param pitch pitch rotation of viewer
87 * @param roll roll rotation of viewer
88 * @param speed moving speed of viewer in kt
90 void drawPrecipitation(double rain_norm, double snow_norm, double hail_norm,
91 double pitch, double roll, double speed);
94 * Draw the lightnings spawned by cumulo nimbus.
96 void drawLightning(void);
99 * Forward the fog color used by the rain rendering.
100 * @param adj_fog_color color of the fog
102 void setLight(sgVec4 adj_fog_color);
104 // this can be queried to add some turbulence for example
105 bool is_view_in_cloud(void) const;
106 void set_view_in_cloud(bool incloud);
107 double get_cloud_turbulence(void) const;
110 // return the size of the memory pool used by texture impostors
111 int get_clouds_CacheSize(void) const;
112 int get_CacheResolution(void) const;
113 float get_clouds_visibility(void) const;
114 float get_clouds_density(void) const;
115 bool get_clouds_enable_state(void) const;
116 bool get_turbulence_enable_state(void) const;
119 * Set the size of the impostor texture cache for 3D clouds.
120 * @param sizeKb size of the texture pool in Kb
122 void set_clouds_CacheSize(int sizeKb);
124 * Set the resolution of the impostor texture for 3D clouds.
125 * @param resolutionPixels size of each texture in pixels (64|128|256)
127 void set_CacheResolution(int resolutionPixels);
129 * Set the maximum range used when drawing clouds.
130 * Clouds are blended from totaly transparent at max range to totaly opaque around the viewer
131 * @param distance in meters
133 void set_clouds_visibility(float distance);
135 * Set the proportion of clouds that will be rendered to limit drop in FPS.
136 * @param density 0..100 no clouds drawn when density == 0, all are drawn when density == 100
138 void set_clouds_density(float density);
140 * Enable or disable the use of 3D clouds.
141 * @param enable when false we draw the 2D layers
143 void set_clouds_enable_state(bool enable);
145 * Enable or disable the use of proximity cloud turbulence.
146 * @param enable when true the turbulence is computed based on type of cloud around the AC
148 void set_turbulence_enable_state(bool enable);
151 float get_precipitation_density(void) const;
152 bool get_precipitation_enable_state(void) const;
154 void set_precipitation_density(float density);
156 * Enable or disable the rendering of precipitation around the viewer.
157 * @param enable when true we will draw precipitation depending on metar data
159 void set_precipitation_enable_state(bool enable);
162 bool get_lightning_enable_state(void) const;
164 * Enable or disable the rendering of lightning and the thunder sound.
165 * @param enable when true we will draw lightning spwaned by cumulonimbus
167 void set_lightning_enable_state(bool enable);
170 * Spawn a new lighning at specified lon/lat.
171 * @param lon position of the new lightning
172 * @param lat position of the new lightning
173 * @param alt asl of the starting point of the lightning in meters
175 void addLightning(double lon, double lat, double alt);
178 * Forward the sound manager instance to be able to play samples.
179 * @param mgr a running sound manager
181 void set_soundMgr(SGSoundMgr *mgr);
183 void setFOV( float w, float h );
184 void getFOV( float &w, float &h );
188 extern SGEnviro sgEnviro;
190 #endif // _VISUAL_ENVIRO_HXX