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