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