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 "fg_commands.hxx"
107 #include "fg_props.hxx"
108 #include "options.hxx"
109 #include "globals.hxx"
111 #if defined(FX) && defined(XMESA)
112 #include <GL/xmesa.h>
115 SG_USING_STD(string);
117 extern const char *default_root;
120 // Read in configuration (file and command line) and just set fg_root
121 bool fgInitFGRoot ( int argc, char **argv ) {
125 // First parse command line options looking for fg-root, this will
126 // override anything specified in a config file
127 root = fgScanForRoot(argc, argv);
129 #if defined( unix ) || defined( __CYGWIN__ )
130 // Next check home directory for .fgfsrc.hostname file
132 envp = ::getenv( "HOME" );
133 if ( envp != NULL ) {
134 SGPath config( envp );
135 config.append( ".fgfsrc" );
137 gethostname( name, 256 );
138 config.concat( "." );
139 config.concat( name );
140 root = fgScanForRoot(config.str());
145 // Next check home directory for .fgfsrc file
147 envp = ::getenv( "HOME" );
148 if ( envp != NULL ) {
149 SGPath config( envp );
150 config.append( ".fgfsrc" );
151 root = fgScanForRoot(config.str());
155 // Next check if fg-root is set as an env variable
157 envp = ::getenv( "FG_ROOT" );
158 if ( envp != NULL ) {
163 // Otherwise, default to a random compiled-in location if we can't
164 // find fg-root any other way.
166 #if defined( __CYGWIN__ )
167 root = "/FlightGear";
168 #elif defined( WIN32 )
169 root = "\\FlightGear";
170 #elif defined( macintosh )
177 SG_LOG(SG_INPUT, SG_INFO, "fg_root = " << root );
178 globals->set_fg_root(root);
184 // Read in configuration (file and command line)
185 bool fgInitConfig ( int argc, char **argv ) {
187 // First, set some sane default values
190 // Read global preferences from $FG_ROOT/preferences.xml
191 SGPath props_path(globals->get_fg_root());
192 props_path.append("preferences.xml");
193 SG_LOG(SG_INPUT, SG_INFO, "Reading global preferences");
194 if (!readProperties(props_path.str(), globals->get_props())) {
195 SG_LOG(SG_INPUT, SG_ALERT, "Failed to read global preferences from "
196 << props_path.str());
198 SG_LOG(SG_INPUT, SG_INFO, "Finished Reading global preferences");
201 // Attempt to locate and parse the various config files in order
202 // from least precidence to greatest precidence
204 // Check for $fg_root/system.fgfsrc
205 SGPath config( globals->get_fg_root() );
206 config.append( "system.fgfsrc" );
207 fgParseOptions(config.str());
210 #if defined( unix ) || defined( __CYGWIN__ )
211 // Check for $fg_root/system.fgfsrc.hostname
212 gethostname( name, 256 );
213 config.concat( "." );
214 config.concat( name );
215 fgParseOptions(config.str());
218 // Check for ~/.fgfsrc
219 char* envp = ::getenv( "HOME" );
220 if ( envp != NULL ) {
222 config.append( ".fgfsrc" );
223 fgParseOptions(config.str());
226 #if defined( unix ) || defined( __CYGWIN__ )
227 // Check for ~/.fgfsrc.hostname
228 gethostname( name, 256 );
229 config.concat( "." );
230 config.concat( name );
231 fgParseOptions(config.str());
234 // Parse remaining command line options
235 // These will override anything specified in a config file
236 fgParseOptions(argc, argv);
242 // find basic airport location info from airport database
243 bool fgFindAirportID( const string& id, FGAirport *a ) {
245 SGPath path( globals->get_fg_root() );
246 path.append( "Airports" );
247 path.append( "simple.mk4" );
248 FGAirports airports( path.c_str() );
250 SG_LOG( SG_GENERAL, SG_INFO, "Searching for airport code = " << id );
252 if ( ! airports.search( id, a ) ) {
253 SG_LOG( SG_GENERAL, SG_ALERT,
254 "Failed to find " << id << " in " << path.str() );
261 SG_LOG( SG_GENERAL, SG_INFO,
262 "Position for " << id << " is ("
263 << a->longitude << ", "
264 << a->latitude << ")" );
270 // Set current_options lon/lat given an airport id
271 bool fgSetPosFromAirportID( const string& id ) {
275 SG_LOG( SG_GENERAL, SG_INFO,
276 "Attempting to set starting position from airport code " << id );
278 if ( fgFindAirportID( id, &a ) ) {
279 fgSetDouble("/position/longitude-deg", a.longitude );
280 fgSetDouble("/position/latitude-deg", a.latitude );
281 SG_LOG( SG_GENERAL, SG_INFO,
282 "Position for " << id << " is ("
283 << a.longitude << ", "
284 << a.latitude << ")" );
294 // Set current_options lon/lat given an airport id and heading (degrees)
295 bool fgSetPosFromAirportIDandHdg( const string& id, double tgt_hdg ) {
298 double found_dir = 0.0;
301 // set initial position from runway and heading
303 SGPath path( globals->get_fg_root() );
304 path.append( "Airports" );
305 path.append( "runways.mk4" );
306 FGRunways runways( path.c_str() );
308 SG_LOG( SG_GENERAL, SG_INFO,
309 "Attempting to set starting position from runway code "
310 << id << " heading " << tgt_hdg );
312 // SGPath inpath( globals->get_fg_root() );
313 // inpath.append( "Airports" );
314 // inpath.append( "apt_simple" );
315 // airports.load( inpath.c_str() );
317 // SGPath outpath( globals->get_fg_root() );
318 // outpath.append( "Airports" );
319 // outpath.append( "simple.gdbm" );
320 // airports.dump_gdbm( outpath.c_str() );
322 if ( ! runways.search( id, &r ) ) {
323 SG_LOG( SG_GENERAL, SG_ALERT,
324 "Failed to find " << id << " in database." );
329 double min_diff = 360.0;
331 while ( r.id == id ) {
333 diff = tgt_hdg - r.heading;
334 while ( diff < -180.0 ) { diff += 360.0; }
335 while ( diff > 180.0 ) { diff -= 360.0; }
337 SG_LOG( SG_GENERAL, SG_INFO,
338 "Runway " << r.rwy_no << " heading = " << r.heading <<
339 " diff = " << diff );
340 if ( diff < min_diff ) {
347 diff = tgt_hdg - r.heading - 180.0;
348 while ( diff < -180.0 ) { diff += 360.0; }
349 while ( diff > 180.0 ) { diff -= 360.0; }
351 SG_LOG( SG_GENERAL, SG_INFO,
352 "Runway -" << r.rwy_no << " heading = " <<
354 " diff = " << diff );
355 if ( diff < min_diff ) {
364 SG_LOG( SG_GENERAL, SG_INFO, "closest runway = " << found_r.rwy_no
365 << " + " << found_dir );
371 double heading = found_r.heading + found_dir;
372 while ( heading >= 360.0 ) { heading -= 360.0; }
374 double lat2, lon2, az2;
375 double azimuth = found_r.heading + found_dir + 180.0;
376 while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
378 SG_LOG( SG_GENERAL, SG_INFO,
379 "runway = " << found_r.lon << ", " << found_r.lat
380 << " length = " << found_r.length * SG_FEET_TO_METER * 0.5
381 << " heading = " << azimuth );
383 geo_direct_wgs_84 ( 0, found_r.lat, found_r.lon,
384 azimuth, found_r.length * SG_FEET_TO_METER * 0.5 - 5.0,
385 &lat2, &lon2, &az2 );
387 if ( fabs( fgGetDouble("/sim/startup/offset-distance") ) > SG_EPSILON ) {
389 double odist = fgGetDouble("/sim/startup/offset-distance");
390 odist *= SG_NM_TO_METER;
391 double oaz = azimuth;
392 if ( fabs(fgGetDouble("/sim/startup/offset-azimuth")) > SG_EPSILON ) {
393 oaz = fgGetDouble("/sim/startup/offset-azimuth") + 180;
395 while ( oaz >= 360.0 ) { oaz -= 360.0; }
396 geo_direct_wgs_84 ( 0, lat2, lon2, oaz, odist, &olat, &olon, &az2 );
400 fgSetDouble("/position/longitude-deg", lon2 );
401 fgSetDouble("/position/latitude-deg", lat2 );
402 fgSetDouble("/orientation/heading-deg", heading );
404 SG_LOG( SG_GENERAL, SG_INFO,
405 "Position for " << id << " is ("
407 << lat2 << ") new heading is "
414 // General house keeping initializations
415 bool fgInitGeneral( void ) {
418 #if defined(FX) && defined(XMESA)
419 char *mesa_win_state;
422 SG_LOG( SG_GENERAL, SG_INFO, "General Initialization" );
423 SG_LOG( SG_GENERAL, SG_INFO, "======= ==============" );
425 root = globals->get_fg_root();
426 if ( ! root.length() ) {
427 // No root path set? Then bail ...
428 SG_LOG( SG_GENERAL, SG_ALERT,
429 "Cannot continue without environment variable FG_ROOT"
430 << "being defined." );
433 SG_LOG( SG_GENERAL, SG_INFO, "FG_ROOT = " << '"' << root << '"' << endl );
435 #if defined(FX) && defined(XMESA)
436 // initialize full screen flag
437 global_fullscreen = false;
438 if ( strstr ( general.get_glRenderer(), "Glide" ) ) {
439 // Test for the MESA_GLX_FX env variable
440 if ( (mesa_win_state = getenv( "MESA_GLX_FX" )) != NULL) {
441 // test if we are fullscreen mesa/glide
442 if ( (mesa_win_state[0] == 'f') ||
443 (mesa_win_state[0] == 'F') ) {
444 global_fullscreen = true;
454 // This is the top level init routine which calls all the other
455 // initialization routines. If you are adding a subsystem to flight
456 // gear, its initialization call should located in this routine.
457 // Returns non-zero if a problem encountered.
458 bool fgInitSubsystems( void ) {
459 fgLIGHT *l = &cur_light_params;
461 SG_LOG( SG_GENERAL, SG_INFO, "Initialize Subsystems");
462 SG_LOG( SG_GENERAL, SG_INFO, "========== ==========");
465 ////////////////////////////////////////////////////////////////////
466 // Initialize the material property subsystem.
467 ////////////////////////////////////////////////////////////////////
469 SGPath mpath( globals->get_fg_root() );
470 mpath.append( "materials" );
471 if ( material_lib.load( mpath.str() ) ) {
473 SG_LOG( SG_GENERAL, SG_ALERT, "Error loading material lib!" );
478 ////////////////////////////////////////////////////////////////////
479 // Initialize the scenery management subsystem.
480 ////////////////////////////////////////////////////////////////////
482 if ( fgSceneryInit() ) {
483 // Material lib initialized ok.
485 SG_LOG( SG_GENERAL, SG_ALERT, "Error in Scenery initialization!" );
489 if ( global_tile_mgr.init() ) {
490 // Load the local scenery data
491 global_tile_mgr.update( fgGetDouble("/position/longitude-deg"),
492 fgGetDouble("/position/latitude-deg") );
494 SG_LOG( SG_GENERAL, SG_ALERT, "Error in Tile Manager initialization!" );
498 SG_LOG( SG_GENERAL, SG_DEBUG,
499 "Current terrain elevation after tile mgr init " <<
503 ////////////////////////////////////////////////////////////////////
504 // Initialize the flight model subsystem.
505 ////////////////////////////////////////////////////////////////////
507 double dt = 1.0 / fgGetInt("/sim/model-hz");
508 // cout << "dt = " << dt << endl;
510 aircraft_dir = fgGetString("/sim/aircraft-dir");
511 const string &model = fgGetString("/sim/flight-model");
513 if (model == "larcsim") {
514 cur_fdm_state = new FGLaRCsim( dt );
515 } else if (model == "jsb") {
516 cur_fdm_state = new FGJSBsim( dt );
517 } else if (model == "ada") {
518 cur_fdm_state = new FGADA( dt );
519 } else if (model == "balloon") {
520 cur_fdm_state = new FGBalloonSim( dt );
521 } else if (model == "magic") {
522 cur_fdm_state = new FGMagicCarpet( dt );
523 } else if (model == "external") {
524 cur_fdm_state = new FGExternal( dt );
526 SG_LOG(SG_GENERAL, SG_ALERT,
527 "Unrecognized flight model '" << model
528 << ", can't init aircraft");
532 SG_LOG(SG_GENERAL, SG_ALERT, "FlightGear aborting\n\n");
536 cur_fdm_state->init();
537 cur_fdm_state->bind();
539 // allocates structures so must happen before any of the flight
540 // model or control parameters are set
541 fgAircraftInit(); // In the future this might not be the case.
544 ////////////////////////////////////////////////////////////////////
545 // Initialize the event manager subsystem.
546 ////////////////////////////////////////////////////////////////////
548 global_events.Init();
550 // Output event stats every 60 seconds
551 global_events.Register( "fgEVENT_MGR::PrintStats()",
552 fgMethodCallback<fgEVENT_MGR>( &global_events,
553 &fgEVENT_MGR::PrintStats),
554 fgEVENT::FG_EVENT_READY, 60000 );
557 ////////////////////////////////////////////////////////////////////
558 // Initialize the view manager subsystem.
559 ////////////////////////////////////////////////////////////////////
561 // Initialize win_ratio parameters
562 for ( int i = 0; i < globals->get_viewmgr()->size(); ++i ) {
563 globals->get_viewmgr()->get_view(i)->
564 set_win_ratio( fgGetInt("/sim/startup/xsize") /
565 fgGetInt("/sim/startup/ysize") );
568 // Initialize pilot view
569 FGViewerRPH *pilot_view =
570 (FGViewerRPH *)globals->get_viewmgr()->get_view( 0 );
572 pilot_view->set_geod_view_pos( cur_fdm_state->get_Longitude(),
573 cur_fdm_state->get_Lat_geocentric(),
574 cur_fdm_state->get_Altitude() *
576 pilot_view->set_sea_level_radius( cur_fdm_state->get_Sea_level_radius() *
578 pilot_view->set_rph( cur_fdm_state->get_Phi(),
579 cur_fdm_state->get_Theta(),
580 cur_fdm_state->get_Psi() );
582 // set current view to 0 (first) which is our main pilot view
583 globals->set_current_view( pilot_view );
585 SG_LOG( SG_GENERAL, SG_DEBUG, " abs_view_pos = "
586 << globals->get_current_view()->get_abs_view_pos());
589 ////////////////////////////////////////////////////////////////////
590 // Initialize the lighting subsystem.
591 ////////////////////////////////////////////////////////////////////
593 // fgUpdateSunPos() needs a few position and view parameters set
594 // so it can calculate local relative sun angle and a few other
595 // things for correctly orienting the sky.
598 global_events.Register( "fgUpdateSunPos()", fgUpdateSunPos,
599 fgEVENT::FG_EVENT_READY, 60000);
600 global_events.Register( "fgUpdateMoonPos()", fgUpdateMoonPos,
601 fgEVENT::FG_EVENT_READY, 60000);
603 // Initialize Lighting interpolation tables
606 // update the lighting parameters (based on sun angle)
607 global_events.Register( "fgLight::Update()",
608 fgMethodCallback<fgLIGHT>( &cur_light_params,
610 fgEVENT::FG_EVENT_READY, 30000 );
613 ////////////////////////////////////////////////////////////////////
614 // Initialize the local time subsystem.
615 ////////////////////////////////////////////////////////////////////
617 // update the current timezone each 30 minutes
618 global_events.Register( "fgUpdateLocalTime()", fgUpdateLocalTime,
619 fgEVENT::FG_EVENT_READY, 1800000);
622 ////////////////////////////////////////////////////////////////////
623 // Initialize the weather subsystem.
624 ////////////////////////////////////////////////////////////////////
626 // Initialize the weather modeling subsystem
627 #ifndef FG_OLD_WEATHER
628 // Initialize the WeatherDatabase
629 SG_LOG(SG_GENERAL, SG_INFO, "Creating LocalWeatherDatabase");
631 sgSetVec3( position, current_aircraft.fdm_state->get_Latitude(),
632 current_aircraft.fdm_state->get_Longitude(),
633 current_aircraft.fdm_state->get_Altitude() * SG_FEET_TO_METER );
634 FGLocalWeatherDatabase::theFGLocalWeatherDatabase =
635 new FGLocalWeatherDatabase( position,
636 globals->get_fg_root() );
637 // cout << theFGLocalWeatherDatabase << endl;
638 // cout << "visibility = "
639 // << theFGLocalWeatherDatabase->getWeatherVisibility() << endl;
641 WeatherDatabase = FGLocalWeatherDatabase::theFGLocalWeatherDatabase;
643 double init_vis = fgGetDouble("/environment/visibility-m");
644 if ( init_vis > 0 ) {
645 WeatherDatabase->setWeatherVisibility( init_vis );
648 // register the periodic update of the weather
649 global_events.Register( "weather update", fgUpdateWeatherDatabase,
650 fgEVENT::FG_EVENT_READY, 30000);
652 current_weather.Init();
655 ////////////////////////////////////////////////////////////////////
656 // Initialize vor/ndb/ils/fix list management and query systems
657 ////////////////////////////////////////////////////////////////////
659 SG_LOG(SG_GENERAL, SG_INFO, "Loading Navaids");
661 SG_LOG(SG_GENERAL, SG_INFO, " VOR/NDB");
662 current_navlist = new FGNavList;
663 SGPath p_nav( globals->get_fg_root() );
664 p_nav.append( "Navaids/default.nav" );
665 current_navlist->init( p_nav );
667 SG_LOG(SG_GENERAL, SG_INFO, " ILS and Marker Beacons");
668 current_beacons = new FGMarkerBeacons;
669 current_beacons->init();
670 current_ilslist = new FGILSList;
671 SGPath p_ils( globals->get_fg_root() );
672 p_ils.append( "Navaids/default.ils" );
673 current_ilslist->init( p_ils );
675 SG_LOG(SG_GENERAL, SG_INFO, " Fixes");
676 current_fixlist = new FGFixList;
677 SGPath p_fix( globals->get_fg_root() );
678 p_fix.append( "Navaids/default.fix" );
679 current_fixlist->init( p_fix );
682 ////////////////////////////////////////////////////////////////////
683 // Initialize the built-in commands.
684 ////////////////////////////////////////////////////////////////////
688 ////////////////////////////////////////////////////////////////////
689 // Initialize the radio stack subsystem.
690 ////////////////////////////////////////////////////////////////////
692 // A textbook example of how FGSubsystem
694 current_radiostack = new FGRadioStack;
695 current_radiostack->init();
696 current_radiostack->bind();
699 ////////////////////////////////////////////////////////////////////
700 // Initialize the cockpit subsystem
701 ////////////////////////////////////////////////////////////////////
703 if( fgCockpitInit( ¤t_aircraft )) {
704 // Cockpit initialized ok.
706 SG_LOG( SG_GENERAL, SG_ALERT, "Error in Cockpit initialization!" );
711 ////////////////////////////////////////////////////////////////////
712 // Initialize the joystick subsystem.
713 ////////////////////////////////////////////////////////////////////
715 // if ( ! fgJoystickInit() ) {
716 // SG_LOG( SG_GENERAL, SG_ALERT, "Error in Joystick initialization!" );
720 ////////////////////////////////////////////////////////////////////
721 // Initialize the autopilot subsystem.
722 ////////////////////////////////////////////////////////////////////
724 current_autopilot = new FGAutopilot;
725 current_autopilot->init();
727 // initialize the gui parts of the autopilot
734 ////////////////////////////////////////////////////////////////////
735 // Initialize I/O subsystem.
736 ////////////////////////////////////////////////////////////////////
738 #if ! defined( macintosh )
742 // Initialize the 2D panel.
743 string panel_path = fgGetString("/sim/panel/path",
744 "Panels/Default/default.xml");
745 current_panel = fgReadPanel(panel_path);
746 if (current_panel == 0) {
747 SG_LOG( SG_INPUT, SG_ALERT,
748 "Error reading new panel from " << panel_path );
750 SG_LOG( SG_INPUT, SG_INFO, "Loaded new panel from " << panel_path );
751 current_panel->init();
752 current_panel->bind();
756 ////////////////////////////////////////////////////////////////////
757 // Initialize the default (kludged) properties.
758 ////////////////////////////////////////////////////////////////////
763 ////////////////////////////////////////////////////////////////////
764 // Initialize the controls subsystem.
765 ////////////////////////////////////////////////////////////////////
771 ////////////////////////////////////////////////////////////////////
772 // Initialize the input subsystem.
773 ////////////////////////////////////////////////////////////////////
775 current_input.init();
776 current_input.bind();
779 ////////////////////////////////////////////////////////////////////////
780 // End of subsystem initialization.
781 ////////////////////////////////////////////////////////////////////
783 SG_LOG( SG_GENERAL, SG_INFO, endl);
785 // Save the initial state for future
787 globals->saveInitialState();
793 void fgReInitSubsystems( void )
795 SG_LOG( SG_GENERAL, SG_INFO,
796 "/position/altitude = " << fgGetDouble("/position/altitude-ft") );
798 bool freeze = globals->get_freeze();
800 globals->set_freeze( true );
802 // Initialize the Scenery Management subsystem
803 if ( ! fgSceneryInit() ) {
804 SG_LOG( SG_GENERAL, SG_ALERT, "Error in Scenery initialization!" );
808 if( global_tile_mgr.init() ) {
809 // Load the local scenery data
810 global_tile_mgr.update( fgGetDouble("/position/longitude-deg"),
811 fgGetDouble("/position/latitude-deg") );
813 SG_LOG( SG_GENERAL, SG_ALERT, "Error in Tile Manager initialization!" );
817 // Initialize view parameters
818 FGViewerRPH *pilot_view =
819 (FGViewerRPH *)globals->get_viewmgr()->get_view( 0 );
821 pilot_view->set_view_offset( 0.0 );
822 pilot_view->set_goal_view_offset( 0.0 );
824 pilot_view->set_geod_view_pos( cur_fdm_state->get_Longitude(),
825 cur_fdm_state->get_Lat_geocentric(),
826 cur_fdm_state->get_Altitude() *
828 pilot_view->set_sea_level_radius( cur_fdm_state->get_Sea_level_radius() *
830 pilot_view->set_rph( cur_fdm_state->get_Phi(),
831 cur_fdm_state->get_Theta(),
832 cur_fdm_state->get_Psi() );
834 // set current view to 0 (first) which is our main pilot view
835 globals->set_current_view( pilot_view );
837 SG_LOG( SG_GENERAL, SG_DEBUG, " abs_view_pos = "
838 << globals->get_current_view()->get_abs_view_pos());
840 cur_fdm_state->init();
842 controls.reset_all();
843 current_autopilot->reset();
847 cur_light_params.Update();
851 globals->set_freeze( false );