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