Added Durk's first stab at clouds.
Added Simulator/Clouds/ Durk fixed a problem in gui.cxx with cursor type. Durk updated his time zone / time-offset command line parameters Curt added a cheezy fade in/out as we transition through the cloud layer. We really need to fog the sky dome, sun, moon, stars as well. Curt added --enable/disable-clouds and --clouds-asl= to control clouds.
This commit is contained in:
parent
e3f7c16e6a
commit
37220833ed
9 changed files with 118 additions and 22 deletions
|
@ -332,11 +332,11 @@ void maybeToggleMouse( void )
|
|||
// Call with FALSE to init and TRUE to restore
|
||||
void BusyCursor( int restore )
|
||||
{
|
||||
static int cursor = 0;
|
||||
static GLenum cursor = (GLenum) 0;
|
||||
if( restore ) {
|
||||
glutSetCursor(cursor);
|
||||
} else {
|
||||
cursor = glutGet( GLUT_WINDOW_CURSOR );
|
||||
cursor = (GLenum) glutGet( (GLenum) GLUT_WINDOW_CURSOR );
|
||||
#if defined(WIN32_CURSOR_TWEAKS)
|
||||
TurnCursorOn();
|
||||
#endif
|
||||
|
|
|
@ -45,6 +45,7 @@ fgfs_LDADD = \
|
|||
$(top_builddir)/Simulator/Airports/libAirports.a \
|
||||
$(top_builddir)/Simulator/Network/libNetwork.a \
|
||||
$(top_builddir)/Simulator/Objects/libObjects.a \
|
||||
$(top_builddir)/Simulator/Clouds/libClouds.a \
|
||||
$(top_builddir)/Simulator/Time/libTime.a \
|
||||
$(WEATHER_LIBS) \
|
||||
$(top_builddir)/Simulator/Joystick/libJoystick.a \
|
||||
|
|
|
@ -427,6 +427,11 @@ bool fgInitSubsystems( void ) {
|
|||
fgMethodCallback<fgLIGHT>( &cur_light_params,
|
||||
&fgLIGHT::Update),
|
||||
fgEVENT::FG_EVENT_READY, 30000 );
|
||||
// update the current timezone each 30 minutes
|
||||
global_events.Register( "fgTIME::updateLocal()",
|
||||
fgMethodCallback<FGTime>(FGTime::cur_time_params,
|
||||
&FGTime::updateLocal),
|
||||
fgEVENT::FG_EVENT_READY, 1800000);
|
||||
|
||||
// Initialize the weather modeling subsystem
|
||||
#ifndef FG_OLD_WEATHER
|
||||
|
|
|
@ -92,7 +92,9 @@
|
|||
#include <Time/fg_timer.hxx>
|
||||
#include <Time/sunpos.hxx>
|
||||
|
||||
#ifdef FG_OLD_WEATHER
|
||||
#ifndef FG_OLD_WEATHER
|
||||
# include <WeatherCM/FGLocalWeatherDatabase.h>
|
||||
#else
|
||||
# include <Weather/weather.hxx>
|
||||
#endif
|
||||
|
||||
|
@ -228,14 +230,15 @@ void fgRenderFrame( void ) {
|
|||
fgLIGHT *l = &cur_light_params;
|
||||
FGTime *t = FGTime::cur_time_params;
|
||||
// FGView *v = ¤t_view;
|
||||
static double last_visibility = -9999;
|
||||
|
||||
double angle;
|
||||
// GLfloat black[4] = { 0.0, 0.0, 0.0, 1.0 };
|
||||
GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 };
|
||||
GLfloat terrain_color[4] = { 0.54, 0.44, 0.29, 1.0 };
|
||||
// GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 };
|
||||
// GLfloat terrain_color[4] = { 0.54, 0.44, 0.29, 1.0 };
|
||||
// GLfloat mat_shininess[] = { 10.0 };
|
||||
GLbitfield clear_mask;
|
||||
|
||||
|
||||
if ( idle_state != 1000 ) {
|
||||
// still initializing, draw the splash screen
|
||||
if ( current_options.get_splash_screen() == 1 ) {
|
||||
|
@ -339,6 +342,40 @@ void fgRenderFrame( void ) {
|
|||
xglFogi( GL_FOG_MODE, GL_EXP2 );
|
||||
xglFogfv( GL_FOG_COLOR, l->adj_fog_color );
|
||||
}
|
||||
|
||||
// update fog params if visibility has changed
|
||||
double cur_visibility = WeatherDatabase->getWeatherVisibility();
|
||||
double actual_visibility = cur_visibility;
|
||||
|
||||
if ( current_options.get_clouds() ) {
|
||||
double diff = fabs( cur_fdm_state->get_Altitude() * FEET_TO_METER -
|
||||
current_options.get_clouds_asl() );
|
||||
cout << "altitude diff = " << diff << endl;
|
||||
if ( diff < 100 ) {
|
||||
actual_visibility = cur_visibility * diff / 100.0;
|
||||
}
|
||||
}
|
||||
|
||||
cout << "actual visibility = " << actual_visibility << endl;
|
||||
|
||||
if ( actual_visibility != last_visibility ) {
|
||||
last_visibility = actual_visibility;
|
||||
|
||||
cout << "----> updating fog params" << endl;
|
||||
|
||||
GLfloat fog_exp_density;
|
||||
GLfloat fog_exp2_density;
|
||||
|
||||
// for GL_FOG_EXP
|
||||
fog_exp_density = -log(0.01 / actual_visibility);
|
||||
|
||||
// for GL_FOG_EXP2
|
||||
fog_exp2_density = sqrt( -log(0.01) ) / actual_visibility;
|
||||
|
||||
// Set correct opengl fog density
|
||||
xglFogf (GL_FOG_DENSITY, fog_exp2_density);
|
||||
}
|
||||
|
||||
// set lighting parameters
|
||||
xglLightfv( GL_LIGHT0, GL_AMBIENT, l->scene_ambient );
|
||||
xglLightfv( GL_LIGHT0, GL_DIFFUSE, l->scene_diffuse );
|
||||
|
|
|
@ -167,6 +167,8 @@ fgOPTIONS::fgOPTIONS() :
|
|||
|
||||
// Rendering options
|
||||
fog(FG_FOG_NICEST), // nicest
|
||||
clouds(true),
|
||||
clouds_asl(5000*FEET_TO_METER),
|
||||
fov(55.0),
|
||||
fullscreen(0),
|
||||
shading(1),
|
||||
|
@ -656,6 +658,16 @@ int fgOPTIONS::parse_option( const string& arg ) {
|
|||
fog = FG_FOG_FASTEST;
|
||||
} else if ( arg == "--fog-nicest" ) {
|
||||
fog = FG_FOG_NICEST;
|
||||
} else if ( arg == "--disable-clouds" ) {
|
||||
clouds = false;
|
||||
} else if ( arg == "--enable-clouds" ) {
|
||||
clouds = true;
|
||||
} else if ( arg.find( "--clouds-asl=" ) != string::npos ) {
|
||||
if ( units == FG_UNITS_FEET ) {
|
||||
clouds_asl = atof( arg.substr(13) ) * FEET_TO_METER;
|
||||
} else {
|
||||
clouds_asl = atof( arg.substr(13) );
|
||||
}
|
||||
} else if ( arg.find( "--fov=" ) != string::npos ) {
|
||||
fov = parse_fov( arg.substr(6) );
|
||||
} else if ( arg == "--disable-fullscreen" ) {
|
||||
|
@ -709,15 +721,15 @@ int fgOPTIONS::parse_option( const string& arg ) {
|
|||
} else if ( arg.find( "--tile-radius=" ) != string::npos ) {
|
||||
tile_radius = parse_tile_radius( arg.substr(14) );
|
||||
tile_diameter = tile_radius * 2 + 1;
|
||||
} else if ( arg.find( "--time-offset-sys=" ) != string::npos ) {
|
||||
time_offset = parse_time_offset( (arg.substr(18)) );
|
||||
} else if ( arg.find( "--time-offset" ) != string::npos ) {
|
||||
time_offset = parse_time_offset( (arg.substr(14)) );
|
||||
//time_offset_type = FG_TIME_SYS_OFFSET;
|
||||
} else if ( arg.find( "--time-match-real") != string::npos ) {
|
||||
//time_offset = parse_time_offset(arg.substr(18));
|
||||
time_offset_type = FG_TIME_SYS_OFFSET;
|
||||
} else if ( arg.find( "--time-offset-lat=") != string::npos ) {
|
||||
time_offset = parse_time_offset(arg.substr(18));
|
||||
} else if ( arg.find( "--time-match-local") != string::npos ) {
|
||||
//time_offset = parse_time_offset(arg.substr(18));
|
||||
time_offset_type = FG_TIME_LAT_OFFSET;
|
||||
} else if ( arg.find( "--time-offset-gmt=") != string::npos ) {
|
||||
time_offset = parse_time_offset(arg.substr(18));
|
||||
time_offset_type = FG_TIME_GMT_OFFSET;
|
||||
} else if ( arg.find( "--start-date-sys=") != string::npos ) {
|
||||
time_offset = parse_date( (arg.substr(17)) );
|
||||
time_offset_type = FG_TIME_SYS_ABSOLUTE;
|
||||
|
@ -875,6 +887,9 @@ void fgOPTIONS::usage ( void ) {
|
|||
cout << "\t--fog-disable: disable fog/haze" << endl;
|
||||
cout << "\t--fog-fastest: enable fastest fog/haze" << endl;
|
||||
cout << "\t--fog-nicest: enable nicest fog/haze" << endl;
|
||||
cout << "\t--enable-clouds: enable demo cloud layer" << endl;
|
||||
cout << "\t--disable-clouds: disable demo cloud layer" << endl;
|
||||
cout << "\t--clouds-asl=xxx: specify altitude of cloud layer above sea level" << endl;
|
||||
cout << "\t--fov=xx.x: specify initial field of view angle in degrees"
|
||||
<< endl;
|
||||
cout << "\t--disable-fullscreen: disable fullscreen mode" << endl;
|
||||
|
@ -904,12 +919,11 @@ void fgOPTIONS::usage ( void ) {
|
|||
cout << endl;
|
||||
|
||||
cout << "Time Options:" << endl;
|
||||
cout << "\t--time-offset-sys=[+-]hh:mm:ss: add this time offset to" << endl
|
||||
<< "\t\tyour system time" << endl;
|
||||
cout << "\t--time-offset-gmt:[+-]hh:mm:ss: add this time offset to" << endl
|
||||
<< "\t\tGreenwich Mean Time (GMT)" << endl;
|
||||
cout << "\t--time-offset-lat:[+-]hh:mm:ss: add this time offset to" << endl
|
||||
<< "\t\tLocal Aircraft Time (LAT)" << endl;
|
||||
cout << "\t--time-offset=[+-]hh:mm:ss: add this time offset" << endl;
|
||||
cout << "\t--time-match-real: Synchronize real-world and FlightGear" << endl
|
||||
<< "\t\ttime. Can be used in combination with --time-offset." << endl;
|
||||
cout << "\t--time-match-local:Synchronize local real-world and " << endl
|
||||
<< "\t\tFlightGear time" << endl;
|
||||
cout << "\t--start-date-sys=yyyy:mm:dd:hh:mm:ss: specify a starting" << endl
|
||||
<< "\t\tdate/time. Uses your system time " << endl;
|
||||
cout << "\t--start-date-gmt=yyyy:mm:dd:hh:mm:ss: specify a starting" << endl
|
||||
|
|
|
@ -161,6 +161,8 @@ private:
|
|||
|
||||
// Rendering options
|
||||
fgFogKind fog; // Fog nicest/fastest/disabled
|
||||
bool clouds; // Enable clouds
|
||||
double clouds_asl; // Cloud layer height above sea level
|
||||
double fov; // Field of View
|
||||
bool fullscreen; // Full screen mode enabled/disabled
|
||||
int shading; // shading method, 0 = Flat, 1 = Smooth
|
||||
|
@ -250,6 +252,8 @@ public:
|
|||
inline void set_speed_up( int speed ) { speed_up = speed; }
|
||||
inline bool fog_enabled() const { return fog != FG_FOG_DISABLED; }
|
||||
inline fgFogKind get_fog() const { return fog; }
|
||||
inline bool get_clouds() const { return clouds; }
|
||||
inline double get_clouds_asl() const { return clouds_asl; }
|
||||
inline double get_fov() const { return fov; }
|
||||
inline bool get_fullscreen() const { return fullscreen; }
|
||||
inline int get_shading() const { return shading; }
|
||||
|
@ -276,6 +280,8 @@ public:
|
|||
// Update functions
|
||||
inline void set_airport_id( const string id ) { airport_id = id; }
|
||||
inline void set_hud_status( bool status ) { hud_status = status; }
|
||||
inline void set_clouds( bool value ) { clouds = value; }
|
||||
inline void set_clouds_asl( double value ) { clouds_asl = value; }
|
||||
inline void set_fov( double amount ) { fov = amount; }
|
||||
inline void set_textures( bool status ) { textures = status; }
|
||||
inline void cycle_fog( void ) {
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
#include <Math/polar3d.hxx>
|
||||
#include <Misc/stopwatch.hxx>
|
||||
#include <Scenery/tileentry.hxx>
|
||||
#include <Clouds/cloudobj.hxx>
|
||||
|
||||
#include "materialmgr.hxx"
|
||||
#include "obj.hxx"
|
||||
|
@ -248,6 +249,9 @@ ssgBranch *fgGenTile( const string& path, FGTileEntry *t) {
|
|||
leaf->setState( state );
|
||||
|
||||
tile->addKid( leaf );
|
||||
if ( current_options.get_clouds() ) {
|
||||
fgGenCloudTile(path, t, tile);
|
||||
}
|
||||
|
||||
return tile;
|
||||
}
|
||||
|
@ -918,7 +922,11 @@ ssgBranch *fgObjLoad( const string& path, FGTileEntry *t) {
|
|||
FG_LOG( FG_TERRAIN, FG_DEBUG,
|
||||
"Loaded " << path << " in "
|
||||
<< stopwatch.elapsedSeconds() << " seconds" );
|
||||
|
||||
|
||||
// Generate a cloud layer above the tiles
|
||||
if ( current_options.get_clouds() ) {
|
||||
fgGenCloudTile(path, t, tile);
|
||||
}
|
||||
return tile;
|
||||
}
|
||||
|
||||
|
|
|
@ -97,6 +97,27 @@ FGTime::~FGTime()
|
|||
delete zonename;
|
||||
}
|
||||
|
||||
void FGTime::updateLocal()
|
||||
{
|
||||
FGInterface* f;
|
||||
f = current_aircraft.fdm_state;
|
||||
time_t currGMT;
|
||||
time_t aircraftLocalTime;
|
||||
GeoCoord location(RAD_TO_DEG * f->get_Latitude(),
|
||||
RAD_TO_DEG * f->get_Longitude());
|
||||
GeoCoord* nearestTz = tzContainer->getNearest(location);
|
||||
FGPath buffer( current_options.get_fg_root() );
|
||||
buffer.append ("Timezone" );
|
||||
buffer.append ( nearestTz->getDescription() );
|
||||
if (zonename)
|
||||
delete zonename;
|
||||
zonename = strdup(buffer.c_str());
|
||||
currGMT = get_gmt(gmtime(&cur_time));
|
||||
aircraftLocalTime = get_gmt((fgLocaltime(&cur_time, buffer.c_str())));
|
||||
localOffset = aircraftLocalTime - currGMT;
|
||||
// cerr << "Using " << localOffset << " as local time offset Timezone is "
|
||||
// << zonename << endl;
|
||||
}
|
||||
|
||||
// Initialize the time dependent variables (maybe I'll put this in the
|
||||
// constructor later)
|
||||
|
@ -132,7 +153,7 @@ void FGTime::init(const FGInterface& f)
|
|||
|
||||
// printf("Using %s for timezone information\n", buffer);
|
||||
zonename = strdup( buffer.c_str() );
|
||||
show( buffer.c_str(), cur_time, 1);
|
||||
//show( buffer.c_str(), cur_time, 1);
|
||||
//printf ("Current greenwich mean time = %24s", asctime(gmtime(&cur_time)));
|
||||
//printf ("Current local time = %24s", asctime(localtime(&cur_time)));
|
||||
currGMT = get_gmt(gmtime(&cur_time));
|
||||
|
|
|
@ -80,9 +80,12 @@ private:
|
|||
// side real time at prime meridian
|
||||
double gst;
|
||||
|
||||
// local side real time
|
||||
// local sidereal time
|
||||
double lst;
|
||||
|
||||
// local offset to GMT
|
||||
time_t localOffset;
|
||||
|
||||
// the difference between the precise sidereal time algorithm
|
||||
// result and the course result. course + diff has good accuracy
|
||||
// for the short term
|
||||
|
@ -122,6 +125,7 @@ public:
|
|||
|
||||
// Update the time dependent variables
|
||||
void update(const FGInterface& f);
|
||||
void updateLocal();
|
||||
|
||||
void cal_mjd (int mn, double dy, int yr);
|
||||
void utc_gst();
|
||||
|
|
Loading…
Add table
Reference in a new issue