SGEnviro sgEnviro;
-SGEnviro::SGEnviro(void) :
+SGEnviro::SGEnviro() :
view_in_cloud(false),
precipitation_enable_state(true),
precipitation_density(100.0),
}
}
-void SGEnviro::callback_cloud(float heading, float alt, float radius, int familly, float dist, int cloudId) {
+void SGEnviro::callback_cloud(float heading, float alt, float radius, int family, float dist, int cloudId) {
// send data to wx radar
// compute turbulence
// draw precipitation
// http://www.pilotfriend.com/flight_training/weather/THUNDERSTORM%20HAZARDS1.htm
double turbulence = 0.0;
if( dist < radius * radius * 2.25f ) {
- switch(familly) {
+ switch(family) {
case SGNewCloud::CLFamilly_st:
turbulence = 0.2;
break;
// convert to LWC for radar (experimental)
// http://www-das.uwyo.edu/~geerts/cwx/notes/chap08/moist_cloud.html
double LWC = 0.0;
- switch(familly) {
+ switch(family) {
case SGNewCloud::CLFamilly_st:
LWC = 0.29;
break;
// NB:data valid only from cockpit view
// spawn a new lightning
- if(lightning_enable_state && min_time_before_lt <= 0.0 && (familly == SGNewCloud::CLFamilly_cb) &&
+ if(lightning_enable_state && min_time_before_lt <= 0.0 && (family == SGNewCloud::CLFamilly_cb) &&
dist < 15000.0 * 15000.0 && sg_random() > 0.9f) {
double lat, lon;
Point3D orig, dest;
// min_time_before_lt = 5.0;
}
if( (alt - radius * 0.1) > precipitation_max_alt )
- switch(familly) {
+ switch(family) {
case SGNewCloud::CLFamilly_st:
case SGNewCloud::CLFamilly_cu:
case SGNewCloud::CLFamilly_cb:
// precipitation rendering code
void SGEnviro::DrawCone2(float baseRadius, float height, int slices, bool down, double rain_norm, double speed) {
-
sgVec3 light;
sgVec3 min_light = {0.35, 0.35, 0.35};
sgAddVec3( light, fog_color, min_light );
glEnd();
}
-void SGEnviro::drawRain(double pitch, double roll, double heading, double speed, double rain_norm) {
+void SGEnviro::drawRain(double pitch, double roll, double heading, double hspeed, double rain_norm) {
+
+#if 0
+ static int debug_period = 0;
+ if (debug_period++ == 50) {
+ debug_period = 0;
+ cout << "drawRain("
+ << pitch << ", "
+ << roll << ", "
+ << heading << ", "
+ << hspeed << ", "
+ << rain_norm << ");"
+ //" angle = " << angle
+ //<< " raindrop(KTS) = " << raindrop_speed_kts
+ << endl;
+ }
+#endif
+
glBindTexture(GL_TEXTURE_2D, 0);
double raindrop_speed_kts
= (5.0 + rain_norm*15.0) * SG_MPH_TO_MPS * SG_MPS_TO_KT;
- float angle = atanf(speed / raindrop_speed_kts) * SG_RADIANS_TO_DEGREES;
- // We assume that the speed is HORIZONTAL airspeed here!!! XXX
- // DOCUMENT THE CHANGE IN THE PARAMETER speed MEANING BY RENAMING IT!!!
+ float angle = atanf(hspeed / raindrop_speed_kts) * SG_RADIANS_TO_DEGREES;
glPushMatrix();
- // the cone rotate with speed
+ // the cone rotate with hspeed
angle = -pitch - angle;
- glRotatef(heading, 0.0, 1.0, 0.0);
glRotatef(roll, 0.0, 0.0, 1.0);
+ glRotatef(heading, 0.0, 1.0, 0.0);
glRotatef(angle, 1.0, 0.0, 0.0);
// up cone
- DrawCone2(15.0, 30.0, slice_count, true, rain_norm, speed);
+ DrawCone2(15.0, 30.0, slice_count, true, rain_norm, hspeed);
// down cone (usually not visible)
if(angle > 0.0 || heading != 0.0)
- DrawCone2(15.0, -30.0, slice_count, false, rain_norm, speed);
+ DrawCone2(15.0, -30.0, slice_count, false, rain_norm, hspeed);
glPopMatrix();
soundMgr = mgr;
}
-void SGEnviro::drawPrecipitation(double rain_norm, double snow_norm, double hail_norm, double pitch, double roll, double heading, double speed) {
+void SGEnviro::drawPrecipitation(double rain_norm, double snow_norm, double hail_norm, double pitch, double roll, double heading, double hspeed) {
if( precipitation_enable_state && rain_norm > 0.0)
if( precipitation_max_alt >= last_alt )
- drawRain(pitch, roll, heading, speed, rain_norm);
+ drawRain(pitch, roll, heading, hspeed, rain_norm);
}
* @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, int cloudId);
+ void callback_cloud(float heading, float alt, float radius, int family, float dist, int cloudId);
- void drawRain(double pitch, double roll, double heading, double speed, double rain_norm);
+ 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
* @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 heading, double speed);
+ double pitch, double roll, double heading, double hspeed);
/**
* Draw the lightnings spawned by cumulo nimbus.
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.