#include <simgear/constants.h> // for VERSION
#include <simgear/debug/logstream.hxx>
-#include <simgear/ephemeris/ephemeris.hxx>
#include <simgear/math/fg_geodesy.hxx>
#include <simgear/math/polar3d.hxx>
#include <simgear/math/fg_random.h>
FGInterface cur_view_fdm;
// Sky structures
-FGEphemeris *ephem;
SGSky *thesky;
// hack
cur_light_params.adj_fog_color,
cur_light_params.sun_angle,
cur_light_params.moon_angle,
- ephem->getNumPlanets(), ephem->getPlanets(),
- ephem->getNumStars(), ephem->getStars() );
+ globals->get_ephem()->getNumPlanets(),
+ globals->get_ephem()->getPlanets(),
+ globals->get_ephem()->getNumStars(),
+ globals->get_ephem()->getStars() );
/* cout << "thesky->reposition( view_pos = " << view_pos[0] << " "
<< view_pos[1] << " " << view_pos[2] << endl;
<< " lat = " << cur_fdm_state->get_Latitude() << endl;
cout << " sun_rot = " << cur_light_params.sun_rotation
<< " gst = " << SGTime::cur_time_params->getGst() << endl;
- cout << " sun ra = " << ephem->getSunRightAscension()
- << " sun dec = " << ephem->getSunDeclination()
- << " moon ra = " << ephem->getMoonRightAscension()
- << " moon dec = " << ephem->getMoonDeclination() << endl; */
+ cout << " sun ra = " << globals->get_ephem()->getSunRightAscension()
+ << " sun dec = " << globals->get_ephem()->getSunDeclination()
+ << " moon ra = " << globals->get_ephem()->getMoonRightAscension()
+ << " moon dec = " << globals->get_ephem()->getMoonDeclination() << endl; */
thesky->reposition( view_pos, zero_elev,
current_view.get_local_up(),
cur_fdm_state->get_Altitude() * FEET_TO_METER,
cur_light_params.sun_rotation,
globals->get_time_params()->getGst(),
- ephem->getSunRightAscension(),
- ephem->getSunDeclination(), 50000.0,
- ephem->getMoonRightAscension(),
- ephem->getMoonDeclination(), 50000.0 );
+ globals->get_ephem()->getSunRightAscension(),
+ globals->get_ephem()->getSunDeclination(),
+ 50000.0,
+ globals->get_ephem()->getMoonRightAscension(),
+ globals->get_ephem()->getMoonDeclination(),
+ 50000.0 );
}
glEnable( GL_DEPTH_TEST );
// glMatrixMode( GL_PROJECTION );
// glLoadIdentity();
float fov = current_options.get_fov();
- ssgSetFOV(fov * current_view.get_win_ratio(), fov);
+ // ssgSetFOV(fov * current_view.get_win_ratio(), fov);
+ ssgSetFOV(fov, fov * current_view.get_win_ratio());
double agl = current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER
- scenery.cur_elev;
multi_loop = 1;
}
- if ( !current_options.get_pause() ) {
+ if ( !globals->get_freeze() ) {
// run Autopilot system
current_autopilot->run();
l->UpdateAdjFog();
// Update solar system
- ephem->update( globals->get_time_params(), cur_fdm_state->get_Latitude() );
+ globals->get_ephem()->update( globals->get_time_params()->getMjd(),
+ globals->get_time_params()->getLst(),
+ cur_fdm_state->get_Latitude() );
// Update radio stack model
current_radiostack->update( cur_fdm_state->get_Longitude(),
t->update( cur_fdm_state->get_Longitude(),
cur_fdm_state->get_Latitude(),
- cur_fdm_state->get_Altitude()* FEET_TO_METER,
globals->get_warp() );
if ( globals->get_warp_delta() != 0 ) {
}
// update magvar model
- cur_magvar.update( cur_fdm_state->get_Longitude(),
- cur_fdm_state->get_Latitude(),
- cur_fdm_state->get_Altitude()* FEET_TO_METER,
- globals->get_time_params()->getJD() );
+ globals->get_mag()->update( cur_fdm_state->get_Longitude(),
+ cur_fdm_state->get_Latitude(),
+ cur_fdm_state->get_Altitude()* FEET_TO_METER,
+ globals->get_time_params()->getJD() );
// Get elapsed time (in usec) for this past frame
elapsed = fgGetTimeInterval();
#endif
// see if we need to load any new scenery tiles
- global_tile_mgr.update( cur_fdm_state->get_Longitude(),
- cur_fdm_state->get_Latitude() );
+ global_tile_mgr.update( cur_fdm_state->get_Longitude() * RAD_TO_DEG,
+ cur_fdm_state->get_Latitude() * RAD_TO_DEG );
// Process/manage pending events
global_events.Process();
# ifdef MICHAEL_JOHNSON_EXPERIMENTAL_ENGINE_AUDIO
+ static double kts_to_fts = NM_TO_METER * METER_TO_FEET / 3600.0;
+
// note: all these factors are relative to the sample. our
// sample format should really contain a conversion factor so
// that we can get prop speed right for arbitrary samples.
double pitch = log((controls.get_throttle(0) * 14.0) + 1.0);
//fprintf(stderr, "pitch1: %f ", pitch);
// if (controls.get_throttle(0) > 0.0 ||
- // cur_fdm_state->v_rel_wind > 40.0) {
+ // cur_fdm_state->get_V_calibrated_kts() > 40.0) {
- //fprintf(stderr, "rel_wind: %f ", cur_fdm_state->v_rel_wind);
+ //fprintf(stderr, "rel_wind: %f ", cur_fdm_state->get_V_calibrated_kts());
// only add relative wind and AoA if prop is moving
// or we're really flying at idle throttle
if (pitch < 5.4) { // this needs tuning
// prop tips not breaking sound barrier
- pitch += log(cur_fdm_state->v_rel_wind + 0.8)/2;
+ pitch += log(cur_fdm_state->get_V_calibrated_kts() * kts_to_fts + 0.8)/2;
} else {
// prop tips breaking sound barrier
- pitch += log(cur_fdm_state->v_rel_wind + 0.8)/10;
+ pitch += log(cur_fdm_state->get_V_calibrated_kts() * kts_to_fts + 0.8)/10;
}
//fprintf(stderr, "pitch2: %f ", pitch);
//fprintf(stderr, "AoA: %f ", FG_Gamma_vert_rad);
// fprintf(stderr, "pitch4: %f\n", pitch);
double volume = controls.get_throttle(0) * 1.15 + 0.3 +
- log(cur_fdm_state->v_rel_wind + 1.0)/14.0;
+ log(cur_fdm_state->get_V_calibrated_kts() * kts_to_fts + 1.0)/14.0;
// fprintf(stderr, "volume: %f\n", volume);
pitch_envelope.setStep ( 0, 0.01, pitch );
// options.cxx needs to see this for toggle_panel()
// Handle new window size or exposure
void fgReshape( int width, int height ) {
- if ( ! current_options.get_panel_status() ) {
- current_view.set_win_ratio( (GLfloat) width / (GLfloat) height );
+ if ( ! current_options.get_panel_status() || idle_state != 1000 ) {
+ current_view.set_win_ratio( height / width );
glViewport(0, 0 , (GLint)(width), (GLint)(height) );
} else {
- current_view.set_win_ratio( (GLfloat) width /
- ((GLfloat) (height)*0.4232) );
+ current_view.set_win_ratio( (height*0.4232) / width );
glViewport(0, (GLint)((height)*0.5768),
(GLint)(width), (GLint)((height)*0.4232) );
}
// glViewport ( 0, 0, width, height );
float fov = current_options.get_fov();
- ssgSetFOV(fov * current_view.get_win_ratio(), fov);
+ // ssgSetFOV(fov * current_view.get_win_ratio(), fov);
+ ssgSetFOV(fov, fov * current_view.get_win_ratio());
fgHUDReshape();
// fonts !!!
guiInit();
+ // set current_options lon/lat if an airport id is specified
+ if ( current_options.get_airport_id().length() ) {
+ // fgSetPosFromAirportID( current_options.get_airport_id() );
+ fgSetPosFromAirportIDandHdg( current_options.get_airport_id(),
+ current_options.get_heading() );
+ }
+
// Initialize time
- SGTime *t = new SGTime( current_options.get_fg_root() );
- t->init( 0.0, 0.0, current_options.get_fg_root() );
+ FGPath zone( current_options.get_fg_root() );
+ zone.append( "Timezone" );
+ SGTime *t = new SGTime( current_options.get_lon() * DEG_TO_RAD,
+ current_options.get_lat() * DEG_TO_RAD,
+ zone.str() );
// Handle potential user specified time offsets
time_t cur_time = t->get_cur_time();
- time_t currGMT = t->get_gmt( gmtime(&cur_time) );
- time_t systemLocalTime = t->get_gmt( localtime(&cur_time) );
+ time_t currGMT = sgTimeGetGMT( gmtime(&cur_time) );
+ time_t systemLocalTime = sgTimeGetGMT( localtime(&cur_time) );
time_t aircraftLocalTime =
- t->get_gmt( fgLocaltime(&cur_time, t->get_zonename() ) );
+ sgTimeGetGMT( fgLocaltime(&cur_time, t->get_zonename() ) );
// Okay, we now have six possible scenarios
switch ( current_options.get_time_offset_type() ) {
globals->set_warp_delta( 0 );
- t->update( 0.0, 0.0, 0.0, globals->get_warp() );
+ t->update( 0.0, 0.0, globals->get_warp() );
globals->set_time_params( t );
// Initialize the sky
FGPath ephem_data_path( current_options.get_fg_root() );
ephem_data_path.append( "Astro" );
- ephem = new FGEphemeris( ephem_data_path.c_str() );
- ephem->update( globals->get_time_params(), 0.0 );
+ SGEphemeris *ephem = new SGEphemeris( ephem_data_path.c_str() );
+ ephem->update( globals->get_time_params()->getMjd(),
+ globals->get_time_params()->getLst(),
+ 0.0 );
+ globals->set_ephem( ephem );
FGPath sky_tex_path( current_options.get_fg_root() );
sky_tex_path.append( "Textures" );
thesky->texture_path( sky_tex_path.str() );
thesky->build( 550.0, 550.0,
- ephem->getNumPlanets(),
- ephem->getPlanets(), 60000.0,
- ephem->getNumStars(),
- ephem->getStars(), 60000.0 );
+ globals->get_ephem()->getNumPlanets(),
+ globals->get_ephem()->getPlanets(), 60000.0,
+ globals->get_ephem()->getNumStars(),
+ globals->get_ephem()->getStars(), 60000.0 );
thesky->add_cloud_layer( 2600.0, 200.0, 50.0, 40000.0,
SG_CLOUD_MOSTLY_SUNNY );
// thesky->add_cloud_layer( 1800.0, 400.0, 100.0, SG_CLOUD_OVERCAST );
// thesky->add_cloud_layer( 5000.0, 20.0, 10.0, SG_CLOUD_CIRRUS );
+ // Initialize MagVar model
+ SGMagVar *magvar = new SGMagVar();
+ globals->set_mag( magvar );
+
// Terrain branch
terrain = new ssgBranch;
terrain->setName( "Terrain" );