From: curt Date: Sun, 6 Dec 1998 13:51:20 +0000 (+0000) Subject: Turned "struct fgWEATHER" into "class FGWeather". X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=1c789b7ab61d41380a443f209265eadb523625ef;p=flightgear.git Turned "struct fgWEATHER" into "class FGWeather". --- diff --git a/Main/GLUTkey.cxx b/Main/GLUTkey.cxx index e2f832a6a..d90866103 100644 --- a/Main/GLUTkey.cxx +++ b/Main/GLUTkey.cxx @@ -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. // diff --git a/Main/GLUTmain.cxx b/Main/GLUTmain.cxx index 6d46fce53..017bb9bf2 100644 --- a/Main/GLUTmain.cxx +++ b/Main/GLUTmain.cxx @@ -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 = ¤t_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. // diff --git a/Main/fg_init.cxx b/Main/fg_init.cxx index 53aff9d81..a767e7a23 100644 --- a/Main/fg_init.cxx +++ b/Main/fg_init.cxx @@ -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( ¤t_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. // diff --git a/Scenery/tilemgr.cxx b/Scenery/tilemgr.cxx index 369f6bb54..0e6ef07a6 100644 --- a/Scenery/tilemgr.cxx +++ b/Scenery/tilemgr.cxx @@ -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. // diff --git a/Weather/weather.cxx b/Weather/weather.cxx index 21d702c5c..c8b99d436 100644 --- a/Weather/weather.cxx +++ b/Weather/weather.cxx @@ -42,68 +42,46 @@ // 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 = ¤t_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 = ¤t_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 = ¤t_weather; - - return ( w->visibility ); -} - - -// Set the visibility and update fog parameters -void fgWeatherSetVisibility( float visibility ) { - struct fgWEATHER *w; - w = ¤t_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. // diff --git a/Weather/weather.hxx b/Weather/weather.hxx index 3e49764e6..e17e1f2f5 100644 --- a/Weather/weather.hxx +++ b/Weather/weather.hxx @@ -22,49 +22,56 @@ // (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 ... //