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