]> git.mxchange.org Git - simgear.git/blobdiff - simgear/environment/visual_enviro.cxx
Merge branch 'next' of git://gitorious.org/fg/simgear into next
[simgear.git] / simgear / environment / visual_enviro.cxx
index 32140a561e661dc4ad06ad48db7e58689f91165d..8ff6232177b45db1822b134c500f87dea9042ebb 100644 (file)
 #  include <simgear_config.h>
 #endif
 
-#include <plib/sg.h>
 #include <simgear/constants.h>
 #include <simgear/structure/SGReferenced.hxx>
 #include <simgear/structure/SGSharedPtr.hxx>
 #include <simgear/math/sg_random.h>
 #include <simgear/math/sg_geodesy.hxx>
-#include <simgear/math/point3d.hxx>
-#include <simgear/math/polar3d.hxx>
-#include <simgear/sound/soundmgr_openal.hxx>
+#include <simgear/sound/sample_group.hxx>
 #include <simgear/scene/sky/cloudfield.hxx>
 #include <simgear/scene/sky/newcloud.hxx>
+#include <simgear/props/props.hxx>
 #include "visual_enviro.hxx"
 
 #include <vector>
 
-SG_USING_STD(vector);
+using std::vector;
 
 
 typedef struct {
-       Point3D         pt;
+       SGVec3d         pt;
        int                     depth;
        int                     prev;
 } lt_tree_seg;
@@ -51,6 +49,85 @@ typedef struct {
 static float rainpos[MAX_RAIN_SLICE];
 #define MAX_LT_TREE_SEG        400
 
+#define DFL_MIN_LIGHT 0.35
+SGVec3f SGEnviro::min_light(DFL_MIN_LIGHT, DFL_MIN_LIGHT, DFL_MIN_LIGHT);
+#define DFL_STREAK_BRIGHT_NEARMOST_LAYER 0.9
+float SGEnviro::streak_bright_nearmost_layer = DFL_STREAK_BRIGHT_NEARMOST_LAYER;
+#define DFL_STREAK_BRIGHT_FARMOST_LAYER 0.5
+float SGEnviro::streak_bright_farmost_layer = DFL_STREAK_BRIGHT_FARMOST_LAYER;
+#define DFL_STREAK_PERIOD_MAX 2.5
+float SGEnviro::streak_period_max = DFL_STREAK_PERIOD_MAX;
+#define DFL_STREAK_PERIOD_CHANGE_PER_KT 0.005
+float SGEnviro::streak_period_change_per_kt = DFL_STREAK_PERIOD_CHANGE_PER_KT;
+#define DFL_STREAK_PERIOD_MIN 1.0
+float SGEnviro::streak_period_min = DFL_STREAK_PERIOD_MIN;
+#define DFL_STREAK_LENGTH_MIN 0.03
+float SGEnviro::streak_length_min = DFL_STREAK_LENGTH_MIN;
+#define DFL_STREAK_LENGTH_CHANGE_PER_KT 0.0005
+float SGEnviro::streak_length_change_per_kt = DFL_STREAK_LENGTH_CHANGE_PER_KT;
+#define DFL_STREAK_LENGTH_MAX 0.1
+float SGEnviro::streak_length_max = DFL_STREAK_LENGTH_MAX;
+#define DFL_STREAK_COUNT_MIN 40
+int SGEnviro::streak_count_min = DFL_STREAK_COUNT_MIN;
+#define DFL_STREAK_COUNT_MAX 190
+#if (DFL_STREAK_COUNT_MAX > MAX_RAIN_SLICE)
+#error "Bad default!"
+#endif
+int SGEnviro::streak_count_max = DFL_STREAK_COUNT_MAX;
+#define DFL_CONE_BASE_RADIUS 15.0
+float SGEnviro::cone_base_radius = DFL_CONE_BASE_RADIUS;
+#define DFL_CONE_HEIGHT 30.0
+float SGEnviro::cone_height = DFL_CONE_HEIGHT;
+
+
+void SGEnviro::config(const SGPropertyNode* n)
+{
+       if (!n)
+               return;
+
+       const float ml = n->getFloatValue("min-light", DFL_MIN_LIGHT);
+  min_light = SGVec3f(ml, ml, ml);
+
+       streak_bright_nearmost_layer = n->getFloatValue(
+                       "streak-brightness-nearmost-layer",
+                       DFL_STREAK_BRIGHT_NEARMOST_LAYER);
+       streak_bright_farmost_layer = n->getFloatValue(
+                       "streak-brightness-farmost-layer",
+                       DFL_STREAK_BRIGHT_FARMOST_LAYER);
+
+       streak_period_max = n->getFloatValue(
+                       "streak-period-max",
+                       DFL_STREAK_PERIOD_MAX);
+       streak_period_min = n->getFloatValue(
+                       "streak-period-min",
+                       DFL_STREAK_PERIOD_MIN);
+       streak_period_change_per_kt = n->getFloatValue(
+                       "streak-period-change-per-kt",
+                       DFL_STREAK_PERIOD_CHANGE_PER_KT);
+
+       streak_length_max = n->getFloatValue(
+                       "streak-length-max",
+                       DFL_STREAK_LENGTH_MAX);
+       streak_length_min = n->getFloatValue(
+                       "streak-length-min",
+                       DFL_STREAK_LENGTH_MIN);
+       streak_length_change_per_kt = n->getFloatValue(
+                       "streak-length-change-per-kt",
+                       DFL_STREAK_LENGTH_CHANGE_PER_KT);
+
+       streak_count_min = n->getIntValue(
+                       "streak-count-min", DFL_STREAK_COUNT_MIN);
+       streak_count_max = n->getIntValue(
+                       "streak-count-max", DFL_STREAK_COUNT_MAX);
+       if (streak_count_max > MAX_RAIN_SLICE)
+               streak_count_max = MAX_RAIN_SLICE;
+
+       cone_base_radius = n->getFloatValue(
+                       "cone-base-radius", DFL_CONE_BASE_RADIUS);
+       cone_height = n->getFloatValue("cone_height", DFL_CONE_HEIGHT);
+}
+
+
 /**
  * A class to render lightnings.
  */
@@ -67,7 +144,7 @@ public:
        ~SGLightning();
        void lt_Render(void);
        void lt_build(void);
-       void lt_build_tree_branch(int tree_nr, Point3D &start, float energy, int nbseg, float segsize);
+       void lt_build_tree_branch(int tree_nr, SGVec3d &start, float energy, int nbseg, float segsize);
 
        // contains all the segments of the lightning
        lt_tree_seg lt_tree[MAX_LT_TREE_SEG];
@@ -85,7 +162,7 @@ static list_of_lightning lightnings;
 
 SGEnviro sgEnviro;
 
-SGEnviro::SGEnviro(void) :
+SGEnviro::SGEnviro() :
        view_in_cloud(false),
        precipitation_enable_state(true),
        precipitation_density(100.0),
@@ -96,7 +173,7 @@ SGEnviro::SGEnviro(void) :
        lightning_enable_state(false),
        elapsed_time(0.0),
        dt(0.0),
-       soundMgr(NULL),
+       sampleGroup(NULL),
        snd_active(false),
        snd_dist(0.0),
        min_time_before_lt(0.0),
@@ -110,24 +187,28 @@ SGEnviro::SGEnviro(void) :
 }
 
 SGEnviro::~SGEnviro(void) {
+  // if (sampleGroup) delete sampleGroup;
+
+  // OSGFIXME
+  return;
        list_of_lightning::iterator iLightning;
-       for( iLightning = lightnings.begin() ; iLightning != lightnings.end() ; iLightning++ ) {
+       for( iLightning = lightnings.begin() ; iLightning != lightnings.end() ; ++iLightning ) {
                delete (*iLightning);
        }
        lightnings.clear();
 }
 
-void SGEnviro::startOfFrame( sgVec3 p, sgVec3 up, double lon, double lat, double alt, double delta_time) {
+void SGEnviro::startOfFrame( SGVec3f p, SGVec3f up, double lon, double lat, double alt, double delta_time) {
+  // OSGFIXME
+  return;
        view_in_cloud = false;
        // ask the impostor cache to do some cleanup
-       if(SGNewCloud::cldCache)
-               SGNewCloud::cldCache->startNewFrame();
        last_cloud_turbulence = cloud_turbulence;
        cloud_turbulence = 0.0;
        elapsed_time += delta_time;
        min_time_before_lt -= delta_time;
        dt = delta_time;
-
+#if 0
        sgMat4 T1, LON, LAT;
     sgVec3 axis;
 
@@ -149,6 +230,7 @@ void SGEnviro::startOfFrame( sgVec3 p, sgVec3 up, double lon, double lat, double
     sgSetCoord( &pos, TRANSFORM );
 
        sgMakeCoordMat4( transform, &pos );
+  #endif
     last_lon = lon;
     last_lat = lat;
        last_alt = alt;
@@ -172,43 +254,10 @@ void SGEnviro::set_view_in_cloud(bool incloud) {
        view_in_cloud = incloud;
 }
 
-int SGEnviro::get_CacheResolution(void) const {
-       return SGCloudField::get_CacheResolution();
-}
-
-int SGEnviro::get_clouds_CacheSize(void) const {
-       return SGCloudField::get_CacheSize();
-}
-float SGEnviro::get_clouds_visibility(void) const {
-       return SGCloudField::get_CloudVis();
-}
-float SGEnviro::get_clouds_density(void) const {
-       return SGCloudField::get_density();
-}
-bool SGEnviro::get_clouds_enable_state(void) const {
-       return SGCloudField::get_enable3dClouds();
-}
-
 bool SGEnviro::get_turbulence_enable_state(void) const {
        return turbulence_enable_state;
 }
 
-void SGEnviro::set_CacheResolution(int resolutionPixels) {
-       SGCloudField::set_CacheResolution(resolutionPixels);
-}
-
-void SGEnviro::set_clouds_CacheSize(int sizeKb) {
-       SGCloudField::set_CacheSize(sizeKb);
-}
-void SGEnviro::set_clouds_visibility(float distance) {
-       SGCloudField::set_CloudVis(distance);
-}
-void SGEnviro::set_clouds_density(float density) {
-       SGCloudField::set_density(density);
-}
-void SGEnviro::set_clouds_enable_state(bool enable) {
-       SGCloudField::set_enable3dClouds(enable);
-}
 void SGEnviro::set_turbulence_enable_state(bool enable) {
        turbulence_enable_state = enable;
 }
@@ -239,14 +288,16 @@ void SGEnviro::set_lightning_enable_state(bool enable) {
        }
 }
 
-void SGEnviro::setLight(sgVec4 adj_fog_color) {
-       sgCopyVec4( fog_color, adj_fog_color );
+void SGEnviro::setLight(SGVec4f adj_fog_color) {
+  // OSGFIXME
+  return;
+        fog_color = adj_fog_color;
        if( false ) {
        //    ssgGetLight( 0 ) -> setColour( GL_DIFFUSE, l->scene_diffuse() );
        }
 }
-
-void SGEnviro::callback_cloud(float heading, float alt, float radius, int familly, float dist, int cloudId) {
+#if 0
+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
@@ -256,7 +307,7 @@ void SGEnviro::callback_cloud(float heading, float alt, float radius, int famill
        // 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;
@@ -291,7 +342,7 @@ void SGEnviro::callback_cloud(float heading, float alt, float radius, int famill
        // 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;
@@ -318,6 +369,7 @@ void SGEnviro::callback_cloud(float heading, float alt, float radius, int famill
                        LWC = 0.29*2.0;
                        break;
        }
+
        // add to the list for the wxRadar instrument
        if( LWC > 0.0 )
                radarEcho.push_back( SGWxRadarEcho ( heading, alt, radius, dist, LWC, false, cloudId ) );
@@ -325,10 +377,10 @@ void SGEnviro::callback_cloud(float heading, float alt, float radius, int famill
        // 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;
+               SGVec3d orig, dest;
                orig.setlat(last_lat * SG_DEGREES_TO_RADIANS );
                orig.setlon(last_lon * SG_DEGREES_TO_RADIANS );
                orig.setelev(0.0);
@@ -344,7 +396,7 @@ void SGEnviro::callback_cloud(float heading, float alt, float radius, int famill
 //             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:
@@ -355,115 +407,33 @@ void SGEnviro::callback_cloud(float heading, float alt, float radius, int famill
                }
 }
 
+#endif
+
 list_of_SGWxRadarEcho *SGEnviro::get_radar_echo(void) {
        return &radarEcho;
 }
 
 // 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 );
-       float da = SG_PI * 2.0f / (float) slices;
-       // low number = faster
-       float speedf = 2.5f - speed / 200.0;
-       if( speedf < 1.0f )
-               speedf = 1.0f;
-       float lenf = 0.03f + speed / 2000.0;
-       if( lenf > 0.10f )
-               lenf = 0.10f;
-    float t = fmod((float) elapsed_time, speedf) / speedf;
-//     t = 0.1f;
-       if( !down )
-               t = 1.0f - t;
-       float angle = 0.0f;
-       glColor4f(1.0f, 0.7f, 0.7f, 0.9f);
-       glBegin(GL_LINES);
-       int rainpos_indice = 0;
-       for( int i = 0 ; i < slices ; i++ ) {
-               float x = cos(angle) * baseRadius;
-               float y = sin(angle) * baseRadius;
-               angle += da;
-               sgVec3 dir = {x, -height, y};
-
-               // rain drops at 2 different speed to simulate depth
-               float t1 = (i & 1 ? t : t + t) + rainpos[rainpos_indice];
-               if(t1 > 1.0f)   t1 -= 1.0f;
-               if(t1 > 1.0f)   t1 -= 1.0f;
-
-               // distant raindrops are more transparent
-               float c = (i & 1 ? t1 * 0.5f : t1 * 0.9f);
-               glColor4f(c * light[0], c * light[1], c * light[2], c);
-               sgVec3 p1, p2;
-               sgScaleVec3(p1, dir, t1);
-               // distant raindrops are shorter
-               float t2 = t1 + (i & 1 ? lenf : lenf+lenf);
-               sgScaleVec3(p2, dir, t2);
-
-               glVertex3f(p1[0], p1[1] + height, p1[2]);
-               glVertex3f(p2[0], p2[1] + height, p2[2]);
-               if( ++rainpos_indice >= MAX_RAIN_SLICE )
-                       rainpos_indice = 0;
-       }
-       glEnd();
+  // OSGFIXME
+  return;
 }
 
-void SGEnviro::drawRain(double pitch, double roll, double heading, double speed, double rain_norm) {
-
-       glBindTexture(GL_TEXTURE_2D, 0);
-
-       glDisable(GL_DEPTH_TEST);
-       glShadeModel(GL_SMOOTH);
-       glEnable(GL_BLEND);
-       glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA );
-       glDisable( GL_FOG );
-       glDisable(GL_LIGHTING);
-
-       int slice_count = static_cast<int>(
-                               (40.0 + rain_norm*150.0)* precipitation_density / 100.0);
-
-       // www.wonderquest.com/falling-raindrops.htm says that
-       // Raindrop terminal velocity is 5 to 20mph
-       // Rather than model it accurately (temp, pressure, diameter), and make it
-       // smaller than terminal when closer to the precipitation cloud base,
-       // we interpolate in the 5-20mph range according to rain_norm.
-       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!!!
-       glPushMatrix();
-               // the cone rotate with speed
-               angle = -pitch - angle;
-               glRotatef(heading, 0.0, 1.0, 0.0);
-               glRotatef(roll, 0.0, 0.0, 1.0);
-               glRotatef(angle, 1.0, 0.0, 0.0);
-
-               // up cone
-               DrawCone2(15.0, 30.0, slice_count, true, rain_norm, speed);
-               // down cone (usually not visible)
-               if(angle > 0.0 || heading != 0.0)
-                       DrawCone2(15.0, -30.0, slice_count, false, rain_norm, speed);
-
-       glPopMatrix();
-
-       glEnable(GL_LIGHTING);
-       glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
-       glEnable( GL_FOG );
-       glEnable(GL_DEPTH_TEST);
-
+void SGEnviro::drawRain(double pitch, double roll, double heading, double hspeed, double rain_norm) {
+  // OSGFIXME
+  return;
 }
 
-void SGEnviro::set_soundMgr(SGSoundMgr *mgr) {
-       soundMgr = mgr;
+void SGEnviro::set_sampleGroup(SGSampleGroup *sgr) {
+       sampleGroup = sgr;
 }
 
-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) {
+  // OSGFIXME
+  return;
        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);
 }
 
 
@@ -482,164 +452,25 @@ SGLightning::~SGLightning() {
 }
 
 // lightning rendering code
-void SGLightning::lt_build_tree_branch(int tree_nr, Point3D &start, float energy, int nbseg, float segsize) {
-
-       sgVec3 dir, newdir;
-       int nseg = 0;
-       Point3D pt = start;
-       if( nbseg == 50 )
-               sgSetVec3( dir, 0.0, -1.0, 0.0 );
-       else {
-               sgSetVec3( dir, sg_random() - 0.5f, sg_random() - 0.5f, sg_random() - 0.5f);
-               sgNormaliseVec3(dir);
-       }
-       if( nb_tree >= MAX_LT_TREE_SEG )
-               return;
-
-       lt_tree[nb_tree].depth = tree_nr;
-       nseg = 0;
-       lt_tree[nb_tree].pt = pt;
-       lt_tree[nb_tree].prev = -1;
-       nb_tree ++;
-
-       // TODO:check agl
-       while(nseg < nbseg && pt.y() > 0.0) {
-        int prev = nb_tree - 1;
-        nseg++;
-               // add a branch
-        if( energy * sg_random() > 0.8f )
-                       lt_build_tree_branch(tree_nr + 1, pt, energy * 0.9f, nbseg == 50 ? 10 : static_cast<int>(nbseg * 0.4f), segsize * 0.7f);
-
-               if( nb_tree >= MAX_LT_TREE_SEG )
-                       return;
-               sgSetVec3(newdir, (sg_random() - 0.5f), (sg_random() - 0.5f) - (nbseg == 50 ? 0.5f : 0.0), (sg_random() - 0.5f));
-               sgNormaliseVec3(newdir);
-               sgAddVec3( dir, newdir);
-               sgNormaliseVec3(dir);
-               sgVec3 scaleDir;
-               sgScaleVec3( scaleDir, dir, segsize * energy * 0.5f );
-               pt[PX] += scaleDir[0];
-               pt[PY] += scaleDir[1];
-               pt[PZ] += scaleDir[2];
-
-               lt_tree[nb_tree].depth = tree_nr;
-               lt_tree[nb_tree].pt = pt;
-               lt_tree[nb_tree].prev = prev;
-               nb_tree ++;
-       }
+void SGLightning::lt_build_tree_branch(int tree_nr, SGVec3d &start, float energy, int nbseg, float segsize) {
+  // OSGFIXME
+  return;
 }
 
 void SGLightning::lt_build(void) {
-    Point3D top;
-    nb_tree = 0;
-    top[PX] = 0 ;
-    top[PY] = alt;
-    top[PZ] = 0;
-    lt_build_tree_branch(0, top, 1.0, 50, top[PY] / 8.0);
-       if( ! sgEnviro.soundMgr )
-               return;
-       Point3D start( sgEnviro.last_lon*SG_DEGREES_TO_RADIANS, sgEnviro.last_lat*SG_DEGREES_TO_RADIANS, 0.0 );
-       Point3D dest( lon*SG_DEGREES_TO_RADIANS, lat*SG_DEGREES_TO_RADIANS, 0.0 );
-       double course = 0.0, dist = 0.0;
-       calc_gc_course_dist( dest, start, &course, &dist );
-       if( dist < 10000.0 && ! sgEnviro.snd_playing && (dist < sgEnviro.snd_dist || ! sgEnviro.snd_active) ) {
-               sgEnviro.snd_timer = 0.0;
-               sgEnviro.snd_wait  = dist / 340;
-               sgEnviro.snd_dist  = dist;
-               sgEnviro.snd_pos_lat = lat;
-               sgEnviro.snd_pos_lon = lon;
-               sgEnviro.snd_active = true;
-               sgEnviro.snd_playing = false;
-       }
+  // OSGFIXME
+  return;
 }
 
 
 void SGLightning::lt_Render(void) {
-       float flash = 0.5;
-       if( fmod(sgEnviro.elapsed_time*100.0, 100.0) > 50.0 )
-               flash = sg_random() * 0.75f + 0.25f;
-    float h = lt_tree[0].pt[PY];
-       sgVec4 col={0.62f, 0.83f, 1.0f, 1.0f};
-       sgVec4 c;
-
-#define DRAW_SEG() \
-                       {glColorMaterial(GL_FRONT, GL_EMISSION);  \
-                       glDisable(GL_LINE_SMOOTH); glBegin(GL_LINES); \
-                               glColor4fv(c); \
-                glVertex3f(lt_tree[n].pt[PX], lt_tree[n].pt[PZ], lt_tree[n].pt[PY]); \
-                glVertex3f(lt_tree[lt_tree[n].prev].pt[PX], lt_tree[lt_tree[n].prev].pt[PZ], lt_tree[lt_tree[n].prev].pt[PY]); \
-                       glEnd(); glEnable(GL_LINE_SMOOTH);}
-
-       glDepthMask( GL_FALSE );
-       glEnable(GL_BLEND);
-       glBlendFunc( GL_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
-       glBindTexture(GL_TEXTURE_2D, 0);
-
-       glDisable(GL_LIGHTING);
-       glDisable( GL_FOG );
-       glPushMatrix();
-       sgMat4 modelview, tmp;
-    ssgGetModelviewMatrix( modelview );
-       sgCopyMat4( tmp, sgEnviro.transform );
-    sgPostMultMat4( tmp, modelview );
-    ssgLoadModelviewMatrix( tmp );
-
-    Point3D start( sgEnviro.last_lon*SG_DEGREES_TO_RADIANS, sgEnviro.last_lat*SG_DEGREES_TO_RADIANS, 0.0 );
-    Point3D dest( lon*SG_DEGREES_TO_RADIANS, lat*SG_DEGREES_TO_RADIANS, 0.0 );
-    double course = 0.0, dist = 0.0;
-    calc_gc_course_dist( dest, start, &course, &dist );
-    double ax = 0.0, ay = 0.0;
-    ax = cos(course) * dist;
-    ay = sin(course) * dist;
-
-       glTranslatef( ax, ay, -sgEnviro.last_alt );
-
-       sgEnviro.radarEcho.push_back( SGWxRadarEcho ( course, 0.0, 0.0, dist, age, true, 0 ) );
-
-       for( int n = 0 ; n < nb_tree ; n++ ) {
-        if( lt_tree[n].prev < 0 )
-                       continue;
-
-        float t1 = sgLerp(0.5, 1.0, lt_tree[n].pt[PY] / h);
-               t1 *= flash;
-               if( lt_tree[n].depth >= 2 ) {
-            glLineWidth(3);
-                       sgScaleVec4(c, col, t1 * 0.6f);
-                       DRAW_SEG();
-               } else {
-                       if( lt_tree[n].depth == 0 ) {
-                glLineWidth(12);
-                               sgScaleVec4(c, col, t1 * 0.5f);
-                               DRAW_SEG();
-
-                glLineWidth(6);
-                               sgScaleVec4(c, col, t1);
-                               DRAW_SEG();
-                       } else {
-                glLineWidth(6);
-                               sgScaleVec4(c, col, t1 * 0.7f);
-                               DRAW_SEG();
-                       }
-
-            if( lt_tree[n].depth == 0 ) 
-                glLineWidth(3);
-                       else
-                glLineWidth(2);
-
-            sgSetVec4(c, t1, t1, t1, t1);
-                       DRAW_SEG();
-               }
-
-       }
-    glLineWidth(1);
-       glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
-       glPopMatrix();
-       glDepthMask( GL_TRUE ); 
-       glEnable( GL_FOG );
-       glEnable(GL_LIGHTING);
+  // OSGFIXME
+  return;
 }
 
 void SGEnviro::addLightning(double lon, double lat, double alt) {
+  // OSGFIXME
+  return;
        if( lightnings.size() > 10)
                return;
        SGLightning *lt= new SGLightning(lon, lat, alt);
@@ -647,52 +478,8 @@ void SGEnviro::addLightning(double lon, double lat, double alt) {
 }
 
 void SGEnviro::drawLightning(void) {
-       list_of_lightning::iterator iLightning;
-       // play 'thunder' for lightning
-       if( snd_active )
-               if( !snd_playing ) {
-                       // wait until sound has reached us
-                       snd_timer += dt;
-                       if( snd_timer >= snd_wait ) {
-                               snd_playing = true;
-                               // compute relative position of lightning
-                               Point3D start( sgEnviro.last_lon*SG_DEGREES_TO_RADIANS, sgEnviro.last_lat*SG_DEGREES_TO_RADIANS, 0.0 );
-                               Point3D dest( snd_pos_lon*SG_DEGREES_TO_RADIANS, snd_pos_lat*SG_DEGREES_TO_RADIANS, 0.0 );
-                               double course = 0.0, dist = 0.0;
-                               calc_gc_course_dist( dest, start, &course, &dist );
-                               double ax = 0.0, ay = 0.0;
-                               ax = cos(course) * dist;
-                               ay = sin(course) * dist;
-                               SGSharedPtr<SGSoundSample> snd = soundMgr->find("thunder");
-                               if( snd ) {
-                                       ALfloat pos[3]={ax, ay, -sgEnviro.last_alt };
-                                       snd->set_source_pos(pos);
-                                       snd->play_once();
-                               }
-                       }
-               } else {
-                       if( !soundMgr->is_playing("thunder") ) {
-                               snd_active = false;
-                               snd_playing = false;
-                       }
-               }
-
-       if( ! lightning_enable_state )
-               return;
-
-       for( iLightning = lightnings.begin() ; iLightning != lightnings.end() ; iLightning++ ) {
-               if( dt )
-                       if( sg_random() > 0.95f )
-                               (*iLightning)->lt_build();
-               (*iLightning)->lt_Render();
-               (*iLightning)->age -= dt;
-               if( (*iLightning)->age < 0.0 ) {
-                       delete (*iLightning);
-                       lightnings.erase( iLightning );
-                       break;
-               }
-       }
-
+  // OSGFIXME
+  return;
 }