]> git.mxchange.org Git - flightgear.git/blob - src/Main/fg_init.cxx
d2329af9d866dc69d545bd3b8abc220d70a5a9c3
[flightgear.git] / src / Main / fg_init.cxx
1 //
2 // fg_init.cxx -- Flight Gear top level initialization routines
3 //
4 // Written by Curtis Olson, started August 1997.
5 //
6 // Copyright (C) 1997  Curtis L. Olson  - curt@infoplane.com
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 //
22 //
23 // $Id$
24
25
26 #ifdef HAVE_CONFIG_H
27 #  include <config.h>
28 #endif
29
30 // For BC 5.01 this must be included before OpenGL includes.
31 #ifdef FG_MATH_EXCEPTION_CLASH
32 #  include <math.h>
33 #endif
34
35 #include <GL/glut.h>
36 #include <simgear/xgl/xgl.h>
37
38 #include <stdio.h>
39 #include <stdlib.h>
40
41 // work around a stdc++ lib bug in some versions of linux, but doesn't
42 // seem to hurt to have this here for all versions of Linux.
43 #ifdef linux
44 #  define _G_NO_EXTERN_TEMPLATES
45 #endif
46
47 #include <simgear/compiler.h>
48
49 #include STL_STRING
50
51 #include <simgear/constants.h>
52 #include <simgear/debug/logstream.hxx>
53 #include <simgear/math/fg_geodesy.hxx>
54 #include <simgear/math/point3d.hxx>
55 #include <simgear/math/polar3d.hxx>
56 #include <simgear/misc/fgpath.hxx>
57
58 #include <Aircraft/aircraft.hxx>
59 #include <Airports/simple.hxx>
60 #include <Astro/stars.hxx>
61 #include <Astro/solarsystem.hxx>
62 #include <Autopilot/autopilot.hxx>
63 #include <Cockpit/cockpit.hxx>
64 #include <FDM/Balloon.h>
65 #include <FDM/External.hxx>
66 #include <FDM/JSBsim.hxx>
67 #include <FDM/LaRCsim.hxx>
68 #include <FDM/MagicCarpet.hxx>
69 #include <Include/general.hxx>
70 #include <Joystick/joystick.hxx>
71 #include <Scenery/scenery.hxx>
72 #include <Scenery/tilemgr.hxx>
73 #include <Sky/skydome.hxx>
74 #include <Time/event.hxx>
75 #include <Time/fg_time.hxx>
76 #include <Time/light.hxx>
77 #include <Time/sunpos.hxx>
78 #include <Time/moonpos.hxx>
79
80 #ifndef FG_OLD_WEATHER
81 #  include <WeatherCM/FGLocalWeatherDatabase.h>
82 #else
83 #  include <Weather/weather.hxx>
84 #endif
85
86 #include "fg_init.hxx"
87 #include "fg_io.hxx"
88 #include "options.hxx"
89 #include "views.hxx"
90
91 #if defined(FX) && defined(XMESA)
92 #include <GL/xmesa.h>
93 #endif
94
95 FG_USING_STD(string);
96
97 extern const char *default_root;
98
99
100 // Read in configuration (file and command line)
101 bool fgInitConfig ( int argc, char **argv ) {
102     // Attempt to locate and parse a config file
103     // First check fg_root
104     FGPath config( current_options.get_fg_root() );
105     config.append( "system.fgfsrc" );
106     current_options.parse_config_file( config.str() );
107
108     // Next check home directory
109     char* envp = ::getenv( "HOME" );
110     if ( envp != NULL ) {
111         config.set( envp );
112         config.append( ".fgfsrc" );
113         current_options.parse_config_file( config.str() );
114     }
115
116     // Parse remaining command line options
117     // These will override anything specified in a config file
118     if ( current_options.parse_command_line(argc, argv) !=
119          fgOPTIONS::FG_OPTIONS_OK )
120     {
121         // Something must have gone horribly wrong with the command
122         // line parsing or maybe the user just requested help ... :-)
123         current_options.usage();
124         FG_LOG( FG_GENERAL, FG_ALERT, "\nExiting ...");
125         return false;
126     }
127
128    return true;
129 }
130
131
132 // Set initial position and orientation
133 bool fgInitPosition( void ) {
134     string id;
135     FGInterface *f;
136
137     f = current_aircraft.fdm_state;
138
139     id = current_options.get_airport_id();
140     if ( id.length() ) {
141         // set initial position from airport id
142
143         fgAIRPORTS airports;
144         fgAIRPORT a;
145
146         FG_LOG( FG_GENERAL, FG_INFO,
147                 "Attempting to set starting position from airport code "
148                 << id );
149
150         airports.load("apt_simple");
151         if ( ! airports.search( id, &a ) ) {
152             FG_LOG( FG_GENERAL, FG_ALERT,
153                     "Failed to find " << id << " in database." );
154             exit(-1);
155         } else {
156             f->set_Longitude( a.longitude * DEG_TO_RAD );
157             f->set_Latitude( a.latitude * DEG_TO_RAD );
158         }
159     } else {
160         // set initial position from default or command line coordinates
161
162         f->set_Longitude( current_options.get_lon() * DEG_TO_RAD );
163         f->set_Latitude( current_options.get_lat() * DEG_TO_RAD );
164     }
165
166     FG_LOG( FG_GENERAL, FG_INFO,
167             "starting altitude is = " << current_options.get_altitude() );
168
169     f->set_Altitude( current_options.get_altitude() * METER_TO_FEET );
170     fgFDMSetGroundElevation( current_options.get_flight_model(),
171                              (f->get_Altitude() - 3.758099) * FEET_TO_METER );
172
173     FG_LOG( FG_GENERAL, FG_INFO,
174             "Initial position is: ("
175             << (f->get_Longitude() * RAD_TO_DEG) << ", "
176             << (f->get_Latitude() * RAD_TO_DEG) << ", "
177             << (f->get_Altitude() * FEET_TO_METER) << ")" );
178
179     return true;
180 }
181
182
183 // General house keeping initializations
184 bool fgInitGeneral( void ) {
185     string root;
186
187 #if defined(FX) && defined(XMESA)
188     char *mesa_win_state;
189 #endif
190
191     FG_LOG( FG_GENERAL, FG_INFO, "General Initialization" );
192     FG_LOG( FG_GENERAL, FG_INFO, "======= ==============" );
193
194     root = current_options.get_fg_root();
195     if ( ! root.length() ) {
196         // No root path set? Then bail ...
197         FG_LOG( FG_GENERAL, FG_ALERT,
198                 "Cannot continue without environment variable FG_ROOT"
199                 << "being defined." );
200         exit(-1);
201     }
202     FG_LOG( FG_GENERAL, FG_INFO, "FG_ROOT = " << '"' << root << '"' << endl );
203
204 #if defined(FX) && defined(XMESA)
205     // initialize full screen flag
206     global_fullscreen = false;
207     if ( strstr ( general.get_glRenderer(), "Glide" ) ) {
208         // Test for the MESA_GLX_FX env variable
209         if ( (mesa_win_state = getenv( "MESA_GLX_FX" )) != NULL) {
210             // test if we are fullscreen mesa/glide
211             if ( (mesa_win_state[0] == 'f') ||
212                  (mesa_win_state[0] == 'F') ) {
213                 global_fullscreen = true;
214             }
215         }
216     }
217 #endif
218
219     return true;
220 }
221
222
223 // This is the top level init routine which calls all the other
224 // initialization routines.  If you are adding a subsystem to flight
225 // gear, its initialization call should located in this routine.
226 // Returns non-zero if a problem encountered.
227 bool fgInitSubsystems( void ) {
228     FGTime::cur_time_params = new FGTime();
229
230     fgLIGHT *l = &cur_light_params;
231     FGTime *t = FGTime::cur_time_params;
232
233     FG_LOG( FG_GENERAL, FG_INFO, "Initialize Subsystems");
234     FG_LOG( FG_GENERAL, FG_INFO, "========== ==========");
235
236     if ( current_options.get_flight_model() == FGInterface::FG_LARCSIM ) {
237         cur_fdm_state = new FGLaRCsim;
238     } else if ( current_options.get_flight_model() == FGInterface::FG_JSBSIM ) {
239         cur_fdm_state = new FGJSBsim;
240     } else if ( current_options.get_flight_model() == 
241                 FGInterface::FG_BALLOONSIM ) {
242         cur_fdm_state = new FGBalloonSim;
243     } else if ( current_options.get_flight_model() == 
244                 FGInterface::FG_MAGICCARPET ) {
245         cur_fdm_state = new FGMagicCarpet;
246     } else if ( current_options.get_flight_model() == 
247                 FGInterface::FG_EXTERNAL ) {
248         cur_fdm_state = new FGExternal;
249     } else {
250         FG_LOG( FG_GENERAL, FG_ALERT,
251                 "No flight model, can't init aircraft" );
252         exit(-1);
253     }
254
255     // allocates structures so must happen before any of the flight
256     // model or control parameters are set
257     fgAircraftInit();   // In the future this might not be the case.
258
259     // set the initial position
260     fgInitPosition();
261
262     // Initialize the Scenery Management subsystem
263     if ( fgSceneryInit() ) {
264         // Scenery initialized ok.
265     } else {
266         FG_LOG( FG_GENERAL, FG_ALERT, "Error in Scenery initialization!" );
267         exit(-1);
268     }
269
270     if( global_tile_mgr.init() ) {
271         // Load the local scenery data
272         global_tile_mgr.update();
273     } else {
274         FG_LOG( FG_GENERAL, FG_ALERT, "Error in Tile Manager initialization!" );
275         exit(-1);
276     }
277
278     FG_LOG( FG_GENERAL, FG_DEBUG,
279             "Current terrain elevation after tile mgr init " <<
280             scenery.cur_elev );
281
282     // Calculate ground elevation at starting point (we didn't have
283     // tmp_abs_view_pos calculated when fgTileMgrUpdate() was called above
284     //
285     // calculalate a cartesian point somewhere along the line between
286     // the center of the earth and our view position.  Doesn't have to
287     // be the exact elevation (this is good because we don't know it
288     // yet :-)
289
290     // now handled inside of the fgTileMgrUpdate()
291
292     /*
293     geod_pos = Point3D( cur_fdm_state->get_Longitude(), cur_fdm_state->get_Latitude(), 0.0);
294     tmp_abs_view_pos = fgGeodToCart(geod_pos);
295
296     FG_LOG( FG_GENERAL, FG_DEBUG,
297             "Initial abs_view_pos = " << tmp_abs_view_pos );
298     scenery.cur_elev =
299         fgTileMgrCurElev( cur_fdm_state->get_Longitude(), cur_fdm_state->get_Latitude(),
300                           tmp_abs_view_pos );
301     FG_LOG( FG_GENERAL, FG_DEBUG,
302             "Altitude after update " << scenery.cur_elev );
303     */
304
305     fgFDMSetGroundElevation( current_options.get_flight_model(),
306                              scenery.cur_elev );
307
308     // Reset our altitude if we are below ground
309     FG_LOG( FG_GENERAL, FG_DEBUG, "Current altitude = " << cur_fdm_state->get_Altitude() );
310     FG_LOG( FG_GENERAL, FG_DEBUG, "Current runway altitude = " <<
311             cur_fdm_state->get_Runway_altitude() );
312
313     if ( cur_fdm_state->get_Altitude() < cur_fdm_state->get_Runway_altitude() + 3.758099) {
314         cur_fdm_state->set_Altitude( cur_fdm_state->get_Runway_altitude() + 3.758099 );
315     }
316
317     FG_LOG( FG_GENERAL, FG_INFO,
318             "Updated position (after elevation adj): ("
319             << (cur_fdm_state->get_Latitude() * RAD_TO_DEG) << ", "
320             << (cur_fdm_state->get_Longitude() * RAD_TO_DEG) << ", "
321             << (cur_fdm_state->get_Altitude() * FEET_TO_METER) << ")" );
322
323     // We need to calculate a few more values here that would normally
324     // be calculated by the FDM so that the current_view.UpdateViewMath()
325     // routine doesn't get hosed.
326
327     double sea_level_radius_meters;
328     double lat_geoc;
329     // Set the FG variables first
330     fgGeodToGeoc( cur_fdm_state->get_Latitude(), cur_fdm_state->get_Altitude(),
331                   &sea_level_radius_meters, &lat_geoc);
332     cur_fdm_state->set_Geocentric_Position( lat_geoc, cur_fdm_state->get_Longitude(),
333                                 cur_fdm_state->get_Altitude() +
334                                 (sea_level_radius_meters * METER_TO_FEET) );
335     cur_fdm_state->set_Sea_level_radius( sea_level_radius_meters * METER_TO_FEET );
336
337     cur_fdm_state->set_sin_cos_longitude(cur_fdm_state->get_Longitude());
338     cur_fdm_state->set_sin_cos_latitude(cur_fdm_state->get_Latitude());
339         
340     cur_fdm_state->set_sin_lat_geocentric(sin(lat_geoc));
341     cur_fdm_state->set_cos_lat_geocentric(cos(lat_geoc));
342
343     // The following section sets up the flight model EOM parameters
344     // and should really be read in from one or more files.
345
346     // Initial Velocity
347     cur_fdm_state->set_Velocities_Local( current_options.get_uBody(),
348                              current_options.get_vBody(),
349                              current_options.get_wBody());
350
351     // Initial Orientation
352     cur_fdm_state->set_Euler_Angles( current_options.get_roll() * DEG_TO_RAD,
353                          current_options.get_pitch() * DEG_TO_RAD,
354                          current_options.get_heading() * DEG_TO_RAD );
355
356     // Initial Angular Body rates
357     cur_fdm_state->set_Omega_Body( 7.206685E-05, 0.0, 9.492658E-05 );
358
359     cur_fdm_state->set_Earth_position_angle( 0.0 );
360
361     // Mass properties and geometry values
362     cur_fdm_state->set_Inertias( 8.547270E+01,
363                      1.048000E+03, 3.000000E+03, 3.530000E+03, 0.000000E+00 );
364
365     // CG position w.r.t. ref. point
366     cur_fdm_state->set_CG_Position( 0.0, 0.0, 0.0 );
367
368     // Initialize the event manager
369     global_events.Init();
370
371     // Output event stats every 60 seconds
372     global_events.Register( "fgEVENT_MGR::PrintStats()",
373                             fgMethodCallback<fgEVENT_MGR>( &global_events,
374                                                    &fgEVENT_MGR::PrintStats),
375                             fgEVENT::FG_EVENT_READY, 60000 );
376
377     // Initialize the time dependent variables
378     t->init(*cur_fdm_state);
379     t->update(*cur_fdm_state);
380
381     // Initialize view parameters
382     FG_LOG( FG_GENERAL, FG_DEBUG, "Before current_view.init()");
383     current_view.Init();
384     pilot_view.Init();
385     FG_LOG( FG_GENERAL, FG_DEBUG, "After current_view.init()");
386     current_view.UpdateViewMath(*cur_fdm_state);
387     pilot_view.UpdateViewMath(*cur_fdm_state);
388     FG_LOG( FG_GENERAL, FG_DEBUG, "  abs_view_pos = " << current_view.get_abs_view_pos());
389     // current_view.UpdateWorldToEye(f);
390
391     // Build the solar system
392     //fgSolarSystemInit(*t);
393     FG_LOG(FG_GENERAL, FG_INFO, "Building SolarSystem");
394     SolarSystem::theSolarSystem = new SolarSystem(t);
395
396     // Initialize the Stars subsystem
397     if( fgStarsInit() ) {
398         // Stars initialized ok.
399     } else {
400         FG_LOG( FG_GENERAL, FG_ALERT, "Error in Stars initialization!" );
401         exit(-1);
402     }
403
404     // Initialize the planetary subsystem
405     // global_events.Register( "fgPlanetsInit()", fgPlanetsInit,
406     //                      fgEVENT::FG_EVENT_READY, 600000);
407
408     // Initialize the sun's position
409     // global_events.Register( "fgSunInit()", fgSunInit,
410     //                      fgEVENT::FG_EVENT_READY, 30000 );
411
412     // Intialize the moon's position
413     // global_events.Register( "fgMoonInit()", fgMoonInit,
414     //                      fgEVENT::FG_EVENT_READY, 600000 );
415
416     // register the periodic update of Sun, moon, and planets
417     global_events.Register( "ssolsysUpdate", solarSystemRebuild,
418                             fgEVENT::FG_EVENT_READY, 600000);
419
420     // fgUpdateSunPos() needs a few position and view parameters set
421     // so it can calculate local relative sun angle and a few other
422     // things for correctly orienting the sky.
423     fgUpdateSunPos();
424     fgUpdateMoonPos();
425     global_events.Register( "fgUpdateSunPos()", fgUpdateSunPos,
426                             fgEVENT::FG_EVENT_READY, 60000);
427     global_events.Register( "fgUpdateMoonPos()", fgUpdateMoonPos,
428                             fgEVENT::FG_EVENT_READY, 60000);
429
430     // Initialize Lighting interpolation tables
431     l->Init();
432
433     // update the lighting parameters (based on sun angle)
434     global_events.Register( "fgLight::Update()",
435                             fgMethodCallback<fgLIGHT>( &cur_light_params,
436                                                        &fgLIGHT::Update),
437                             fgEVENT::FG_EVENT_READY, 30000 );
438     // update the current timezone each 30 minutes
439     global_events.Register( "fgTIME::updateLocal()",
440                             fgMethodCallback<FGTime>(FGTime::cur_time_params, 
441                                                      &FGTime::updateLocal),
442                             fgEVENT::FG_EVENT_READY, 1800000);
443
444     // Initialize the weather modeling subsystem
445 #ifndef FG_OLD_WEATHER
446     // Initialize the WeatherDatabase
447     FG_LOG(FG_GENERAL, FG_INFO, "Creating LocalWeatherDatabase");
448     sgVec3 position;
449     sgSetVec3( position, current_aircraft.fdm_state->get_Latitude(),
450                current_aircraft.fdm_state->get_Longitude(),
451                current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER );
452     FGLocalWeatherDatabase::theFGLocalWeatherDatabase = 
453         new FGLocalWeatherDatabase( position );
454     // cout << theFGLocalWeatherDatabase << endl;
455     // cout << "visibility = " 
456     //      << theFGLocalWeatherDatabase->getWeatherVisibility() << endl;
457
458     WeatherDatabase = FGLocalWeatherDatabase::theFGLocalWeatherDatabase;
459      
460     // register the periodic update of the weather
461     global_events.Register( "weather update", fgUpdateWeatherDatabase,
462                             fgEVENT::FG_EVENT_READY, 30000);
463 #else
464     current_weather.Init();
465 #endif
466
467     // Initialize the Cockpit subsystem
468     if( fgCockpitInit( &current_aircraft )) {
469         // Cockpit initialized ok.
470     } else {
471         FG_LOG( FG_GENERAL, FG_ALERT, "Error in Cockpit initialization!" );
472         exit(-1);
473     }
474
475     // Initialize the flight model subsystem data structures base on
476     // above values
477
478     // fgFDMInit( current_options.get_flight_model(), cur_fdm_state,
479     //            1.0 / current_options.get_model_hz() );
480     cur_fdm_state->init( 1.0 / current_options.get_model_hz() );
481
482     // I'm just sticking this here for now, it should probably move
483     // eventually
484     scenery.cur_elev = cur_fdm_state->get_Runway_altitude() * FEET_TO_METER;
485
486     if ( cur_fdm_state->get_Altitude() < cur_fdm_state->get_Runway_altitude() + 3.758099) {
487         cur_fdm_state->set_Altitude( cur_fdm_state->get_Runway_altitude() + 3.758099 );
488     }
489
490     FG_LOG( FG_GENERAL, FG_INFO,
491             "Updated position (after elevation adj): ("
492             << (cur_fdm_state->get_Latitude() * RAD_TO_DEG) << ", "
493             << (cur_fdm_state->get_Longitude() * RAD_TO_DEG) << ", "
494             << (cur_fdm_state->get_Altitude() * FEET_TO_METER) << ")" );
495     // end of thing that I just stuck in that I should probably move
496
497     // Joystick support
498     if ( fgJoystickInit() ) {
499         // Joystick initialized ok.
500     } else {
501         FG_LOG( FG_GENERAL, FG_ALERT, "Error in Joystick initialization!" );
502     }
503
504     // Autopilot init added here, by Jeff Goeke-Smith
505     fgAPInit(&current_aircraft);
506
507     // Initialize I/O channels
508 #if ! defined( MACOS )
509     fgIOInit();
510 #endif
511
512     FG_LOG( FG_GENERAL, FG_INFO, endl);
513
514     return true;
515 }
516
517
518 void fgReInitSubsystems( void )
519 {
520     FGTime *t = FGTime::cur_time_params;
521     
522     int toggle_pause = t->getPause();
523     
524     if( !toggle_pause )
525         t->togglePauseMode();
526     
527     fgInitPosition();
528     if( global_tile_mgr.init() ) {
529         // Load the local scenery data
530         global_tile_mgr.update();
531     } else {
532         FG_LOG( FG_GENERAL, FG_ALERT, "Error in Tile Manager initialization!" );
533                 exit(-1);
534     }
535     fgFDMSetGroundElevation( current_options.get_flight_model(), 
536                              scenery.cur_elev );
537
538     // Reset our altitude if we are below ground
539     FG_LOG( FG_GENERAL, FG_DEBUG, "Current altitude = " << cur_fdm_state->get_Altitude() );
540     FG_LOG( FG_GENERAL, FG_DEBUG, "Current runway altitude = " << 
541             cur_fdm_state->get_Runway_altitude() );
542
543     if ( cur_fdm_state->get_Altitude() < cur_fdm_state->get_Runway_altitude() + 3.758099) {
544         cur_fdm_state->set_Altitude( cur_fdm_state->get_Runway_altitude() + 3.758099 );
545     }
546     double sea_level_radius_meters;
547     double lat_geoc;
548     // Set the FG variables first
549     fgGeodToGeoc( cur_fdm_state->get_Latitude(), cur_fdm_state->get_Altitude(), 
550                   &sea_level_radius_meters, &lat_geoc);
551     cur_fdm_state->set_Geocentric_Position( lat_geoc, cur_fdm_state->get_Longitude(), 
552                                 cur_fdm_state->get_Altitude() + 
553                                 (sea_level_radius_meters * METER_TO_FEET) );
554     cur_fdm_state->set_Sea_level_radius( sea_level_radius_meters * METER_TO_FEET );
555         
556     cur_fdm_state->set_sin_cos_longitude(cur_fdm_state->get_Longitude());
557     cur_fdm_state->set_sin_cos_latitude(cur_fdm_state->get_Latitude());
558         
559     cur_fdm_state->set_sin_lat_geocentric(sin(lat_geoc));
560     cur_fdm_state->set_cos_lat_geocentric(cos(lat_geoc));
561
562     // The following section sets up the flight model EOM parameters
563     // and should really be read in from one or more files.
564
565     // Initial Velocity
566     cur_fdm_state->set_Velocities_Local( current_options.get_uBody(),
567                              current_options.get_vBody(),
568                              current_options.get_wBody());
569
570     // Initial Orientation
571     cur_fdm_state->set_Euler_Angles( current_options.get_roll() * DEG_TO_RAD,
572                          current_options.get_pitch() * DEG_TO_RAD,
573                          current_options.get_heading() * DEG_TO_RAD );
574
575     // Initial Angular Body rates
576     cur_fdm_state->set_Omega_Body( 7.206685E-05, 0.0, 9.492658E-05 );
577
578     cur_fdm_state->set_Earth_position_angle( 0.0 );
579
580     // Mass properties and geometry values
581     cur_fdm_state->set_Inertias( 8.547270E+01, 
582                      1.048000E+03, 3.000000E+03, 3.530000E+03, 0.000000E+00 );
583
584     // CG position w.r.t. ref. point
585     cur_fdm_state->set_CG_Position( 0.0, 0.0, 0.0 );
586
587     // Initialize view parameters
588     current_view.set_view_offset( 0.0 );
589     current_view.set_goal_view_offset( 0.0 );
590     pilot_view.set_view_offset( 0.0 );
591     pilot_view.set_goal_view_offset( 0.0 );
592
593     FG_LOG( FG_GENERAL, FG_DEBUG, "After current_view.init()");
594     current_view.UpdateViewMath(*cur_fdm_state);
595     pilot_view.UpdateViewMath(*cur_fdm_state);
596     FG_LOG( FG_GENERAL, FG_DEBUG, "  abs_view_pos = " << current_view.get_abs_view_pos());
597
598     // fgFDMInit( current_options.get_flight_model(), cur_fdm_state, 
599     //            1.0 / current_options.get_model_hz() );
600     cur_fdm_state->init( 1.0 / current_options.get_model_hz() );
601
602     scenery.cur_elev = cur_fdm_state->get_Runway_altitude() * FEET_TO_METER;
603
604     if ( cur_fdm_state->get_Altitude() < cur_fdm_state->get_Runway_altitude() + 3.758099) {
605         cur_fdm_state->set_Altitude( cur_fdm_state->get_Runway_altitude() + 3.758099 );
606     }
607
608     controls.reset_all();
609     fgAPReset();
610
611     if( !toggle_pause )
612         t->togglePauseMode();
613 }