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