#endif
#include <GL/glut.h>
-#include <XGL/xgl.h>
+#include <simgear/xgl/xgl.h>
#include <stdio.h>
#include <stdlib.h>
# define _G_NO_EXTERN_TEMPLATES
#endif
-#include <Include/compiler.h>
+#include <simgear/compiler.h>
#include STL_STRING
-#include <Debug/logstream.hxx>
+#include <simgear/constants.h>
+#include <simgear/debug/logstream.hxx>
+#include <simgear/math/fg_geodesy.hxx>
+#include <simgear/math/point3d.hxx>
+#include <simgear/math/polar3d.hxx>
+#include <simgear/misc/fgpath.hxx>
+
#include <Aircraft/aircraft.hxx>
#include <Airports/simple.hxx>
-#include <Astro/sky.hxx>
-#include <Astro/stars.hxx>
-#include <Astro/solarsystem.hxx>
-#include <Autopilot/autopilot.hxx>
+#include <Autopilot/auto_gui.hxx>
+#include <Autopilot/newauto.hxx>
#include <Cockpit/cockpit.hxx>
-// #include <FDM/Balloon.h>
+#include <Cockpit/radiostack.hxx>
+#include <Cockpit/panel.hxx>
+#include <Cockpit/sp_panel.hxx>
+#include <FDM/Balloon.h>
+#include <FDM/External.hxx>
#include <FDM/JSBsim.hxx>
#include <FDM/LaRCsim.hxx>
#include <FDM/MagicCarpet.hxx>
-#include <Include/fg_constants.h>
#include <Include/general.hxx>
#include <Joystick/joystick.hxx>
-#include <Math/fg_geodesy.hxx>
-#include <Math/point3d.hxx>
-#include <Math/polar3d.hxx>
-#include <Misc/fgpath.hxx>
+#include <Objects/matlib.hxx>
+#include <Navaids/fixlist.hxx>
+#include <Navaids/ilslist.hxx>
+#include <Navaids/navlist.hxx>
#include <Scenery/scenery.hxx>
#include <Scenery/tilemgr.hxx>
#include <Time/event.hxx>
#endif
#include "fg_init.hxx"
+#include "fg_io.hxx"
#include "options.hxx"
#include "views.hxx"
-#include "fg_serial.hxx"
+#include "bfi.hxx"
#if defined(FX) && defined(XMESA)
#include <GL/xmesa.h>
return false;
}
- return true;
+ return true;
}
if ( id.length() ) {
// set initial position from airport id
- fgAIRPORTS airports;
- fgAIRPORT a;
+ FGPath path( current_options.get_fg_root() );
+ path.append( "Airports" );
+ path.append( "simple.mk4" );
+ FGAirports airports( path.c_str() );
+ FGAirport a;
FG_LOG( FG_GENERAL, FG_INFO,
"Attempting to set starting position from airport code "
<< id );
- airports.load("apt_simple");
+ // FGPath inpath( current_options.get_fg_root() );
+ // inpath.append( "Airports" );
+ // inpath.append( "apt_simple" );
+ // airports.load( inpath.c_str() );
+
+ // FGPath outpath( current_options.get_fg_root() );
+ // outpath.append( "Airports" );
+ // outpath.append( "simple.gdbm" );
+ // airports.dump_gdbm( outpath.c_str() );
+
if ( ! airports.search( id, &a ) ) {
FG_LOG( FG_GENERAL, FG_ALERT,
"Failed to find " << id << " in database." );
// General house keeping initializations
bool fgInitGeneral( void ) {
string root;
+
+#if defined(FX) && defined(XMESA)
char *mesa_win_state;
+#endif
FG_LOG( FG_GENERAL, FG_INFO, "General Initialization" );
FG_LOG( FG_GENERAL, FG_INFO, "======= ==============" );
// gear, its initialization call should located in this routine.
// Returns non-zero if a problem encountered.
bool fgInitSubsystems( void ) {
- FGTime::cur_time_params = new FGTime();
-
fgLIGHT *l = &cur_light_params;
FGTime *t = FGTime::cur_time_params;
cur_fdm_state = new FGLaRCsim;
} else if ( current_options.get_flight_model() == FGInterface::FG_JSBSIM ) {
cur_fdm_state = new FGJSBsim;
- // } else if ( current_options.get_flight_model() ==
- // FGInterface::FG_BALLOONSIM ) {
- // cur_fdm_state = new FGBalloonSim;
+ } else if ( current_options.get_flight_model() ==
+ FGInterface::FG_BALLOONSIM ) {
+ cur_fdm_state = new FGBalloonSim;
} else if ( current_options.get_flight_model() ==
FGInterface::FG_MAGICCARPET ) {
cur_fdm_state = new FGMagicCarpet;
+ } else if ( current_options.get_flight_model() ==
+ FGInterface::FG_EXTERNAL ) {
+ cur_fdm_state = new FGExternal;
} else {
FG_LOG( FG_GENERAL, FG_ALERT,
"No flight model, can't init aircraft" );
// set the initial position
fgInitPosition();
+ // Initialize the material property lib
+ FGPath mpath( current_options.get_fg_root() );
+ mpath.append( "materials" );
+ if ( material_lib.load( mpath.str() ) ) {
+ } else {
+ FG_LOG( FG_GENERAL, FG_ALERT, "Error loading material lib!" );
+ exit(-1);
+ }
+
// Initialize the Scenery Management subsystem
if ( fgSceneryInit() ) {
- // Scenery initialized ok.
+ // Material lib initialized ok.
} else {
FG_LOG( FG_GENERAL, FG_ALERT, "Error in Scenery initialization!" );
exit(-1);
if( global_tile_mgr.init() ) {
// Load the local scenery data
- global_tile_mgr.update();
+ global_tile_mgr.update( cur_fdm_state->get_Longitude(),
+ cur_fdm_state->get_Latitude() );
} else {
FG_LOG( FG_GENERAL, FG_ALERT, "Error in Tile Manager initialization!" );
exit(-1);
&fgEVENT_MGR::PrintStats),
fgEVENT::FG_EVENT_READY, 60000 );
- // Initialize the time dependent variables
- t->init(*cur_fdm_state);
- t->update(*cur_fdm_state);
-
// Initialize view parameters
FG_LOG( FG_GENERAL, FG_DEBUG, "Before current_view.init()");
current_view.Init();
FG_LOG( FG_GENERAL, FG_DEBUG, " abs_view_pos = " << current_view.get_abs_view_pos());
// current_view.UpdateWorldToEye(f);
- // Build the solar system
- //fgSolarSystemInit(*t);
- FG_LOG(FG_GENERAL, FG_INFO, "Building SolarSystem");
- SolarSystem::theSolarSystem = new SolarSystem(t);
-
- // Initialize the Stars subsystem
- if( fgStarsInit() ) {
- // Stars initialized ok.
- } else {
- FG_LOG( FG_GENERAL, FG_ALERT, "Error in Stars initialization!" );
- exit(-1);
- }
-
// Initialize the planetary subsystem
// global_events.Register( "fgPlanetsInit()", fgPlanetsInit,
// fgEVENT::FG_EVENT_READY, 600000);
// global_events.Register( "fgMoonInit()", fgMoonInit,
// fgEVENT::FG_EVENT_READY, 600000 );
- // register the periodic update of Sun, moon, and planets
- global_events.Register( "ssolsysUpdate", solarSystemRebuild,
- fgEVENT::FG_EVENT_READY, 600000);
-
// fgUpdateSunPos() needs a few position and view parameters set
// so it can calculate local relative sun angle and a few other
// things for correctly orienting the sky.
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
// Initialize the WeatherDatabase
FG_LOG(FG_GENERAL, FG_INFO, "Creating LocalWeatherDatabase");
+ sgVec3 position;
+ sgSetVec3( position, current_aircraft.fdm_state->get_Latitude(),
+ current_aircraft.fdm_state->get_Longitude(),
+ current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER );
FGLocalWeatherDatabase::theFGLocalWeatherDatabase =
- new FGLocalWeatherDatabase(
- Point3D( current_aircraft.fdm_state->get_Latitude(),
- current_aircraft.fdm_state->get_Longitude(),
- current_aircraft.fdm_state->get_Altitude()
- * FEET_TO_METER) );
+ new FGLocalWeatherDatabase( position );
+ // cout << theFGLocalWeatherDatabase << endl;
+ // cout << "visibility = "
+ // << theFGLocalWeatherDatabase->getWeatherVisibility() << endl;
WeatherDatabase = FGLocalWeatherDatabase::theFGLocalWeatherDatabase;
-
+
// register the periodic update of the weather
global_events.Register( "weather update", fgUpdateWeatherDatabase,
- fgEVENT::FG_EVENT_READY, 30000);
+ fgEVENT::FG_EVENT_READY, 30000);
#else
current_weather.Init();
#endif
+ // Initialize vor/ndb/ils/fix list management and query systems
+ FG_LOG(FG_GENERAL, FG_INFO, "Loading Navaids");
+
+ FG_LOG(FG_GENERAL, FG_INFO, " VOR/NDB");
+ current_navlist = new FGNavList;
+ FGPath p_nav( current_options.get_fg_root() );
+ p_nav.append( "Navaids/default.nav" );
+ current_navlist->init( p_nav );
+
+ FG_LOG(FG_GENERAL, FG_INFO, " ILS");
+ current_ilslist = new FGILSList;
+ FGPath p_ils( current_options.get_fg_root() );
+ p_ils.append( "Navaids/default.ils" );
+ current_ilslist->init( p_ils );
+
+ FG_LOG(FG_GENERAL, FG_INFO, " Fixes");
+ current_fixlist = new FGFixList;
+ FGPath p_fix( current_options.get_fg_root() );
+ p_fix.append( "Navaids/default.fix" );
+ current_fixlist->init( p_fix );
+
+ // Initialize the underlying radio stack model
+ current_radiostack = new FGRadioStack;
+
+ current_radiostack->set_nav1_freq( 117.30 );
+ current_radiostack->set_nav1_alt_freq( 110.30 );
+ current_radiostack->set_nav1_sel_radial( 119.0 );
+
+ current_radiostack->set_nav2_freq( 111.80 );
+ current_radiostack->set_nav2_alt_freq( 115.70 );
+ current_radiostack->set_nav2_sel_radial( 029.0 );
+
+ current_radiostack->set_adf_freq( 266.0 );
+
+#if 0
+ // This block of settings are Alex's defaults for San Diego
+ current_radiostack->set_nav1_freq( 111.70 );
+ current_radiostack->set_nav1_alt_freq( 115.30 );
+ current_radiostack->set_nav1_sel_radial( 280.0 );
+ current_radiostack->set_nav2_freq( 117.80 );
+ current_radiostack->set_nav2_alt_freq( 114.00 );
+ current_radiostack->set_nav2_sel_radial( 68.0 );
+ current_radiostack->set_adf_freq( 210.0 );
+ // End of Alex's custom settings
+#endif
+
+ current_radiostack->search( cur_fdm_state->get_Longitude(),
+ cur_fdm_state->get_Latitude(),
+ cur_fdm_state->get_Altitude() * FEET_TO_METER );
+
+ current_radiostack->update( cur_fdm_state->get_Longitude(),
+ cur_fdm_state->get_Latitude(),
+ cur_fdm_state->get_Altitude() * FEET_TO_METER );
+
+ // Search radio database once per second
+ global_events.Register( "fgRadioSearch()", fgRadioSearch,
+ fgEVENT::FG_EVENT_READY, 1000);
+
+
// Initialize the Cockpit subsystem
if( fgCockpitInit( ¤t_aircraft )) {
// Cockpit initialized ok.
exit(-1);
}
- // Initialize the "sky"
- fgSkyInit();
-
// Initialize the flight model subsystem data structures base on
// above values
FG_LOG( FG_GENERAL, FG_ALERT, "Error in Joystick initialization!" );
}
- // Autopilot init added here, by Jeff Goeke-Smith
- fgAPInit(¤t_aircraft);
+ // Autopilot init
+ current_autopilot = new FGAutopilot;
+ current_autopilot->init();
+
+ // initialize the gui parts of the autopilot
+ NewTgtAirportInit();
+ fgAPAdjustInit() ;
+ NewHeadingInit();
+ NewAltitudeInit();
- // Initialize serial ports
+ // Initialize I/O channels
#if ! defined( MACOS )
- fgSerialInit();
+ fgIOInit();
#endif
+ // Initialize the 2D panel.
+ current_panel = fgCreateSmallSinglePropPanel(0, 0, 1024, 768);
+
+ // Initialize the BFI
+ FGBFI::init();
+
FG_LOG( FG_GENERAL, FG_INFO, endl);
return true;
fgInitPosition();
if( global_tile_mgr.init() ) {
// Load the local scenery data
- global_tile_mgr.update();
+ global_tile_mgr.update( cur_fdm_state->get_Longitude(),
+ cur_fdm_state->get_Latitude() );
} else {
FG_LOG( FG_GENERAL, FG_ALERT, "Error in Tile Manager initialization!" );
exit(-1);
}
controls.reset_all();
- fgAPReset();
+ current_autopilot->reset();
if( !toggle_pause )
t->togglePauseMode();