]> git.mxchange.org Git - simgear.git/blobdiff - simgear/environment/visual_enviro.cxx
Allow tasks to be removed from the EventManager by name.
[simgear.git] / simgear / environment / visual_enviro.cxx
index d3888f5c50b880c52e85a37b123773e66f75958f..b0cb219059f4b8ceecf844b8d7cb3581a0c85886 100644 (file)
@@ -23,7 +23,6 @@
 #  include <simgear_config.h>
 #endif
 
-#include <plib/sg.h>
 #include <simgear/constants.h>
 #include <simgear/structure/SGReferenced.hxx>
 #include <simgear/structure/SGSharedPtr.hxx>
@@ -31,7 +30,7 @@
 #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>
@@ -39,7 +38,7 @@
 
 #include <vector>
 
-SG_USING_STD(vector);
+using std::vector;
 
 
 typedef struct {
@@ -176,7 +175,7 @@ SGEnviro::SGEnviro() :
        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),
@@ -190,6 +189,10 @@ SGEnviro::SGEnviro() :
 }
 
 SGEnviro::~SGEnviro(void) {
+       if (sampleGroup) delete sampleGroup;
+
+  // OSGFIXME
+  return;
        list_of_lightning::iterator iLightning;
        for( iLightning = lightnings.begin() ; iLightning != lightnings.end() ; iLightning++ ) {
                delete (*iLightning);
@@ -198,10 +201,10 @@ SGEnviro::~SGEnviro(void) {
 }
 
 void SGEnviro::startOfFrame( sgVec3 p, sgVec3 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;
@@ -252,43 +255,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;
 }
@@ -320,12 +290,14 @@ void SGEnviro::set_lightning_enable_state(bool enable) {
 }
 
 void SGEnviro::setLight(sgVec4 adj_fog_color) {
+  // OSGFIXME
+  return;
        sgCopyVec4( fog_color, adj_fog_color );
        if( false ) {
        //    ssgGetLight( 0 ) -> setColour( GL_DIFFUSE, l->scene_diffuse() );
        }
 }
-
+#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
@@ -398,6 +370,7 @@ void SGEnviro::callback_cloud(float heading, float alt, float radius, int family
                        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 ) );
@@ -435,12 +408,16 @@ void SGEnviro::callback_cloud(float heading, float alt, float radius, int family
                }
 }
 
+#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) {
+  // OSGFIXME
+  return;
        sgVec3 light;
        sgAddVec3( light, fog_color, min_light );
        float da = SG_PI * 2.0f / (float) slices;
@@ -489,6 +466,8 @@ void SGEnviro::DrawCone2(float baseRadius, float height, int slices, bool down,
 }
 
 void SGEnviro::drawRain(double pitch, double roll, double heading, double hspeed, double rain_norm) {
+  // OSGFIXME
+  return;
 
 #if 0
        static int debug_period = 0;
@@ -553,11 +532,13 @@ void SGEnviro::drawRain(double pitch, double roll, double heading, double hspeed
 
 }
 
-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 hspeed) {
+  // OSGFIXME
+  return;
        if( precipitation_enable_state && rain_norm > 0.0)
          if( precipitation_max_alt >= last_alt )
                drawRain(pitch, roll, heading, hspeed, rain_norm);
@@ -580,6 +561,8 @@ SGLightning::~SGLightning() {
 
 // lightning rendering code
 void SGLightning::lt_build_tree_branch(int tree_nr, Point3D &start, float energy, int nbseg, float segsize) {
+  // OSGFIXME
+  return;
 
        sgVec3 dir, newdir;
        int nseg = 0;
@@ -627,13 +610,15 @@ void SGLightning::lt_build_tree_branch(int tree_nr, Point3D &start, float energy
 }
 
 void SGLightning::lt_build(void) {
+  // OSGFIXME
+  return;
     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 )
+       if( ! sgEnviro.sampleGroup )
                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 );
@@ -652,6 +637,8 @@ void SGLightning::lt_build(void) {
 
 
 void SGLightning::lt_Render(void) {
+  // OSGFIXME
+  return;
        float flash = 0.5;
        if( fmod(sgEnviro.elapsed_time*100.0, 100.0) > 50.0 )
                flash = sg_random() * 0.75f + 0.25f;
@@ -676,10 +663,12 @@ void SGLightning::lt_Render(void) {
        glDisable( GL_FOG );
        glPushMatrix();
        sgMat4 modelview, tmp;
-    ssgGetModelviewMatrix( modelview );
+    // OSGFIXME
+//     ssgGetModelviewMatrix( modelview );
        sgCopyMat4( tmp, sgEnviro.transform );
     sgPostMultMat4( tmp, modelview );
-    ssgLoadModelviewMatrix( tmp );
+    // OSGFIXME
+//     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 );
@@ -737,6 +726,8 @@ void SGLightning::lt_Render(void) {
 }
 
 void SGEnviro::addLightning(double lon, double lat, double alt) {
+  // OSGFIXME
+  return;
        if( lightnings.size() > 10)
                return;
        SGLightning *lt= new SGLightning(lon, lat, alt);
@@ -744,9 +735,11 @@ void SGEnviro::addLightning(double lon, double lat, double alt) {
 }
 
 void SGEnviro::drawLightning(void) {
+  // OSGFIXME
+  return;
        list_of_lightning::iterator iLightning;
        // play 'thunder' for lightning
-       if( snd_active )
+       if( snd_active ) {
                if( !snd_playing ) {
                        // wait until sound has reached us
                        snd_timer += dt;
@@ -760,20 +753,21 @@ void SGEnviro::drawLightning(void) {
                                double ax = 0.0, ay = 0.0;
                                ax = cos(course) * dist;
                                ay = sin(course) * dist;
-                               SGSharedPtr<SGSoundSample> snd = soundMgr->find("thunder");
+                               SGSharedPtr<SGSoundSample> snd = sampleGroup->find("thunder");
                                if( snd ) {
-                                       ALfloat pos[3]={ax, ay, -sgEnviro.last_alt };
-                                       snd->set_source_pos(pos);
+                                       SGVec3d pos = SGVec3d(ax, ay, -sgEnviro.last_alt);
+                                       snd->set_position(pos);
                                        snd->play_once();
                                }
                        }
                } else {
-                       if( !soundMgr->is_playing("thunder") ) {
+                       if( !sampleGroup->is_playing("thunder") ) {
                                snd_active = false;
                                snd_playing = false;
                        }
                }
 
+       }
        if( ! lightning_enable_state )
                return;