1 // fg_init.cxx -- Flight Gear top level initialization routines
3 // Written by Curtis Olson, started August 1997.
5 // Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 // For BC 5.01 this must be included before OpenGL includes.
30 #ifdef SG_MATH_EXCEPTION_CLASH
44 #if defined( unix ) || defined( __CYGWIN__ )
45 # include <unistd.h> // for gethostname()
48 // work around a stdc++ lib bug in some versions of linux, but doesn't
49 // seem to hurt to have this here for all versions of Linux.
51 # define _G_NO_EXTERN_TEMPLATES
54 #include <simgear/compiler.h>
58 #include <simgear/constants.h>
59 #include <simgear/debug/logstream.hxx>
60 #include <simgear/math/point3d.hxx>
61 #include <simgear/math/polar3d.hxx>
62 #include <simgear/math/sg_geodesy.hxx>
63 #include <simgear/misc/sg_path.hxx>
64 #include <simgear/timing/sg_time.hxx>
66 #include <Aircraft/aircraft.hxx>
67 #include <FDM/UIUCModel/uiuc_aircraftdir.h>
68 #include <Airports/runways.hxx>
69 #include <Airports/simple.hxx>
70 #include <Autopilot/auto_gui.hxx>
71 #include <Autopilot/newauto.hxx>
72 #include <Cockpit/cockpit.hxx>
73 #include <Cockpit/radiostack.hxx>
74 #include <Cockpit/panel.hxx>
75 #include <Cockpit/panel_io.hxx>
76 #include <FDM/ADA.hxx>
77 #include <FDM/Balloon.h>
78 #include <FDM/External.hxx>
79 #include <FDM/JSBSim.hxx>
80 #include <FDM/LaRCsim.hxx>
81 #include <FDM/MagicCarpet.hxx>
82 #include <Include/general.hxx>
83 #include <Input/input.hxx>
84 #include <Joystick/joystick.hxx>
85 #include <Objects/matlib.hxx>
86 #include <Navaids/fixlist.hxx>
87 #include <Navaids/ilslist.hxx>
88 #include <Navaids/mkrbeacons.hxx>
89 #include <Navaids/navlist.hxx>
90 #include <Scenery/scenery.hxx>
91 #include <Scenery/tilemgr.hxx>
92 #include <Time/event.hxx>
93 #include <Time/light.hxx>
94 #include <Time/sunpos.hxx>
95 #include <Time/moonpos.hxx>
96 #include <Time/tmp.hxx>
98 #ifndef FG_OLD_WEATHER
99 # include <WeatherCM/FGLocalWeatherDatabase.h>
101 # include <Weather/weather.hxx>
104 #include "fg_init.hxx"
106 #include "options.hxx"
107 #include "globals.hxx"
110 #if defined(FX) && defined(XMESA)
111 #include <GL/xmesa.h>
114 SG_USING_STD(string);
116 extern const char *default_root;
119 // Read in configuration (file and command line) and just set fg_root
120 bool fgInitFGRoot ( int argc, char **argv ) {
124 // First parse command line options looking for fg-root, this will
125 // override anything specified in a config file
126 root = fgScanForRoot(argc, argv);
128 #if defined( unix ) || defined( __CYGWIN__ )
129 // Next check home directory for .fgfsrc.hostname file
131 envp = ::getenv( "HOME" );
132 if ( envp != NULL ) {
133 SGPath config( envp );
134 config.append( ".fgfsrc" );
136 gethostname( name, 256 );
137 config.concat( "." );
138 config.concat( name );
139 root = fgScanForRoot(config.str());
144 // Next check home directory for .fgfsrc file
146 envp = ::getenv( "HOME" );
147 if ( envp != NULL ) {
148 SGPath config( envp );
149 config.append( ".fgfsrc" );
150 root = fgScanForRoot(config.str());
154 // Next check if fg-root is set as an env variable
156 envp = ::getenv( "FG_ROOT" );
157 if ( envp != NULL ) {
162 // Otherwise, default to a random compiled-in location if we can't
163 // find fg-root any other way.
165 #if defined( __CYGWIN__ )
166 root = "/FlightGear";
167 #elif defined( WIN32 )
168 root = "\\FlightGear";
169 #elif defined( macintosh )
176 SG_LOG(SG_INPUT, SG_INFO, "fg_root = " << root );
177 globals->set_fg_root(root);
183 // Read in configuration (file and command line)
184 bool fgInitConfig ( int argc, char **argv ) {
186 // First, set some sane default values
189 // Read global preferences from $FG_ROOT/preferences.xml
190 SGPath props_path(globals->get_fg_root());
191 props_path.append("preferences.xml");
192 SG_LOG(SG_INPUT, SG_INFO, "Reading global preferences");
193 if (!readProperties(props_path.str(), globals->get_props())) {
194 SG_LOG(SG_INPUT, SG_ALERT, "Failed to read global preferences from "
195 << props_path.str());
197 SG_LOG(SG_INPUT, SG_INFO, "Finished Reading global preferences");
200 // Attempt to locate and parse the various config files in order
201 // from least precidence to greatest precidence
203 // Check for $fg_root/system.fgfsrc
204 SGPath config( globals->get_fg_root() );
205 config.append( "system.fgfsrc" );
206 fgParseOptions(config.str());
209 #if defined( unix ) || defined( __CYGWIN__ )
210 // Check for $fg_root/system.fgfsrc.hostname
211 gethostname( name, 256 );
212 config.concat( "." );
213 config.concat( name );
214 fgParseOptions(config.str());
217 // Check for ~/.fgfsrc
218 char* envp = ::getenv( "HOME" );
219 if ( envp != NULL ) {
221 config.append( ".fgfsrc" );
222 fgParseOptions(config.str());
225 #if defined( unix ) || defined( __CYGWIN__ )
226 // Check for ~/.fgfsrc.hostname
227 gethostname( name, 256 );
228 config.concat( "." );
229 config.concat( name );
230 fgParseOptions(config.str());
233 // Parse remaining command line options
234 // These will override anything specified in a config file
235 fgParseOptions(argc, argv);
241 // find basic airport location info from airport database
242 bool fgFindAirportID( const string& id, FGAirport *a ) {
244 SGPath path( globals->get_fg_root() );
245 path.append( "Airports" );
246 path.append( "simple.mk4" );
247 FGAirports airports( path.c_str() );
249 SG_LOG( SG_GENERAL, SG_INFO, "Searching for airport code = " << id );
251 if ( ! airports.search( id, a ) ) {
252 SG_LOG( SG_GENERAL, SG_ALERT,
253 "Failed to find " << id << " in " << path.str() );
260 SG_LOG( SG_GENERAL, SG_INFO,
261 "Position for " << id << " is ("
262 << a->longitude << ", "
263 << a->latitude << ")" );
269 // Set current_options lon/lat given an airport id
270 bool fgSetPosFromAirportID( const string& id ) {
274 SG_LOG( SG_GENERAL, SG_INFO,
275 "Attempting to set starting position from airport code " << id );
277 if ( fgFindAirportID( id, &a ) ) {
278 fgSetDouble("/position/longitude", a.longitude );
279 fgSetDouble("/position/latitude", a.latitude );
280 SG_LOG( SG_GENERAL, SG_INFO,
281 "Position for " << id << " is ("
282 << a.longitude << ", "
283 << a.latitude << ")" );
293 // Set current_options lon/lat given an airport id and heading (degrees)
294 bool fgSetPosFromAirportIDandHdg( const string& id, double tgt_hdg ) {
297 double found_dir = 0.0;
300 // set initial position from runway and heading
302 SGPath path( globals->get_fg_root() );
303 path.append( "Airports" );
304 path.append( "runways.mk4" );
305 FGRunways runways( path.c_str() );
307 SG_LOG( SG_GENERAL, SG_INFO,
308 "Attempting to set starting position from runway code "
309 << id << " heading " << tgt_hdg );
311 // SGPath inpath( globals->get_fg_root() );
312 // inpath.append( "Airports" );
313 // inpath.append( "apt_simple" );
314 // airports.load( inpath.c_str() );
316 // SGPath outpath( globals->get_fg_root() );
317 // outpath.append( "Airports" );
318 // outpath.append( "simple.gdbm" );
319 // airports.dump_gdbm( outpath.c_str() );
321 if ( ! runways.search( id, &r ) ) {
322 SG_LOG( SG_GENERAL, SG_ALERT,
323 "Failed to find " << id << " in database." );
328 double min_diff = 360.0;
330 while ( r.id == id ) {
332 diff = tgt_hdg - r.heading;
333 while ( diff < -180.0 ) { diff += 360.0; }
334 while ( diff > 180.0 ) { diff -= 360.0; }
336 SG_LOG( SG_GENERAL, SG_INFO,
337 "Runway " << r.rwy_no << " heading = " << r.heading <<
338 " diff = " << diff );
339 if ( diff < min_diff ) {
346 diff = tgt_hdg - r.heading - 180.0;
347 while ( diff < -180.0 ) { diff += 360.0; }
348 while ( diff > 180.0 ) { diff -= 360.0; }
350 SG_LOG( SG_GENERAL, SG_INFO,
351 "Runway -" << r.rwy_no << " heading = " <<
353 " diff = " << diff );
354 if ( diff < min_diff ) {
363 SG_LOG( SG_GENERAL, SG_INFO, "closest runway = " << found_r.rwy_no
364 << " + " << found_dir );
370 double heading = found_r.heading + found_dir;
371 while ( heading >= 360.0 ) { heading -= 360.0; }
373 double lat2, lon2, az2;
374 double azimuth = found_r.heading + found_dir + 180.0;
375 while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
377 SG_LOG( SG_GENERAL, SG_INFO,
378 "runway = " << found_r.lon << ", " << found_r.lat
379 << " length = " << found_r.length * SG_FEET_TO_METER * 0.5
380 << " heading = " << azimuth );
382 geo_direct_wgs_84 ( 0, found_r.lat, found_r.lon,
383 azimuth, found_r.length * SG_FEET_TO_METER * 0.5 - 5.0,
384 &lat2, &lon2, &az2 );
386 if ( fabs( fgGetDouble("/sim/startup/offset-distance") ) > SG_EPSILON ) {
388 double odist = fgGetDouble("/sim/startup/offset-distance");
389 odist *= SG_NM_TO_METER;
390 double oaz = azimuth;
391 if ( fabs(fgGetDouble("/sim/startup/offset-azimuth")) > SG_EPSILON ) {
392 oaz = fgGetDouble("/sim/startup/offset-azimuth") + 180;
394 while ( oaz >= 360.0 ) { oaz -= 360.0; }
395 geo_direct_wgs_84 ( 0, lat2, lon2, oaz, odist, &olat, &olon, &az2 );
399 fgSetDouble("/position/longitude", lon2 );
400 fgSetDouble("/position/latitude", lat2 );
401 fgSetDouble("/orientation/heading", heading );
403 SG_LOG( SG_GENERAL, SG_INFO,
404 "Position for " << id << " is ("
406 << lat2 << ") new heading is "
413 // General house keeping initializations
414 bool fgInitGeneral( void ) {
417 #if defined(FX) && defined(XMESA)
418 char *mesa_win_state;
421 SG_LOG( SG_GENERAL, SG_INFO, "General Initialization" );
422 SG_LOG( SG_GENERAL, SG_INFO, "======= ==============" );
424 root = globals->get_fg_root();
425 if ( ! root.length() ) {
426 // No root path set? Then bail ...
427 SG_LOG( SG_GENERAL, SG_ALERT,
428 "Cannot continue without environment variable FG_ROOT"
429 << "being defined." );
432 SG_LOG( SG_GENERAL, SG_INFO, "FG_ROOT = " << '"' << root << '"' << endl );
434 #if defined(FX) && defined(XMESA)
435 // initialize full screen flag
436 global_fullscreen = false;
437 if ( strstr ( general.get_glRenderer(), "Glide" ) ) {
438 // Test for the MESA_GLX_FX env variable
439 if ( (mesa_win_state = getenv( "MESA_GLX_FX" )) != NULL) {
440 // test if we are fullscreen mesa/glide
441 if ( (mesa_win_state[0] == 'f') ||
442 (mesa_win_state[0] == 'F') ) {
443 global_fullscreen = true;
453 // This is the top level init routine which calls all the other
454 // initialization routines. If you are adding a subsystem to flight
455 // gear, its initialization call should located in this routine.
456 // Returns non-zero if a problem encountered.
457 bool fgInitSubsystems( void ) {
458 fgLIGHT *l = &cur_light_params;
460 SG_LOG( SG_GENERAL, SG_INFO, "Initialize Subsystems");
461 SG_LOG( SG_GENERAL, SG_INFO, "========== ==========");
464 ////////////////////////////////////////////////////////////////////
465 // Initialize the material property subsystem.
466 ////////////////////////////////////////////////////////////////////
468 SGPath mpath( globals->get_fg_root() );
469 mpath.append( "materials" );
470 if ( material_lib.load( mpath.str() ) ) {
472 SG_LOG( SG_GENERAL, SG_ALERT, "Error loading material lib!" );
477 ////////////////////////////////////////////////////////////////////
478 // Initialize the scenery management subsystem.
479 ////////////////////////////////////////////////////////////////////
481 if ( fgSceneryInit() ) {
482 // Material lib initialized ok.
484 SG_LOG( SG_GENERAL, SG_ALERT, "Error in Scenery initialization!" );
488 if ( global_tile_mgr.init() ) {
489 // Load the local scenery data
490 global_tile_mgr.update( fgGetDouble("/position/longitude"),
491 fgGetDouble("/position/latitude") );
493 SG_LOG( SG_GENERAL, SG_ALERT, "Error in Tile Manager initialization!" );
497 SG_LOG( SG_GENERAL, SG_DEBUG,
498 "Current terrain elevation after tile mgr init " <<
502 ////////////////////////////////////////////////////////////////////
503 // Initialize the flight model subsystem.
504 ////////////////////////////////////////////////////////////////////
506 double dt = 1.0 / fgGetInt("/sim/model-hz");
507 // cout << "dt = " << dt << endl;
509 aircraft_dir = fgGetString("/sim/aircraft-dir");
510 const string &model = fgGetString("/sim/flight-model");
511 if (model == "larcsim") {
512 cur_fdm_state = new FGLaRCsim( dt );
513 } else if (model == "jsb") {
514 cur_fdm_state = new FGJSBsim( dt );
515 } else if (model == "ada") {
516 cur_fdm_state = new FGADA( dt );
517 } else if (model == "balloon") {
518 cur_fdm_state = new FGBalloonSim( dt );
519 } else if (model == "magic") {
520 cur_fdm_state = new FGMagicCarpet( dt );
521 } else if (model == "external") {
522 cur_fdm_state = new FGExternal( dt );
524 SG_LOG(SG_GENERAL, SG_ALERT,
525 "Unrecognized flight model '" << model
526 << ", can't init aircraft");
529 cur_fdm_state->init();
530 cur_fdm_state->bind();
532 // allocates structures so must happen before any of the flight
533 // model or control parameters are set
534 fgAircraftInit(); // In the future this might not be the case.
537 ////////////////////////////////////////////////////////////////////
538 // Initialize the event manager subsystem.
539 ////////////////////////////////////////////////////////////////////
541 global_events.Init();
543 // Output event stats every 60 seconds
544 global_events.Register( "fgEVENT_MGR::PrintStats()",
545 fgMethodCallback<fgEVENT_MGR>( &global_events,
546 &fgEVENT_MGR::PrintStats),
547 fgEVENT::FG_EVENT_READY, 60000 );
550 ////////////////////////////////////////////////////////////////////
551 // Initialize the view manager subsystem.
552 ////////////////////////////////////////////////////////////////////
554 // Initialize win_ratio parameters
555 for ( int i = 0; i < globals->get_viewmgr()->size(); ++i ) {
556 globals->get_viewmgr()->get_view(i)->
557 set_win_ratio( fgGetInt("/sim/startup/xsize") /
558 fgGetInt("/sim/startup/ysize") );
561 // Initialize pilot view
562 FGViewerRPH *pilot_view =
563 (FGViewerRPH *)globals->get_viewmgr()->get_view( 0 );
565 pilot_view->set_geod_view_pos( cur_fdm_state->get_Longitude(),
566 cur_fdm_state->get_Lat_geocentric(),
567 cur_fdm_state->get_Altitude() *
569 pilot_view->set_sea_level_radius( cur_fdm_state->get_Sea_level_radius() *
571 pilot_view->set_rph( cur_fdm_state->get_Phi(),
572 cur_fdm_state->get_Theta(),
573 cur_fdm_state->get_Psi() );
575 // set current view to 0 (first) which is our main pilot view
576 globals->set_current_view( pilot_view );
578 SG_LOG( SG_GENERAL, SG_DEBUG, " abs_view_pos = "
579 << globals->get_current_view()->get_abs_view_pos());
582 ////////////////////////////////////////////////////////////////////
583 // Initialize the lighting subsystem.
584 ////////////////////////////////////////////////////////////////////
586 // fgUpdateSunPos() needs a few position and view parameters set
587 // so it can calculate local relative sun angle and a few other
588 // things for correctly orienting the sky.
591 global_events.Register( "fgUpdateSunPos()", fgUpdateSunPos,
592 fgEVENT::FG_EVENT_READY, 60000);
593 global_events.Register( "fgUpdateMoonPos()", fgUpdateMoonPos,
594 fgEVENT::FG_EVENT_READY, 60000);
596 // Initialize Lighting interpolation tables
599 // update the lighting parameters (based on sun angle)
600 global_events.Register( "fgLight::Update()",
601 fgMethodCallback<fgLIGHT>( &cur_light_params,
603 fgEVENT::FG_EVENT_READY, 30000 );
606 ////////////////////////////////////////////////////////////////////
607 // Initialize the local time subsystem.
608 ////////////////////////////////////////////////////////////////////
610 // update the current timezone each 30 minutes
611 global_events.Register( "fgUpdateLocalTime()", fgUpdateLocalTime,
612 fgEVENT::FG_EVENT_READY, 1800000);
615 ////////////////////////////////////////////////////////////////////
616 // Initialize the weather subsystem.
617 ////////////////////////////////////////////////////////////////////
619 // Initialize the weather modeling subsystem
620 #ifndef FG_OLD_WEATHER
621 // Initialize the WeatherDatabase
622 SG_LOG(SG_GENERAL, SG_INFO, "Creating LocalWeatherDatabase");
624 sgSetVec3( position, current_aircraft.fdm_state->get_Latitude(),
625 current_aircraft.fdm_state->get_Longitude(),
626 current_aircraft.fdm_state->get_Altitude() * SG_FEET_TO_METER );
627 FGLocalWeatherDatabase::theFGLocalWeatherDatabase =
628 new FGLocalWeatherDatabase( position,
629 globals->get_fg_root() );
630 // cout << theFGLocalWeatherDatabase << endl;
631 // cout << "visibility = "
632 // << theFGLocalWeatherDatabase->getWeatherVisibility() << endl;
634 WeatherDatabase = FGLocalWeatherDatabase::theFGLocalWeatherDatabase;
636 double init_vis = fgGetDouble("/environment/visibility");
637 if ( init_vis > 0 ) {
638 WeatherDatabase->setWeatherVisibility( init_vis );
641 // register the periodic update of the weather
642 global_events.Register( "weather update", fgUpdateWeatherDatabase,
643 fgEVENT::FG_EVENT_READY, 30000);
645 current_weather.Init();
648 ////////////////////////////////////////////////////////////////////
649 // Initialize vor/ndb/ils/fix list management and query systems
650 ////////////////////////////////////////////////////////////////////
652 SG_LOG(SG_GENERAL, SG_INFO, "Loading Navaids");
654 SG_LOG(SG_GENERAL, SG_INFO, " VOR/NDB");
655 current_navlist = new FGNavList;
656 SGPath p_nav( globals->get_fg_root() );
657 p_nav.append( "Navaids/default.nav" );
658 current_navlist->init( p_nav );
660 SG_LOG(SG_GENERAL, SG_INFO, " ILS and Marker Beacons");
661 current_beacons = new FGMarkerBeacons;
662 current_beacons->init();
663 current_ilslist = new FGILSList;
664 SGPath p_ils( globals->get_fg_root() );
665 p_ils.append( "Navaids/default.ils" );
666 current_ilslist->init( p_ils );
668 SG_LOG(SG_GENERAL, SG_INFO, " Fixes");
669 current_fixlist = new FGFixList;
670 SGPath p_fix( globals->get_fg_root() );
671 p_fix.append( "Navaids/default.fix" );
672 current_fixlist->init( p_fix );
675 ////////////////////////////////////////////////////////////////////
676 // Initialize the radio stack subsystem.
677 ////////////////////////////////////////////////////////////////////
679 // A textbook example of how FGSubsystem
681 current_radiostack = new FGRadioStack;
682 current_radiostack->init();
683 current_radiostack->bind();
686 ////////////////////////////////////////////////////////////////////
687 // Initialize the cockpit subsystem
688 ////////////////////////////////////////////////////////////////////
690 if( fgCockpitInit( ¤t_aircraft )) {
691 // Cockpit initialized ok.
693 SG_LOG( SG_GENERAL, SG_ALERT, "Error in Cockpit initialization!" );
698 ////////////////////////////////////////////////////////////////////
699 // Initialize the joystick subsystem.
700 ////////////////////////////////////////////////////////////////////
702 if ( ! fgJoystickInit() ) {
703 SG_LOG( SG_GENERAL, SG_ALERT, "Error in Joystick initialization!" );
707 ////////////////////////////////////////////////////////////////////
708 // Initialize the autopilot subsystem.
709 ////////////////////////////////////////////////////////////////////
711 current_autopilot = new FGAutopilot;
712 current_autopilot->init();
714 // initialize the gui parts of the autopilot
721 ////////////////////////////////////////////////////////////////////
722 // Initialize I/O subsystem.
723 ////////////////////////////////////////////////////////////////////
725 #if ! defined( macintosh )
729 // Initialize the 2D panel.
730 string panel_path = fgGetString("/sim/panel/path",
731 "Panels/Default/default.xml");
732 current_panel = fgReadPanel(panel_path);
733 if (current_panel == 0) {
734 SG_LOG( SG_INPUT, SG_ALERT,
735 "Error reading new panel from " << panel_path );
737 SG_LOG( SG_INPUT, SG_INFO, "Loaded new panel from " << panel_path );
738 current_panel->init();
739 current_panel->bind();
743 ////////////////////////////////////////////////////////////////////
744 // Initialize the BFI.
745 ////////////////////////////////////////////////////////////////////
750 ////////////////////////////////////////////////////////////////////
751 // Initialize the controls subsystem.
752 ////////////////////////////////////////////////////////////////////
758 ////////////////////////////////////////////////////////////////////
759 // Initialize the input subsystem.
760 ////////////////////////////////////////////////////////////////////
762 current_input.init();
763 current_input.bind();
766 ////////////////////////////////////////////////////////////////////////
767 // End of subsystem initialization.
768 ////////////////////////////////////////////////////////////////////
770 SG_LOG( SG_GENERAL, SG_INFO, endl);
772 // Save the initial state for future
774 globals->saveInitialState();
780 void fgReInitSubsystems( void )
782 SG_LOG( SG_GENERAL, SG_INFO,
783 "/position/altitude = " << fgGetDouble("/position/altitude") );
785 bool freeze = globals->get_freeze();
787 globals->set_freeze( true );
789 // Initialize the Scenery Management subsystem
790 if ( ! fgSceneryInit() ) {
791 SG_LOG( SG_GENERAL, SG_ALERT, "Error in Scenery initialization!" );
795 if( global_tile_mgr.init() ) {
796 // Load the local scenery data
797 global_tile_mgr.update( fgGetDouble("/position/longitude"),
798 fgGetDouble("/position/latitude") );
800 SG_LOG( SG_GENERAL, SG_ALERT, "Error in Tile Manager initialization!" );
804 // Initialize view parameters
805 FGViewerRPH *pilot_view =
806 (FGViewerRPH *)globals->get_viewmgr()->get_view( 0 );
808 pilot_view->set_view_offset( 0.0 );
809 pilot_view->set_goal_view_offset( 0.0 );
811 pilot_view->set_geod_view_pos( cur_fdm_state->get_Longitude(),
812 cur_fdm_state->get_Lat_geocentric(),
813 cur_fdm_state->get_Altitude() *
815 pilot_view->set_sea_level_radius( cur_fdm_state->get_Sea_level_radius() *
817 pilot_view->set_rph( cur_fdm_state->get_Phi(),
818 cur_fdm_state->get_Theta(),
819 cur_fdm_state->get_Psi() );
821 // set current view to 0 (first) which is our main pilot view
822 globals->set_current_view( pilot_view );
824 SG_LOG( SG_GENERAL, SG_DEBUG, " abs_view_pos = "
825 << globals->get_current_view()->get_abs_view_pos());
827 cur_fdm_state->init();
829 controls.reset_all();
830 current_autopilot->reset();
834 cur_light_params.Update();
838 globals->set_freeze( false );