]> git.mxchange.org Git - flightgear.git/blob - Main/fg_init.cxx
Fixed a problem with the initial starting altitude. "v->abs_view_pos" wasn't
[flightgear.git] / 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 // (Log is kept at end of this file)
25
26
27 #ifdef HAVE_CONFIG_H
28 #  include <config.h>
29 #endif
30
31 #include <stdio.h>
32 #include <stdlib.h>
33
34 // work around a stdc++ lib bug in some versions of linux, but doesn't
35 // seem to hurt to have this here for all versions of Linux.
36 #ifdef linux
37 #  define _G_NO_EXTERN_TEMPLATES
38 #endif
39
40 #include <string>
41
42 #include <Include/fg_constants.h>
43 #include <Include/general.h>
44
45 #include <Aircraft/aircraft.hxx>
46 #include <Airports/simple.hxx>
47 #include <Astro/sky.hxx>
48 #include <Astro/stars.hxx>
49 #include <Astro/solarsystem.hxx>
50 #include <Autopilot/autopilot.hxx>
51 #include <Cockpit/cockpit.hxx>
52 // #include <Debug/fg_debug.h>
53 #include <Debug/logstream.hxx>
54 #include <Joystick/joystick.hxx>
55 #include <Math/fg_geodesy.hxx>
56 #include <Math/fg_random.h>
57 #include <Math/point3d.hxx>
58 #include <Math/polar3d.hxx>
59 #include <Scenery/scenery.hxx>
60 #include <Scenery/tilemgr.hxx>
61 #include <Time/event.hxx>
62 #include <Time/fg_time.hxx>
63 #include <Time/light.hxx>
64 #include <Time/sunpos.hxx>
65 #include <Weather/weather.hxx>
66
67 #include "fg_init.hxx"
68 #include "options.hxx"
69 #include "views.hxx"
70
71
72 extern const char *default_root;
73
74
75 // Set initial position and orientation
76 int fgInitPosition( void ) {
77     string id;
78     FGState *f;
79
80     f = current_aircraft.fdm_state;
81
82     id = current_options.get_airport_id();
83     if ( id.length() ) {
84         // set initial position from airport id
85
86         fgAIRPORTS airports;
87         fgAIRPORT a;
88
89         FG_LOG( FG_GENERAL, FG_INFO, 
90                 "Attempting to set starting position from airport code "
91                 << id );
92
93         airports.load("apt_simple");
94         if ( ! airports.search( id, &a ) ) {
95             FG_LOG( FG_GENERAL, FG_ALERT, 
96                     "Failed to find " << id << " in database." );
97             exit(-1);
98         } else {
99             f->set_Longitude( a.longitude * DEG_TO_RAD );
100             f->set_Latitude( a.latitude * DEG_TO_RAD );
101         }
102     } else {
103         // set initial position from default or command line coordinates
104
105         f->set_Longitude( current_options.get_lon() * DEG_TO_RAD );
106         f->set_Latitude( current_options.get_lat() * DEG_TO_RAD );
107     }
108     FG_LOG( FG_GENERAL, FG_INFO, 
109             "starting altitude is = " << current_options.get_altitude() );
110
111     f->set_Altitude( current_options.get_altitude() * METER_TO_FEET );
112     f->set_Runway_altitude( f->get_Altitude() - 3.758099 );
113
114     FG_LOG( FG_GENERAL, FG_INFO,
115             "Initial position is: ("
116             << (f->get_Longitude() * RAD_TO_DEG) << ", " 
117             << (f->get_Latitude() * RAD_TO_DEG) << ", " 
118             << (f->get_Altitude() * FEET_TO_METER) << ")" );
119
120     return(1);
121 }
122
123
124 // General house keeping initializations
125 int fgInitGeneral( void ) {
126     string root;
127     int i;
128
129     FG_LOG( FG_GENERAL, FG_INFO, "General Initialization" );
130     FG_LOG( FG_GENERAL, FG_INFO, "======= ==============" );
131
132     root = current_options.get_fg_root();
133     if ( ! root.length() ) {
134         // No root path set? Then bail ...
135         FG_LOG( FG_GENERAL, FG_ALERT, 
136                 "Cannot continue without environment variable FG_ROOT"
137                 << "being defined." );
138         exit(-1);
139     }
140     FG_LOG( FG_GENERAL, FG_INFO, "FG_ROOT = " << root << endl );
141
142     // prime the frame rate counter pump
143     for ( i = 0; i < FG_FRAME_RATE_HISTORY; i++ ) {
144         general.frames[i] = 0.0;
145     }
146
147     return ( 1 ); 
148 }
149
150
151 // This is the top level init routine which calls all the other
152 // initialization routines.  If you are adding a subsystem to flight
153 // gear, its initialization call should located in this routine.
154 // Returns non-zero if a problem encountered.
155 int fgInitSubsystems( void )
156 {
157     FGState *f;
158     fgLIGHT *l;
159     fgTIME *t;
160     fgVIEW *v;
161     Point3D geod_pos, tmp_abs_view_pos;
162
163     l = &cur_light_params;
164     t = &cur_time_params;
165     v = &current_view;
166
167     FG_LOG( FG_GENERAL, FG_INFO, "Initialize Subsystems");
168     FG_LOG( FG_GENERAL, FG_INFO, "========== ==========");
169
170     // seed the random number generater
171     fg_srandom();
172
173     // allocates structures so must happen before any of the flight
174     // model or control parameters are set
175     fgAircraftInit();   // In the future this might not be the case.
176     f = current_aircraft.fdm_state;
177
178     // set the initial position
179     fgInitPosition();
180
181     // Initialize the Scenery Management subsystem
182     if ( fgSceneryInit() ) {
183         // Scenery initialized ok.
184     } else {
185         FG_LOG( FG_GENERAL, FG_ALERT, "Error in Scenery initialization!" );
186         exit(-1);
187     }
188
189     if( fgTileMgrInit() ) {
190         // Load the local scenery data
191         fgTileMgrUpdate();
192     } else {
193         FG_LOG( FG_GENERAL, FG_ALERT, "Error in Tile Manager initialization!" );
194         exit(-1);
195     }
196
197     // Calculate ground elevation at starting point (we didn't have
198     // tmp_abs_view_pos calculated when fgTileMgrUpdate() was called above
199
200     // calculalate a cartesian point somewhere along the line between
201     // the center of the earth and our view position.  Doesn't have to
202     // be the exact elevation (this is good because we don't know it
203     // yet :-)
204     geod_pos = Point3D( f->get_Longitude(), f->get_Latitude(), 0.0);
205     tmp_abs_view_pos = fgGeodToCart(geod_pos);
206
207     FG_LOG( FG_GENERAL, FG_DEBUG, 
208             "Altitude before update " << scenery.cur_elev );
209     FG_LOG( FG_GENERAL, FG_DEBUG, 
210             "Initial abs_view_pos = " << tmp_abs_view_pos );
211     scenery.cur_elev = 
212         fgTileMgrCurElevOLD( f->get_Longitude(), 
213                              f->get_Latitude(),
214                              tmp_abs_view_pos );
215     FG_LOG( FG_GENERAL, FG_DEBUG, 
216             "Altitude after update " << scenery.cur_elev );
217     f->set_Runway_altitude( scenery.cur_elev * METER_TO_FEET );
218
219     // Reset our altitude if we are below ground
220     if ( f->get_Altitude() < f->get_Runway_altitude() + 3.758099) {
221         f->set_Altitude( f->get_Runway_altitude() + 3.758099 );
222     }
223
224     FG_LOG( FG_GENERAL, FG_INFO,
225             "Updated position (after elevation adj): ("
226             << (f->get_Latitude() * RAD_TO_DEG) << ", " 
227             << (f->get_Longitude() * RAD_TO_DEG) << ", " 
228             << (f->get_Altitude() * FEET_TO_METER) << ")" );
229
230     // We need to calculate a few more values here that would normally
231     // be calculated by the FDM so that the v->UpdateViewMath()
232     // routine doesn't get hosed.
233
234     double sea_level_radius_meters;
235     double lat_geoc;
236     // Set the FG variables first
237     fgGeodToGeoc( f->get_Latitude(), f->get_Altitude(), 
238                   &sea_level_radius_meters, &lat_geoc);
239     f->set_Geocentric_Position( lat_geoc, f->get_Longitude(), 
240                                 f->get_Altitude() + 
241                                 (sea_level_radius_meters * METER_TO_FEET) );
242     f->set_Sea_level_radius( sea_level_radius_meters * METER_TO_FEET );
243
244     // The following section sets up the flight model EOM parameters
245     // and should really be read in from one or more files.
246
247     // Initial Velocity
248     f->set_Velocities_Local( 0.0, 0.0, 0.0 );
249
250     // Initial Orientation
251     f->set_Euler_Angles( current_options.get_roll() * DEG_TO_RAD,
252                          current_options.get_pitch() * DEG_TO_RAD,
253                          current_options.get_heading() * DEG_TO_RAD );
254
255     // Initial Angular Body rates
256     f->set_Omega_Body( 7.206685E-05, 0.0, 9.492658E-05 );
257
258     f->set_Earth_position_angle( 0.0 );
259
260     // Mass properties and geometry values
261     f->set_Inertias( 8.547270E+01, 
262                      1.048000E+03, 3.000000E+03, 3.530000E+03, 0.000000E+00 );
263
264     // CG position w.r.t. ref. point
265     f->set_CG_Position( 0.0, 0.0, 0.0 );
266
267     // Initialize the event manager
268     global_events.Init();
269
270     // Output event stats every 60 seconds
271     global_events.Register( "fgEVENT_MGR::PrintStats()",
272                             fgMethodCallback<fgEVENT_MGR>( &global_events,
273                                                    &fgEVENT_MGR::PrintStats),
274                             fgEVENT::FG_EVENT_READY, 60000 );
275
276     // Initialize the time dependent variables
277     fgTimeInit(t);
278     fgTimeUpdate(f, t);
279
280     // Initialize view parameters
281     FG_LOG( FG_GENERAL, FG_DEBUG, "Before v->init()");
282     v->Init();
283     FG_LOG( FG_GENERAL, FG_DEBUG, "After v->init()");
284     v->UpdateViewMath(f);
285     FG_LOG( FG_GENERAL, FG_DEBUG, "  abs_view_pos = " << v->abs_view_pos );
286     v->UpdateWorldToEye(f);
287
288     // Build the solar system
289     //fgSolarSystemInit(*t);
290     FG_LOG(FG_GENERAL, FG_INFO, "Building SolarSystem");
291     SolarSystem::theSolarSystem = new SolarSystem(t);
292
293     // Initialize the Stars subsystem
294     if( fgStarsInit() ) {
295         // Stars initialized ok.
296     } else {
297         FG_LOG( FG_GENERAL, FG_ALERT, "Error in Stars initialization!" );
298         exit(-1);
299     }
300
301     // Initialize the planetary subsystem
302     // global_events.Register( "fgPlanetsInit()", fgPlanetsInit, 
303     //                      fgEVENT::FG_EVENT_READY, 600000);
304
305     // Initialize the sun's position 
306     // global_events.Register( "fgSunInit()", fgSunInit, 
307     //                      fgEVENT::FG_EVENT_READY, 30000 );
308
309     // Intialize the moon's position
310     // global_events.Register( "fgMoonInit()", fgMoonInit, 
311     //                      fgEVENT::FG_EVENT_READY, 600000 );
312
313     // register the periodic update of Sun, moon, and planets
314     global_events.Register( "ssolsysUpdate", solarSystemRebuild,
315                             fgEVENT::FG_EVENT_READY, 600000);
316     
317     // fgUpdateSunPos() needs a few position and view parameters set
318     // so it can calculate local relative sun angle and a few other
319     // things for correctly orienting the sky.
320     fgUpdateSunPos();
321     global_events.Register( "fgUpdateSunPos()", fgUpdateSunPos,
322                             fgEVENT::FG_EVENT_READY, 60000);
323
324     // Initialize Lighting interpolation tables
325     l->Init();
326
327     // update the lighting parameters (based on sun angle)
328     global_events.Register( "fgLight::Update()",
329                             fgMethodCallback<fgLIGHT>( &cur_light_params,
330                                                        &fgLIGHT::Update),
331                             fgEVENT::FG_EVENT_READY, 30000 );
332
333     // Initialize the weather modeling subsystem
334     current_weather.Init();
335
336     // Initialize the Cockpit subsystem
337     if( fgCockpitInit( &current_aircraft )) {
338         // Cockpit initialized ok.
339     } else {
340         FG_LOG( FG_GENERAL, FG_ALERT, "Error in Cockpit initialization!" );
341         exit(-1);
342     }
343
344     // Initialize the "sky"
345     fgSkyInit();
346
347     // Initialize the flight model subsystem data structures base on
348     // above values
349
350     fgFlightModelInit( current_options.get_flight_model(), cur_fdm_state, 
351                        1.0 / DEFAULT_MODEL_HZ );
352
353     // I'm just sticking this here for now, it should probably move
354     // eventually
355     scenery.cur_elev = f->get_Runway_altitude() * FEET_TO_METER;
356
357     if ( f->get_Altitude() < f->get_Runway_altitude() + 3.758099) {
358         f->set_Altitude( f->get_Runway_altitude() + 3.758099 );
359     }
360
361     FG_LOG( FG_GENERAL, FG_INFO,
362             "Updated position (after elevation adj): ("
363             << (f->get_Latitude() * RAD_TO_DEG) << ", " 
364             << (f->get_Longitude() * RAD_TO_DEG) << ", "
365             << (f->get_Altitude() * FEET_TO_METER) << ")" );
366     // end of thing that I just stuck in that I should probably move
367
368     // Joystick support
369     if ( fgJoystickInit() ) {
370         // Joystick initialized ok.
371     } else {
372         FG_LOG( FG_GENERAL, FG_ALERT, "Error in Joystick initialization!" );
373     }
374
375     // Autopilot init added here, by Jeff Goeke-Smith
376     fgAPInit(&current_aircraft);
377
378     // Initialize serial ports
379     fgSerialInit();
380
381     FG_LOG( FG_GENERAL, FG_INFO, endl);
382
383     return(1);
384 }
385
386
387 // $Log$
388 // Revision 1.57  1998/12/06 14:52:56  curt
389 // Fixed a problem with the initial starting altitude.  "v->abs_view_pos" wasn't
390 // being calculated correctly at the beginning causing the first terrain
391 // intersection to fail, returning a ground altitude of zero, causing the plane
392 // to free fall for one frame, until the ground altitude was corrected, but now
393 // being under the ground we got a big bounce and the plane always ended up
394 // upside down.
395 //
396 // Revision 1.56  1998/12/06 13:51:23  curt
397 // Turned "struct fgWEATHER" into "class FGWeather".
398 //
399 // Revision 1.55  1998/12/05 15:54:20  curt
400 // Renamed class fgFLIGHT to class FGState as per request by JSB.
401 //
402 // Revision 1.54  1998/12/05 14:19:53  curt
403 // Looking into a problem with cur_view_params.abs_view_pos initialization.
404 //
405 // Revision 1.53  1998/12/03 04:25:05  curt
406 // Working on fixing up new fgFLIGHT class.
407 //
408 // Revision 1.52  1998/12/03 01:17:17  curt
409 // Converted fgFLIGHT to a class.
410 //
411 // Revision 1.51  1998/11/20 01:02:37  curt
412 // Try to detect Mesa/Glide/Voodoo and chose the appropriate resolution.
413 //
414 // Revision 1.50  1998/11/16 14:00:01  curt
415 // Added pow() macro bug work around.
416 // Added support for starting FGFS at various resolutions.
417 // Added some initial serial port support.
418 // Specify default log levels in main().
419 //
420 // Revision 1.49  1998/11/11 00:24:02  curt
421 // Added Michael Johnson's audio patches for testing.
422 // Also did a few tweaks to avoid numerical problems when starting at a place
423 // with no (or bogus) scenery.
424 //
425 // Revision 1.48  1998/11/07 19:07:10  curt
426 // Enable release builds using the --without-logging option to the configure
427 // script.  Also a couple log message cleanups, plus some C to C++ comment
428 // conversion.
429 //
430 // Revision 1.47  1998/11/06 21:18:10  curt
431 // Converted to new logstream debugging facility.  This allows release
432 // builds with no messages at all (and no performance impact) by using
433 // the -DFG_NDEBUG flag.
434 //
435 // Revision 1.46  1998/10/27 02:14:38  curt
436 // Changes to support GLUT joystick routines as fall back.
437 //
438 // Revision 1.45  1998/10/25 10:57:21  curt
439 // Changes to use the new joystick library if it is available.
440 //
441 // Revision 1.44  1998/10/18 01:17:17  curt
442 // Point3D tweaks.
443 //
444 // Revision 1.43  1998/10/17 01:34:22  curt
445 // C++ ifying ...
446 //
447 // Revision 1.42  1998/10/16 23:27:54  curt
448 // C++-ifying.
449 //
450 // Revision 1.41  1998/10/16 00:54:01  curt
451 // Converted to Point3D class.
452 //
453 // Revision 1.40  1998/10/02 12:46:49  curt
454 // Added an "auto throttle"
455 //
456 // Revision 1.39  1998/09/29 02:03:39  curt
457 // Autopilot mods.
458 //
459 // Revision 1.38  1998/09/15 04:27:30  curt
460 // Changes for new Astro code.
461 //
462 // Revision 1.37  1998/09/15 02:09:26  curt
463 // Include/fg_callback.hxx
464 //   Moved code inline to stop g++ 2.7 from complaining.
465 //
466 // Simulator/Time/event.[ch]xx
467 //   Changed return type of fgEVENT::printStat().  void caused g++ 2.7 to
468 //   complain bitterly.
469 //
470 // Minor bugfix and changes.
471 //
472 // Simulator/Main/GLUTmain.cxx
473 //   Added missing type to idle_state definition - eliminates a warning.
474 //
475 // Simulator/Main/fg_init.cxx
476 //   Changes to airport lookup.
477 //
478 // Simulator/Main/options.cxx
479 //   Uses fg_gzifstream when loading config file.
480 //
481 // Revision 1.36  1998/09/08 21:40:08  curt
482 // Fixes by Charlie Hotchkiss.
483 //
484 // Revision 1.35  1998/08/29 13:09:26  curt
485 // Changes to event manager from Bernie Bright.
486 //
487 // Revision 1.34  1998/08/27 17:02:06  curt
488 // Contributions from Bernie Bright <bbright@c031.aone.net.au>
489 // - use strings for fg_root and airport_id and added methods to return
490 //   them as strings,
491 // - inlined all access methods,
492 // - made the parsing functions private methods,
493 // - deleted some unused functions.
494 // - propogated some of these changes out a bit further.
495 //
496 // Revision 1.33  1998/08/25 20:53:32  curt
497 // Shuffled $FG_ROOT file layout.
498 //
499 // Revision 1.32  1998/08/25 16:59:09  curt
500 // Directory reshuffling.
501 //
502 // Revision 1.31  1998/08/22  14:49:57  curt
503 // Attempting to iron out seg faults and crashes.
504 // Did some shuffling to fix a initialization order problem between view
505 // position, scenery elevation.
506 //
507 // Revision 1.30  1998/08/20 20:32:33  curt
508 // Reshuffled some of the code in and around views.[ch]xx
509 //
510 // Revision 1.29  1998/07/30 23:48:27  curt
511 // Output position & orientation when pausing.
512 // Eliminated libtool use.
513 // Added options to specify initial position and orientation.
514 // Changed default fov to 55 degrees.
515 // Added command line option to start in paused or unpaused state.
516 //
517 // Revision 1.28  1998/07/27 18:41:25  curt
518 // Added a pause command "p"
519 // Fixed some initialization order problems between pui and glut.
520 // Added an --enable/disable-sound option.
521 //
522 // Revision 1.27  1998/07/24 21:39:10  curt
523 // Debugging output tweaks.
524 // Cast glGetString to (char *) to avoid compiler errors.
525 // Optimizations to fgGluLookAt() by Norman Vine.
526 //
527 // Revision 1.26  1998/07/22 21:40:44  curt
528 // Clear to adjusted fog color (for sunrise/sunset effects)
529 // Make call to fog sunrise/sunset adjustment method.
530 // Add a stdc++ library bug work around to fg_init.cxx
531 //
532 // Revision 1.25  1998/07/13 21:01:38  curt
533 // Wrote access functions for current fgOPTIONS.
534 //
535 // Revision 1.24  1998/07/13 15:32:39  curt
536 // Clear color buffer if drawing wireframe.
537 // When specifying and airport, start elevation at -1000 and let the system
538 // position you at ground level.
539 //
540 // Revision 1.23  1998/07/12 03:14:43  curt
541 // Added ground collision detection.
542 // Did some serious horsing around to be able to "hug" the ground properly
543 //   and still be able to take off.
544 // Set the near clip plane to 1.0 meters when less than 10 meters above the
545 //   ground.
546 // Did some serious horsing around getting the initial airplane position to be
547 //   correct based on rendered terrain elevation.
548 // Added a little cheat/hack that will prevent the view position from ever
549 //   dropping below the terrain, even when the flight model doesn't quite
550 //   put you as high as you'd like.
551 //
552 // Revision 1.22  1998/07/04 00:52:25  curt
553 // Add my own version of gluLookAt() (which is nearly identical to the
554 // Mesa/glu version.)  But, by calculating the Model View matrix our selves
555 // we can save this matrix without having to read it back in from the video
556 // card.  This hopefully allows us to save a few cpu cycles when rendering
557 // out the fragments because we can just use glLoadMatrixd() with the
558 // precalculated matrix for each tile rather than doing a push(), translate(),
559 // pop() for every fragment.
560 //
561 // Panel status defaults to off for now until it gets a bit more developed.
562 //
563 // Extract OpenGL driver info on initialization.
564 //
565 // Revision 1.21  1998/06/27 16:54:33  curt
566 // Replaced "extern displayInstruments" with a entry in fgOPTIONS.
567 // Don't change the view port when displaying the panel.
568 //
569 // Revision 1.20  1998/06/17 21:35:12  curt
570 // Refined conditional audio support compilation.
571 // Moved texture parameter setup calls to ../Scenery/materials.cxx
572 // #include <string.h> before various STL includes.
573 // Make HUD default state be enabled.
574 //
575 // Revision 1.19  1998/06/08 17:57:05  curt
576 // Minor sound/startup position tweaks.
577 //
578 // Revision 1.18  1998/06/03 00:47:14  curt
579 // Updated to compile in audio support if OSS available.
580 // Updated for new version of Steve's audio library.
581 // STL includes don't use .h
582 // Small view optimizations.
583 //
584 // Revision 1.17  1998/06/01 17:54:42  curt
585 // Added Linux audio support.
586 // avoid glClear( COLOR_BUFFER_BIT ) when not using it to set the sky color.
587 // map stl tweaks.
588 //
589 // Revision 1.16  1998/05/29 20:37:24  curt
590 // Tweaked material properties & lighting a bit in GLUTmain.cxx.
591 // Read airport list into a "map" STL for dynamic list sizing and fast tree
592 // based lookups.
593 //
594 // Revision 1.15  1998/05/22 21:28:53  curt
595 // Modifications to use the new fgEVENT_MGR class.
596 //
597 // Revision 1.14  1998/05/20 20:51:35  curt
598 // Tweaked smooth shaded texture lighting properties.
599 // Converted fgLIGHT to a C++ class.
600 //
601 // Revision 1.13  1998/05/16 13:08:35  curt
602 // C++ - ified views.[ch]xx
603 // Shuffled some additional view parameters into the fgVIEW class.
604 // Changed tile-radius to tile-diameter because it is a much better
605 //   name.
606 // Added a WORLD_TO_EYE transformation to views.cxx.  This allows us
607 //  to transform world space to eye space for view frustum culling.
608 //
609 // Revision 1.12  1998/05/13 18:29:58  curt
610 // Added a keyboard binding to dynamically adjust field of view.
611 // Added a command line option to specify fov.
612 // Adjusted terrain color.
613 // Root path info moved to fgOPTIONS.
614 // Added ability to parse options out of a config file.
615 //
616 // Revision 1.11  1998/05/07 23:14:15  curt
617 // Added "D" key binding to set autopilot heading.
618 // Made frame rate calculation average out over last 10 frames.
619 // Borland C++ floating point exception workaround.
620 // Added a --tile-radius=n option.
621 //
622 // Revision 1.10  1998/05/06 03:16:24  curt
623 // Added an averaged global frame rate counter.
624 // Added an option to control tile radius.
625 //
626 // Revision 1.9  1998/05/03 00:47:31  curt
627 // Added an option to enable/disable full-screen mode.
628 //
629 // Revision 1.8  1998/04/30 12:34:18  curt
630 // Added command line rendering options:
631 //   enable/disable fog/haze
632 //   specify smooth/flat shading
633 //   disable sky blending and just use a solid color
634 //   enable wireframe drawing mode
635 //
636 // Revision 1.7  1998/04/28 01:20:22  curt
637 // Type-ified fgTIME and fgVIEW.
638 // Added a command line option to disable textures.
639 //
640 // Revision 1.6  1998/04/26 05:10:03  curt
641 // "struct fgLIGHT" -> "fgLIGHT" because fgLIGHT is typedef'd.
642 //
643 // Revision 1.5  1998/04/25 22:06:30  curt
644 // Edited cvs log messages in source files ... bad bad bad!
645 //
646 // Revision 1.4  1998/04/25 20:24:01  curt
647 // Cleaned up initialization sequence to eliminate interdependencies
648 // between sun position, lighting, and view position.  This creates a
649 // valid single pass initialization path.
650 //
651 // Revision 1.3  1998/04/25 15:11:11  curt
652 // Added an command line option to set starting position based on airport ID.
653 //
654 // Revision 1.2  1998/04/24 00:49:20  curt
655 // Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
656 // Trying out some different option parsing code.
657 // Some code reorganization.
658 //
659 // Revision 1.1  1998/04/22 13:25:44  curt
660 // C++ - ifing the code.
661 // Starting a bit of reorganization of lighting code.
662 //
663 // Revision 1.56  1998/04/18 04:11:28  curt
664 // Moved fg_debug to it's own library, added zlib support.
665 //
666 // Revision 1.55  1998/04/14 02:21:03  curt
667 // Incorporated autopilot heading hold contributed by:  Jeff Goeke-Smith
668 // <jgoeke@voyager.net>
669 //
670 // Revision 1.54  1998/04/08 23:35:36  curt
671 // Tweaks to Gnu automake/autoconf system.
672 //
673 // Revision 1.53  1998/04/03 22:09:06  curt
674 // Converting to Gnu autoconf system.
675 //
676 // Revision 1.52  1998/03/23 21:24:38  curt
677 // Source code formating tweaks.
678 //
679 // Revision 1.51  1998/03/14 00:31:22  curt
680 // Beginning initial terrain texturing experiments.
681 //
682 // Revision 1.50  1998/03/09 22:46:19  curt
683 // Minor tweaks.
684 //
685 // Revision 1.49  1998/02/23 19:07:59  curt
686 // Incorporated Durk's Astro/ tweaks.  Includes unifying the sun position
687 // calculation code between sun display, and other FG sections that use this
688 // for things like lighting.
689 //
690 // Revision 1.48  1998/02/21 14:53:15  curt
691 // Added Charlie's HUD changes.
692 //
693 // Revision 1.47  1998/02/19 13:05:53  curt
694 // Incorporated some HUD tweaks from Michelle America.
695 // Tweaked the sky's sunset/rise colors.
696 // Other misc. tweaks.
697 //
698 // Revision 1.46  1998/02/18 15:07:06  curt
699 // Tweaks to build with SGI OpenGL (and therefor hopefully other accelerated
700 // drivers will work.)
701 //
702 // Revision 1.45  1998/02/16 13:39:43  curt
703 // Miscellaneous weekend tweaks.  Fixed? a cache problem that caused whole
704 // tiles to occasionally be missing.
705 //
706 // Revision 1.44  1998/02/12 21:59:50  curt
707 // Incorporated code changes contributed by Charlie Hotchkiss
708 // <chotchkiss@namg.us.anritsu.com>
709 //
710 // Revision 1.43  1998/02/11 02:50:40  curt
711 // Minor changes.
712 //
713 // Revision 1.42  1998/02/09 22:56:58  curt
714 // Removed "depend" files from cvs control.  Other minor make tweaks.
715 //
716 // Revision 1.41  1998/02/09 15:07:50  curt
717 // Minor tweaks.
718 //
719 // Revision 1.40  1998/02/07 15:29:44  curt
720 // Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
721 // <chotchkiss@namg.us.anritsu.com>
722 //
723 // Revision 1.39  1998/02/03 23:20:25  curt
724 // Lots of little tweaks to fix various consistency problems discovered by
725 // Solaris' CC.  Fixed a bug in fg_debug.c with how the fgPrintf() wrapper
726 // passed arguments along to the real printf().  Also incorporated HUD changes
727 // by Michele America.
728 //
729 // Revision 1.38  1998/02/02 20:53:58  curt
730 // Incorporated Durk's changes.
731 //
732 // Revision 1.37  1998/02/01 03:39:54  curt
733 // Minor tweaks.
734 //
735 // Revision 1.36  1998/01/31 00:43:13  curt
736 // Added MetroWorks patches from Carmen Volpe.
737 //
738 // Revision 1.35  1998/01/27 00:47:57  curt
739 // Incorporated Paul Bleisch's <pbleisch@acm.org> new debug message
740 // system and commandline/config file processing code.
741 //
742 // Revision 1.34  1998/01/22 02:59:37  curt
743 // Changed #ifdef FILE_H to #ifdef _FILE_H
744 //
745 // Revision 1.33  1998/01/21 21:11:34  curt
746 // Misc. tweaks.
747 //
748 // Revision 1.32  1998/01/19 19:27:08  curt
749 // Merged in make system changes from Bob Kuehne <rpk@sgi.com>
750 // This should simplify things tremendously.
751 //
752 // Revision 1.31  1998/01/19 18:40:32  curt
753 // Tons of little changes to clean up the code and to remove fatal errors
754 // when building with the c++ compiler.
755 //
756 // Revision 1.30  1998/01/13 00:23:09  curt
757 // Initial changes to support loading and management of scenery tiles.  Note,
758 // there's still a fair amount of work left to be done.
759 //
760 // Revision 1.29  1998/01/08 02:22:08  curt
761 // Beginning to integrate Tile management subsystem.
762 //
763 // Revision 1.28  1998/01/07 03:18:58  curt
764 // Moved astronomical stuff from .../Src/Scenery to .../Src/Astro/
765 //
766 // Revision 1.27  1998/01/05 18:44:35  curt
767 // Add an option to advance/decrease time from keyboard.
768 //
769 // Revision 1.26  1997/12/30 23:09:04  curt
770 // Tweaking initialization sequences.
771 //
772 // Revision 1.25  1997/12/30 22:22:33  curt
773 // Further integration of event manager.
774 //
775 // Revision 1.24  1997/12/30 20:47:44  curt
776 // Integrated new event manager with subsystem initializations.
777 //
778 // Revision 1.23  1997/12/30 16:36:50  curt
779 // Merged in Durk's changes ...
780 //
781 // Revision 1.22  1997/12/19 23:34:05  curt
782 // Lot's of tweaking with sky rendering and lighting.
783 //
784 // Revision 1.21  1997/12/19 16:45:00  curt
785 // Working on scene rendering order and options.
786 //
787 // Revision 1.20  1997/12/18 23:32:33  curt
788 // First stab at sky dome actually starting to look reasonable. :-)
789 //
790 // Revision 1.19  1997/12/17 23:13:36  curt
791 // Began working on rendering a sky.
792 //
793 // Revision 1.18  1997/12/15 23:54:49  curt
794 // Add xgl wrappers for debugging.
795 // Generate terrain normals on the fly.
796 //
797 // Revision 1.17  1997/12/15 20:59:09  curt
798 // Misc. tweaks.
799 //
800 // Revision 1.16  1997/12/12 19:52:48  curt
801 // Working on lightling and material properties.
802 //
803 // Revision 1.15  1997/12/11 04:43:55  curt
804 // Fixed sun vector and lighting problems.  I thing the moon is now lit
805 // correctly.
806 //
807 // Revision 1.14  1997/12/10 22:37:47  curt
808 // Prepended "fg" on the name of all global structures that didn't have it yet.
809 // i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
810 //
811 // Revision 1.13  1997/11/25 19:25:32  curt
812 // Changes to integrate Durk's moon/sun code updates + clean up.
813 //
814 // Revision 1.12  1997/11/15 18:16:35  curt
815 // minor tweaks.
816 //
817 // Revision 1.11  1997/10/30 12:38:42  curt
818 // Working on new scenery subsystem.
819 //
820 // Revision 1.10  1997/10/25 03:24:23  curt
821 // Incorporated sun, moon, and star positioning code contributed by Durk Talsma.
822 //
823 // Revision 1.9  1997/09/23 00:29:39  curt
824 // Tweaks to get things to compile with gcc-win32.
825 //
826 // Revision 1.8  1997/09/22 14:44:20  curt
827 // Continuing to try to align stars correctly.
828 //
829 // Revision 1.7  1997/09/16 15:50:30  curt
830 // Working on star alignment and time issues.
831 //
832 // Revision 1.6  1997/09/05 14:17:30  curt
833 // More tweaking with stars.
834 //
835 // Revision 1.5  1997/09/04 02:17:36  curt
836 // Shufflin' stuff.
837 //
838 // Revision 1.4  1997/08/27 21:32:26  curt
839 // Restructured view calculation code.  Added stars.
840 //
841 // Revision 1.3  1997/08/27 03:30:19  curt
842 // Changed naming scheme of basic shared structures.
843 //
844 // Revision 1.2  1997/08/25 20:27:23  curt
845 // Merged in initial HUD and Joystick code.
846 //
847 // Revision 1.1  1997/08/23 01:46:20  curt
848 // Initial revision.
849 //
850