Turned "struct fgWEATHER" into "class FGWeather".
This commit is contained in:
parent
5ead340cee
commit
1c789b7ab6
6 changed files with 81 additions and 86 deletions
|
@ -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.
|
||||
//
|
||||
|
|
|
@ -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.
|
||||
//
|
||||
|
|
|
@ -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.
|
||||
//
|
||||
|
|
|
@ -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.
|
||||
//
|
||||
|
|
|
@ -42,68 +42,46 @@
|
|||
|
||||
|
||||
// This is a record containing current weather info
|
||||
struct fgWEATHER current_weather;
|
||||
FGWeather current_weather;
|
||||
|
||||
|
||||
FGWeather::FGWeather() {
|
||||
}
|
||||
|
||||
|
||||
FGWeather::~FGWeather() {
|
||||
}
|
||||
|
||||
|
||||
// Initialize the weather modeling subsystem
|
||||
void fgWeatherInit( void ) {
|
||||
struct fgWEATHER *w;
|
||||
|
||||
w = ¤t_weather;
|
||||
|
||||
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.
|
||||
//
|
||||
|
|
|
@ -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 {
|
||||
|
||||
private:
|
||||
|
||||
double visibility;
|
||||
GLfloat fog_exp_density;
|
||||
GLfloat fog_exp2_density;
|
||||
|
||||
public:
|
||||
|
||||
FGWeather();
|
||||
~FGWeather();
|
||||
|
||||
void Init();
|
||||
void Update();
|
||||
|
||||
inline double get_visibility() const { return visibility; }
|
||||
|
||||
inline void set_visibility( double v ) {
|
||||
// in meters
|
||||
visibility = v;
|
||||
|
||||
// for GL_FOG_EXP
|
||||
fog_exp_density = -log(0.01 / visibility);
|
||||
|
||||
// for GL_FOG_EXP2
|
||||
fog_exp2_density = sqrt( -log(0.01) ) / visibility;
|
||||
|
||||
// Set correct opengl fog density
|
||||
xglFogf (GL_FOG_DENSITY, fog_exp2_density);
|
||||
|
||||
// FG_LOG( FG_INPUT, FG_DEBUG, "Fog density = " << w->fog_density );
|
||||
}
|
||||
};
|
||||
|
||||
extern struct fgWEATHER current_weather;
|
||||
extern FGWeather current_weather;
|
||||
|
||||
|
||||
// Initialize the weather modeling subsystem
|
||||
void fgWeatherInit( void );
|
||||
|
||||
|
||||
// Update the weather parameters for the current position
|
||||
void fgWeatherUpdate( void );
|
||||
|
||||
|
||||
// Get the current visibility
|
||||
float fgWeatherGetVisibility( void );
|
||||
|
||||
|
||||
// Set the visibility and update fog parameters
|
||||
void fgWeatherSetVisibility( float visibility );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#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 ...
|
||||
//
|
||||
|
|
Loading…
Add table
Reference in a new issue