]> git.mxchange.org Git - flightgear.git/commitdiff
Turned "struct fgWEATHER" into "class FGWeather".
authorcurt <curt>
Sun, 6 Dec 1998 13:51:20 +0000 (13:51 +0000)
committercurt <curt>
Sun, 6 Dec 1998 13:51:20 +0000 (13:51 +0000)
Main/GLUTkey.cxx
Main/GLUTmain.cxx
Main/fg_init.cxx
Scenery/tilemgr.cxx
Weather/weather.cxx
Weather/weather.hxx

index e2f832a6ac122740b1c4ee2afbfc75a5fd610f5e..d908661036a5b0e23a06cc9d259cb85fa121a2e4 100644 (file)
@@ -72,7 +72,7 @@ void GLUTkey(unsigned char k, int x, int y) {
     FGState *f;
     fgTIME *t;
     fgVIEW *v;
-    struct fgWEATHER *w;
+    FGWeather *w;
     float fov, tmp;
     static bool winding_ccw = true;
 
@@ -167,9 +167,9 @@ void GLUTkey(unsigned char k, int x, int y) {
            v->update_fov = TRUE;
            return;
        case 90: // Z key
-           tmp = fgWeatherGetVisibility();   // in meters
+           tmp = w->get_visibility();   // in meters
            tmp /= 1.10;
-           fgWeatherSetVisibility( tmp );
+           w->set_visibility( tmp );
            return;
        }
     } else {
@@ -253,9 +253,9 @@ void GLUTkey(unsigned char k, int x, int y) {
            v->update_fov = TRUE;
            return;
        case 122: // z key
-           tmp = fgWeatherGetVisibility();   // in meters
+           tmp = w->get_visibility();   // in meters
            tmp *= 1.10;
-           fgWeatherSetVisibility( tmp );
+           w->set_visibility( tmp );
            return;
        case 27: // ESC
            // if( fg_DebugOutput ) {
@@ -386,6 +386,9 @@ void GLUTspecialkey(int k, int x, int y) {
 
 
 // $Log$
+// Revision 1.36  1998/12/06 13:51:20  curt
+// Turned "struct fgWEATHER" into "class FGWeather".
+//
 // Revision 1.35  1998/12/05 16:13:17  curt
 // Renamed class fgCONTROLS to class FGControls.
 //
index 6d46fce53e68fb636ecc5a4b2e29dd2716f52484..017bb9bf2e5a7d87be5091f7c3e4c4b5c7746d0e 100644 (file)
@@ -134,10 +134,8 @@ slSample *s2;
 // fgInitVisuals() -- Initialize various GL/view parameters
 static void fgInitVisuals( void ) {
     fgLIGHT *l;
-    struct fgWEATHER *w;
 
     l = &cur_light_params;
-    w = &current_weather;
 
     // Go full screen if requested ...
     if ( current_options.get_fullscreen() ) {
@@ -471,7 +469,7 @@ static void fgMainLoop( void ) {
     FG_LOG( FG_ALL, FG_DEBUG, "Running Main Loop");
     FG_LOG( FG_ALL, FG_DEBUG, "======= ==== ====");
 
-    fgWeatherUpdate();
+    current_weather.Update();
 
     // Fix elevation.  I'm just sticking this here for now, it should
     // probably move eventually
@@ -946,7 +944,7 @@ int main( int argc, char **argv ) {
     // fgInitDebug();
 
     // set default log levels
-    fglog().setLogLevels( FG_ALL, FG_DEBUG );
+    fglog().setLogLevels( FG_ALL, FG_INFO );
 
     FG_LOG( FG_GENERAL, FG_INFO, "Flight Gear:  Version " << VERSION << endl );
 
@@ -1014,6 +1012,9 @@ int main( int argc, char **argv ) {
 
 
 // $Log$
+// Revision 1.73  1998/12/06 13:51:22  curt
+// Turned "struct fgWEATHER" into "class FGWeather".
+//
 // Revision 1.72  1998/12/05 15:54:18  curt
 // Renamed class fgFLIGHT to class FGState as per request by JSB.
 //
index 53aff9d819aae46d17775ba1ef841d36835ebc82..a767e7a23ed0a39e990660d607fe03e84c2d1545 100644 (file)
@@ -316,7 +316,7 @@ int fgInitSubsystems( void )
                            fgEVENT::FG_EVENT_READY, 30000 );
 
     // Initialize the weather modeling subsystem
-    fgWeatherInit();
+    current_weather.Init();
 
     // Initialize the Cockpit subsystem
     if( fgCockpitInit( &current_aircraft )) {
@@ -370,6 +370,9 @@ int fgInitSubsystems( void )
 
 
 // $Log$
+// Revision 1.56  1998/12/06 13:51:23  curt
+// Turned "struct fgWEATHER" into "class FGWeather".
+//
 // Revision 1.55  1998/12/05 15:54:20  curt
 // Renamed class fgFLIGHT to class FGState as per request by JSB.
 //
index 369f6bb54b35428051041a417cb8cd60c283cc7a..0e6ef07a6487ed8b7184736b8c906e9dcb1a8df6 100644 (file)
@@ -477,7 +477,7 @@ static int viewable( const Point3D& cp, double radius ) {
        
     // Check near and far clip plane
     if( ( eye[2] > radius ) ||
-       ( eye[2] + radius + current_weather.visibility < 0) )
+       ( eye[2] + radius + current_weather.get_visibility() < 0) )
     {
        return(0);
     }
@@ -526,7 +526,7 @@ static int viewable( const Point3D& cp, double radius ) {
     }
 
     // Check far clip plane
-    if ( eye[2] + radius < -current_weather.visibility ) {
+    if ( eye[2] + radius < -current_weather.get_visibility() ) {
        return(0);
     }
 
@@ -748,6 +748,9 @@ void fgTileMgrRender( void ) {
 
 
 // $Log$
+// Revision 1.50  1998/12/06 13:51:25  curt
+// Turned "struct fgWEATHER" into "class FGWeather".
+//
 // Revision 1.49  1998/12/05 15:54:26  curt
 // Renamed class fgFLIGHT to class FGState as per request by JSB.
 //
index 21d702c5cf74a0e4fb12e77e3ffc7ace875868a1..c8b99d4367cb66b2fc7da07f1dc6f7037c61f606 100644 (file)
 
 
 // This is a record containing current weather info
-struct fgWEATHER current_weather;
+FGWeather current_weather;
 
 
-// Initialize the weather modeling subsystem
-void fgWeatherInit( void ) {
-    struct fgWEATHER *w;
+FGWeather::FGWeather() {
+}
+
+
+FGWeather::~FGWeather() {
+}
 
-    w = &current_weather;
 
+// Initialize the weather modeling subsystem
+void FGWeather::Init( ) {
     FG_LOG( FG_GENERAL, FG_INFO, "Initializing weather subsystem");
 
     // Configure some wind
     // FG_V_north_airmass = 15; // ft/s =~ 10mph
 
-    // fgWeatherSetVisibility(45000.0);    // in meters
-    fgWeatherSetVisibility(32000.0);    // about 20 miles (in meters)
+    // set_visibility( 45000.0 );    // in meters
+    set_visibility( 32000.0 );       // about 20 miles (in meters)
 }
 
 
 // Update the weather parameters for the current position
-void fgWeatherUpdate( void ) {
-
-    // temporarily remove the code of this do-nothing routine
-
-// #ifdef FG_WEATHER_UPDATE
+void FGWeather::Update( void ) {
     FGState *f;
-    struct fgWEATHER *w;
 
     f = current_aircraft.fdm_state;
-    w = &current_weather;
 
     // Add some random turbulence
-    // FG_U_gust = fg_random() * 5.0 - 2.5;
-    // FG_V_gust = fg_random() * 5.0 - 2.5;
-    // FG_W_gust = fg_random() * 5.0 - 2.5;
-// #endif FG_WEATHER_UPDATE
-}
-
-
-// Get the current visibility
-float fgWeatherGetVisibility( void ) {
-    struct fgWEATHER *w;
-    w = &current_weather;
-
-    return ( w->visibility );
-}
-
-
-// Set the visibility and update fog parameters
-void fgWeatherSetVisibility( float visibility ) {
-    struct fgWEATHER *w;
-    w = &current_weather;
-
-    w->visibility = visibility;       // in meters
-    // w->fog_density = -log(0.01 / w->visibility;        // for GL_FOG_EXP
-    w->fog_density = sqrt( -log(0.01) ) / w->visibility;  // for GL_FOG_EXP2
-    xglFogf (GL_FOG_DENSITY, w->fog_density);
-    FG_LOG( FG_INPUT, FG_DEBUG, "Fog density = " << w->fog_density );
+    // f->set_U_gust( fg_random() * 5.0 - 2.5 );
+    // f->set_V_gust( fg_random() * 5.0 - 2.5 );
+    // f->set_W_gust( fg_random() * 5.0 - 2.5 );
 }
 
 
 // $Log$
+// Revision 1.5  1998/12/06 13:51:26  curt
+// Turned "struct fgWEATHER" into "class FGWeather".
+//
 // Revision 1.4  1998/12/05 15:54:31  curt
 // Renamed class fgFLIGHT to class FGState as per request by JSB.
 //
index 3e49764e6f803a8a3c7f1307b682a0d84a5e4cf7..e17e1f2f55edbfce0ea5de6424527941be390a97 100644 (file)
 // (Log is kept at end of this file)
 
 
-#ifndef _WEATHER_H
-#define _WEATHER_H
-
-
-#ifdef __cplusplus                                                          
-extern "C" {                            
-#endif                                   
+#ifndef _WEATHER_HXX
+#define _WEATHER_HXX
 
 
 // holds the current weather values
-struct fgWEATHER {
-    float visibility;
-    float fog_density;
-};
+class FGWeather {
 
-extern struct fgWEATHER current_weather;
+private:
 
+    double visibility;
+    GLfloat fog_exp_density;
+    GLfloat fog_exp2_density;
 
-// Initialize the weather modeling subsystem
-void fgWeatherInit( void );
+public:
 
+    FGWeather();
+    ~FGWeather();
 
-// Update the weather parameters for the current position
-void fgWeatherUpdate( void );
+    void Init();
+    void Update();
+    
+    inline double get_visibility() const { return visibility; }
 
+    inline void set_visibility( double v ) {
+       // in meters
+       visibility = v;
 
-// Get the current visibility
-float fgWeatherGetVisibility( void );
+        // for GL_FOG_EXP
+       fog_exp_density = -log(0.01 / visibility);
 
+       // for GL_FOG_EXP2
+       fog_exp2_density = sqrt( -log(0.01) ) / visibility;
 
-// Set the visibility and update fog parameters
-void fgWeatherSetVisibility( float visibility );
+       // Set correct opengl fog density
+       xglFogf (GL_FOG_DENSITY, fog_exp2_density);
 
+       // FG_LOG( FG_INPUT, FG_DEBUG, "Fog density = " << w->fog_density );
+    }
+};
 
-#ifdef __cplusplus
-}
-#endif
+extern FGWeather current_weather;
 
 
-#endif // _WEATHER_H
+#endif // _WEATHER_HXX
 
 
 // $Log$
+// Revision 1.2  1998/12/06 13:51:27  curt
+// Turned "struct fgWEATHER" into "class FGWeather".
+//
 // Revision 1.1  1998/10/17 01:34:37  curt
 // C++ ifying ...
 //