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