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