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