]> git.mxchange.org Git - flightgear.git/blob - Main/GLUTmain.c
Moved astronomical stuff from .../Src/Scenery to .../Src/Astro/
[flightgear.git] / Main / GLUTmain.c
1 /**************************************************************************
2  * GLUTmain.c -- top level sim routines
3  *
4  * Written by Curtis Olson for OpenGL, started May 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  * $Id$
23  * (Log is kept at end of this file)
24  **************************************************************************/
25
26
27 #ifdef WIN32
28 #  include <windows.h>                     
29 #endif
30
31 #include <GL/glut.h>
32 #include "../XGL/xgl.h"
33 #include <stdio.h>
34
35 #include "GLUTkey.h"
36 #include "fg_init.h"
37 #include "views.h"
38
39 #include "../Include/constants.h"
40 #include "../Include/general.h"
41
42 #include "../Aircraft/aircraft.h"
43 #include "../Astro/moon.h"
44 #include "../Astro/sky.h"
45 #include "../Astro/stars.h"
46 #include "../Astro/sun.h"
47 #include "../Cockpit/cockpit.h"
48 #include "../Joystick/joystick.h"
49 #include "../Math/fg_geodesy.h"
50 #include "../Math/mat3.h"
51 #include "../Math/polar.h"
52 #include "../Scenery/mesh.h"
53 #include "../Scenery/scenery.h"
54 #include "../Time/event.h"
55 #include "../Time/fg_time.h"
56 #include "../Time/fg_timer.h"
57 #include "../Time/sunpos.h"
58 #include "../Weather/weather.h"
59
60
61 /* This is a record containing global housekeeping information */
62 struct fgGENERAL general;
63
64 /* view parameters */
65 static GLfloat win_ratio = 1.0;
66 static GLint winWidth, winHeight;
67
68 /* temporary hack */
69 /* pointer to scenery structure */
70 /* static GLint scenery, runway; */
71
72 double Simtime;
73
74 /* Another hack */
75 int use_signals = 0;
76
77 /* Yet another hack. This one used by the HUD code. Michele */
78 int show_hud;
79
80 /* Yet another other hack. Used for my prototype instrument code. (Durk) */
81 int displayInstruments; 
82
83
84 /**************************************************************************
85  * fgInitVisuals() -- Initialize various GL/view parameters
86  **************************************************************************/
87
88 static void fgInitVisuals() {
89     struct fgLIGHT *l;
90     struct fgTIME *t;
91     struct fgWEATHER *w;
92
93     l = &cur_light_params;
94     t = &cur_time_params;
95     w = &current_weather;
96
97     
98     /* xglDisable( GL_DITHER ); */
99
100     /* If enabled, normal vectors specified with glNormal are scaled
101        to unit length after transformation.  See glNormal. */
102     xglEnable( GL_NORMALIZE );
103
104     xglEnable( GL_LIGHTING );
105     xglEnable( GL_LIGHT0 );
106     xglLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec );
107
108     xglFogi (GL_FOG_MODE, GL_LINEAR);
109     /* xglFogf (GL_FOG_START, 1.0); */
110     xglFogf (GL_FOG_END, w->visibility);
111     /* xglFogf (GL_FOG_DENSITY, w->visibility); */
112     xglHint (GL_FOG_HINT, GL_NICEST /* GL_FASTEST */ );
113 }
114
115
116 /**************************************************************************
117  * Update the view volume, position, and orientation
118  **************************************************************************/
119
120 static void fgUpdateViewParams() {
121     struct fgFLIGHT *f;
122     struct fgLIGHT *l;
123     struct fgTIME *t;
124     struct fgVIEW *v;
125
126     f = &current_aircraft.flight;
127     l = &cur_light_params;
128     t = &cur_time_params;
129     v = &current_view;
130
131     fgViewUpdate(f, v, l);
132
133     if (displayInstruments)
134       {
135         xglViewport(0, (GLint)(winHeight / 2 ) , (GLint)winWidth, (GLint)winHeight / 2);
136         /* Tell GL we are about to modify the projection parameters */    
137         xglMatrixMode(GL_PROJECTION);
138         xglLoadIdentity();
139         gluPerspective(55.0, 2.0/win_ratio, 1.0, 100000.0);
140       }
141     else
142       {
143         xglViewport(0, 0 , (GLint)winWidth, (GLint) winHeight);
144         /* Tell GL we are about to modify the projection parameters */    
145         xglMatrixMode(GL_PROJECTION);
146         xglLoadIdentity();
147         gluPerspective(55.0, 1.0/win_ratio, 1.0, 100000.0);
148       }
149
150     xglMatrixMode(GL_MODELVIEW);
151     xglLoadIdentity();
152     
153     /* set up our view volume (default) */
154     gluLookAt(v->view_pos.x, v->view_pos.y, v->view_pos.z,
155                v->view_pos.x + v->view_forward[0], 
156                v->view_pos.y + v->view_forward[1], 
157                v->view_pos.z + v->view_forward[2],
158                v->view_up[0], v->view_up[1], v->view_up[2]);
159
160     /* lock view horizontally towards sun (testing) */
161     /* gluLookAt(v->view_pos.x, v->view_pos.y, v->view_pos.z,
162                v->view_pos.x + v->surface_to_sun[0], 
163                v->view_pos.y + v->surface_to_sun[1], 
164                v->view_pos.z + v->surface_to_sun[2],
165                v->view_up[0], v->view_up[1], v->view_up[2]); */
166
167     /* lock view horizontally towards south (testing) */
168     /* gluLookAt(v->view_pos.x, v->view_pos.y, v->view_pos.z,
169                v->view_pos.x + v->surface_south[0], 
170                v->view_pos.y + v->surface_south[1], 
171                v->view_pos.z + v->surface_south[2],
172                v->view_up[0], v->view_up[1], v->view_up[2]); */
173
174     /* set the sun position */
175     xglLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec );
176 }
177
178
179 /*************************************************************************
180  * Draw a basic instrument panel
181  ************************************************************************/
182 static void fgUpdateInstrViewParams() {
183     xglViewport(0, 0 , (GLint)winWidth, (GLint)winHeight / 2);
184   
185     xglMatrixMode(GL_PROJECTION);
186     xglPushMatrix();
187   
188     xglLoadIdentity();
189     gluOrtho2D(0, 640, 0, 480);
190     xglMatrixMode(GL_MODELVIEW);
191     xglPushMatrix();
192     xglLoadIdentity();
193     
194     xglColor3f(1.0, 1.0, 1.0);
195     xglIndexi(7);
196   
197     xglDisable(GL_DEPTH_TEST);
198     xglDisable(GL_LIGHTING);
199   
200     xglLineWidth(1);
201     xglColor3f (0.5, 0.5, 0.5);
202
203     xglBegin(GL_QUADS);
204     xglVertex2f(0.0, 0.00);
205     xglVertex2f(0.0, 480.0);
206     xglVertex2f(640.0,480.0);
207     xglVertex2f(640.0, 0.0);
208     xglEnd();
209
210     xglRectf(0.0,0.0, 640, 480);
211     xglEnable(GL_DEPTH_TEST);
212     xglEnable(GL_LIGHTING);
213     xglMatrixMode(GL_PROJECTION);
214     xglPopMatrix();
215     xglMatrixMode(GL_MODELVIEW);
216     xglPopMatrix();
217 }
218
219
220 /**************************************************************************
221  * Update all Visuals (redraws anything graphics related)
222  **************************************************************************/
223
224 static void fgRenderFrame( void ) {
225     struct fgLIGHT *l;
226     struct fgTIME *t;
227     struct fgVIEW *v;
228     double angle;
229     GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 };
230
231     l = &cur_light_params;
232     t = &cur_time_params;
233     v = &current_view;
234
235     /* update view volume parameters */
236     fgUpdateViewParams();
237
238     xglClear( GL_DEPTH_BUFFER_BIT /* | GL_COLOR_BUFFER_BIT */ );
239
240     /* Tell GL we are switching to model view parameters */
241     xglMatrixMode(GL_MODELVIEW);
242     /* xglLoadIdentity(); */
243
244     /* draw sky */
245     xglDisable( GL_DEPTH_TEST );
246     xglDisable( GL_LIGHTING );
247     xglDisable( GL_CULL_FACE );
248     xglDisable( GL_FOG );
249     xglShadeModel( GL_SMOOTH );
250     fgSkyRender();
251
252     /* setup transformation for drawing astronomical objects */
253     xglPushMatrix();
254     /* Translate to view position */
255     xglTranslatef( v->view_pos.x, v->view_pos.y, v->view_pos.z );
256     /* Rotate based on gst (side real time) */
257     angle = t->gst * 15.041085; /* should be 15.041085, Curt thought it was 15*/
258     /* printf("Rotating astro objects by %.2f degrees\n",angle); */
259     xglRotatef( angle, 0.0, 0.0, -1.0 );
260
261     /* draw stars and planets */
262     fgStarsRender();
263
264     /* draw the sun */
265     fgSunRender();
266
267     /* render the moon */
268     xglEnable( GL_LIGHTING );
269     /* set lighting parameters */
270     xglLightfv(GL_LIGHT0, GL_AMBIENT, white );
271     xglLightfv(GL_LIGHT0, GL_DIFFUSE, white );
272     xglEnable( GL_CULL_FACE );
273     fgMoonRender();
274
275     xglPopMatrix();
276
277     /* draw scenery */
278     xglShadeModel( GL_SMOOTH ); 
279     xglEnable( GL_DEPTH_TEST );
280     xglEnable( GL_FOG );
281     xglFogfv (GL_FOG_COLOR, l->fog_color);
282     /* set lighting parameters */
283     xglLightfv(GL_LIGHT0, GL_AMBIENT, l->scene_ambient );
284     xglLightfv(GL_LIGHT0, GL_DIFFUSE, l->scene_diffuse );
285     fgSceneryRender();
286
287     /* display HUD */
288     if( show_hud ) {
289         fgCockpitUpdate();
290     }
291
292     /* display instruments */
293     if (displayInstruments) {
294         fgUpdateInstrViewParams();
295     }
296
297     #ifdef GLUT
298       xglutSwapBuffers();
299     #endif
300 }
301
302
303 /**************************************************************************
304  * Update internal time dependent calculations (i.e. flight model)
305  **************************************************************************/
306
307 void fgUpdateTimeDepCalcs(int multi_loop) {
308     struct fgFLIGHT *f;
309     struct fgTIME *t;
310     struct fgVIEW *v;
311     int i;
312
313     f = &current_aircraft.flight;
314     t = &cur_time_params;
315     v = &current_view;
316
317     /* update the flight model */
318     if ( multi_loop < 0 ) {
319         multi_loop = DEFAULT_MULTILOOP;
320     }
321
322     /* printf("updating flight model x %d\n", multi_loop); */
323     fgFlightModelUpdate(FG_LARCSIM, f, multi_loop);
324
325     /* update the view angle */
326     for ( i = 0; i < multi_loop; i++ ) {
327         if ( fabs(v->goal_view_offset - v->view_offset) < 0.05 ) {
328             v->view_offset = v->goal_view_offset;
329             break;
330         } else {
331             /* move v->view_offset towards v->goal_view_offset */
332             if ( v->goal_view_offset > v->view_offset ) {
333                 if ( v->goal_view_offset - v->view_offset < FG_PI ) {
334                     v->view_offset += 0.01;
335                 } else {
336                     v->view_offset -= 0.01;
337                 }
338             } else {
339                 if ( v->view_offset - v->goal_view_offset < FG_PI ) {
340                     v->view_offset -= 0.01;
341                 } else {
342                     v->view_offset += 0.01;
343                 }
344             }
345             if ( v->view_offset > FG_2PI ) {
346                 v->view_offset -= FG_2PI;
347             } else if ( v->view_offset < 0 ) {
348                 v->view_offset += FG_2PI;
349             }
350         }
351     }
352 }
353
354
355 void fgInitTimeDepCalcs() {
356     /* initialize timer */
357
358 #ifdef USE_ITIMER
359     fgTimerInit( 1.0 / DEFAULT_TIMER_HZ, fgUpdateTimeDepCalcs );
360 #endif USE_ITIMER
361
362 }
363
364
365 /**************************************************************************
366  * Scenery management routines
367  **************************************************************************/
368
369 /* static void fgSceneryInit_OLD() { */
370     /* make scenery */
371 /*     scenery = fgSceneryCompile_OLD();
372     runway = fgRunwayHack_OLD(0.69, 53.07);
373 } */
374
375
376 /* create the scenery */
377 /* GLint fgSceneryCompile_OLD() {
378     GLint scenery;
379
380     scenery = mesh2GL(mesh_ptr_OLD);
381
382     return(scenery);
383 }
384 */
385
386 /* hack in a runway */
387 /* GLint fgRunwayHack_OLD(double width, double length) {
388     static GLfloat concrete[4] = { 0.5, 0.5, 0.5, 1.0 };
389     static GLfloat line[4]     = { 0.9, 0.9, 0.9, 1.0 };
390     int i;
391     int num_lines = 16;
392     float line_len, line_width_2, cur_pos;
393
394     runway = xglGenLists(1);
395     xglNewList(runway, GL_COMPILE);
396     */
397     /* draw concrete */
398 /*    xglBegin(GL_POLYGON);
399     xglMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, concrete );
400     xglNormal3f(0.0, 0.0, 1.0);
401
402     xglVertex3d( 0.0,   -width/2.0, 0.0);
403     xglVertex3d( 0.0,    width/2.0, 0.0);
404     xglVertex3d(length,  width/2.0, 0.0);
405     xglVertex3d(length, -width/2.0, 0.0);
406     xglEnd();
407     */
408     /* draw center line */
409 /*    xglMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, line );
410     line_len = length / ( 2 * num_lines + 1);
411     printf("line_len = %.3f\n", line_len);
412     line_width_2 = 0.02;
413     cur_pos = line_len;
414     for ( i = 0; i < num_lines; i++ ) {
415         xglBegin(GL_POLYGON);
416         xglVertex3d( cur_pos, -line_width_2, 0.005);
417         xglVertex3d( cur_pos,  line_width_2, 0.005);
418         cur_pos += line_len;
419         xglVertex3d( cur_pos,  line_width_2, 0.005);
420         xglVertex3d( cur_pos, -line_width_2, 0.005);
421         cur_pos += line_len;
422         xglEnd();
423     }
424
425     xglEndList();
426
427     return(runway);
428 }
429 */
430
431 /* draw the scenery */
432 /*static void fgSceneryDraw_OLD() {
433     static float z = 32.35;
434
435     xglPushMatrix();
436
437     xglCallList(scenery);
438
439     printf("*** Drawing runway at %.2f\n", z);
440
441     xglTranslatef( -398391.28, 120070.41, 32.35);
442     xglRotatef(170.0, 0.0, 0.0, 1.0);
443     xglCallList(runway);
444
445     xglPopMatrix();
446 }
447 */
448
449
450 /* What should we do when we have nothing else to do?  How about get
451  * ready for the next move and update the display? */
452 static void fgMainLoop( void ) {
453     static int remainder = 0;
454     int elapsed, multi_loop;
455     double cur_elev;
456     double joy_x, joy_y;
457     int joy_b1, joy_b2;
458     struct fgAIRCRAFT *a;
459     struct fgFLIGHT *f;
460     struct fgTIME *t;
461
462     printf("Running Main Loop\n");
463     printf("======= ==== ====\n");
464
465     a = &current_aircraft;
466     f = &a->flight;
467     t = &cur_time_params;
468
469     /* update "time" */
470     fgTimeUpdate(f, t);
471
472     /* Read joystick */
473     /* fgJoystickRead( &joy_x, &joy_y, &joy_b1, &joy_b2 );
474     printf( "Joystick X %f  Y %f  B1 %d  B2 %d\n",  
475             joy_x, joy_y, joy_b1, joy_b2 );
476     fgElevSet( -joy_y );
477     fgAileronSet( joy_x ); */
478
479     /* Calculate model iterations needed */
480     elapsed = fgGetTimeInterval();
481     printf("Time interval is = %d, previous remainder is = %d\n", elapsed, 
482            remainder);
483     printf("--> Frame rate is = %.2f\n", 1000.0 / (float)elapsed);
484     elapsed += remainder;
485
486     multi_loop = ((float)elapsed * 0.001) * DEFAULT_MODEL_HZ;
487     remainder = elapsed - ((multi_loop*1000) / DEFAULT_MODEL_HZ);
488     printf("Model iterations needed = %d, new remainder = %d\n", multi_loop, 
489            remainder);
490
491     /* Run flight model */
492     if ( ! use_signals ) {
493         /* flight model */
494         fgUpdateTimeDepCalcs(multi_loop);
495     }
496
497     /* I'm just sticking this here for now, it should probably move 
498      * eventually */
499     cur_elev = mesh_altitude(FG_Longitude * RAD_TO_ARCSEC, 
500                                FG_Latitude  * RAD_TO_ARCSEC);
501     /* printf("Ground elevation is %.2f meters here.\n", cur_elev); */
502     /* FG_Runway_altitude = cur_elev * METER_TO_FEET; */
503
504     if ( FG_Altitude * FEET_TO_METER < cur_elev + 3.758099) {
505         /* set this here, otherwise if we set runway height above our
506            current height we get a really nasty bounce. */
507         FG_Runway_altitude = FG_Altitude - 3.758099;
508
509         /* now set aircraft altitude above ground */
510         FG_Altitude = cur_elev * METER_TO_FEET + 3.758099;
511         printf("<*> resetting altitude to %.0f meters\n", 
512                FG_Altitude * FEET_TO_METER);
513     }
514
515     /* fgAircraftOutputCurrent(a); */
516
517     /* Process/manage pending events */
518     fgEventProcess();
519
520     /* redraw display */
521     fgRenderFrame();
522
523     printf("\n");
524 }
525
526
527 /**************************************************************************
528  * Handle new window size or exposure
529  **************************************************************************/
530
531 static void fgReshape( int width, int height ) {
532     /* Do this so we can call fgReshape(0,0) ourselves without having to know
533      * what the values of width & height are. */
534     if ( (height > 0) && (width > 0) ) {
535         win_ratio = (GLfloat) height / (GLfloat) width;
536     }
537
538     winWidth = width;
539     winHeight = height;
540
541     /* Inform gl of our view window size (now handled elsewhere) */
542     /* xglViewport(0, 0, (GLint)width, (GLint)height); */
543
544     fgUpdateViewParams();
545     
546     /* xglClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); */
547 }
548
549
550 /**************************************************************************
551  * Main ...
552  **************************************************************************/
553
554 int main( int argc, char *argv[] ) {
555     struct fgFLIGHT *f;
556
557     f = &current_aircraft.flight;
558
559     printf("Flight Gear:  Version %s\n\n", VERSION);
560
561     /**********************************************************************
562      * Initialize the Window/Graphics environment.
563      **********************************************************************/
564
565     #ifdef GLUT
566       /* initialize GLUT */
567       xglutInit(&argc, argv);
568
569       /* Define Display Parameters */
570       xglutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
571
572       /* Define initial window size */
573       xglutInitWindowSize(640, 480);
574
575       /* Initialize windows */
576       xglutCreateWindow("Flight Gear");
577     #endif
578
579     /* This is the general house keeping init routine */
580     fgInitGeneral();
581
582     /* This is the top level init routine which calls all the other
583      * subsystem initialization routines.  If you are adding a
584      * subsystem to flight gear, its initialization call should
585      * located in this routine.*/
586     fgInitSubsystems();
587
588     /* setup view parameters, only makes GL calls */
589     fgInitVisuals();
590
591     if ( use_signals ) {
592         /* init timer routines, signals, etc.  Arrange for an alarm
593            signal to be generated, etc. */
594         fgInitTimeDepCalcs();
595     }
596
597    /**********************************************************************
598      * Initialize the Event Handlers.
599      **********************************************************************/
600
601     #ifdef GLUT
602       /* call fgReshape() on window resizes */
603       xglutReshapeFunc( fgReshape );
604
605       /* call key() on keyboard event */
606       xglutKeyboardFunc( GLUTkey );
607       glutSpecialFunc( GLUTspecialkey );
608
609       /* call fgMainLoop() whenever there is nothing else to do */
610       xglutIdleFunc( fgMainLoop );
611
612       /* draw the scene */
613       xglutDisplayFunc( fgRenderFrame );
614
615       /* pass control off to the GLUT event handler */
616       glutMainLoop();
617     #endif
618
619     return(0);
620 }
621
622
623 #ifdef NO_PRINTF
624   #include <stdarg.h>
625   int printf (const char *format, ...) {
626   }
627 #endif
628
629
630 /* $Log$
631 /* Revision 1.45  1998/01/07 03:18:55  curt
632 /* Moved astronomical stuff from .../Src/Scenery to .../Src/Astro/
633 /*
634  * Revision 1.44  1997/12/30 22:22:31  curt
635  * Further integration of event manager.
636  *
637  * Revision 1.43  1997/12/30 20:47:43  curt
638  * Integrated new event manager with subsystem initializations.
639  *
640  * Revision 1.42  1997/12/30 16:36:47  curt
641  * Merged in Durk's changes ...
642  *
643  * Revision 1.41  1997/12/30 13:06:56  curt
644  * A couple lighting tweaks ...
645  *
646  * Revision 1.40  1997/12/30 01:38:37  curt
647  * Switched back to per vertex normals and smooth shading for terrain.
648  *
649  * Revision 1.39  1997/12/22 23:45:45  curt
650  * First stab at sunset/sunrise sky glow effects.
651  *
652  * Revision 1.38  1997/12/22 04:14:28  curt
653  * Aligned sky with sun so dusk/dawn effects can be correct relative to the sun.
654  *
655  * Revision 1.37  1997/12/19 23:34:03  curt
656  * Lot's of tweaking with sky rendering and lighting.
657  *
658  * Revision 1.36  1997/12/19 16:44:57  curt
659  * Working on scene rendering order and options.
660  *
661  * Revision 1.35  1997/12/18 23:32:32  curt
662  * First stab at sky dome actually starting to look reasonable. :-)
663  *
664  * Revision 1.34  1997/12/17 23:13:34  curt
665  * Began working on rendering a sky.
666  *
667  * Revision 1.33  1997/12/15 23:54:45  curt
668  * Add xgl wrappers for debugging.
669  * Generate terrain normals on the fly.
670  *
671  * Revision 1.32  1997/12/15 20:59:08  curt
672  * Misc. tweaks.
673  *
674  * Revision 1.31  1997/12/12 21:41:25  curt
675  * More light/material property tweaking ... still a ways off.
676  *
677  * Revision 1.30  1997/12/12 19:52:47  curt
678  * Working on lightling and material properties.
679  *
680  * Revision 1.29  1997/12/11 04:43:54  curt
681  * Fixed sun vector and lighting problems.  I thing the moon is now lit
682  * correctly.
683  *
684  * Revision 1.28  1997/12/10 22:37:45  curt
685  * Prepended "fg" on the name of all global structures that didn't have it yet.
686  * i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
687  *
688  * Revision 1.27  1997/12/09 05:11:54  curt
689  * Working on tweaking lighting.
690  *
691  * Revision 1.26  1997/12/09 04:25:29  curt
692  * Working on adding a global lighting params structure.
693  *
694  * Revision 1.25  1997/12/08 22:54:09  curt
695  * Enabled GL_CULL_FACE.
696  *
697  * Revision 1.24  1997/11/25 19:25:32  curt
698  * Changes to integrate Durk's moon/sun code updates + clean up.
699  *
700  * Revision 1.23  1997/11/15 18:16:34  curt
701  * minor tweaks.
702  *
703  * Revision 1.22  1997/10/30 12:38:41  curt
704  * Working on new scenery subsystem.
705  *
706  * Revision 1.21  1997/09/23 00:29:38  curt
707  * Tweaks to get things to compile with gcc-win32.
708  *
709  * Revision 1.20  1997/09/22 14:44:19  curt
710  * Continuing to try to align stars correctly.
711  *
712  * Revision 1.19  1997/09/18 16:20:08  curt
713  * At dusk/dawn add/remove stars in stages.
714  *
715  * Revision 1.18  1997/09/16 22:14:51  curt
716  * Tweaked time of day lighting equations.  Don't draw stars during the day.
717  *
718  * Revision 1.17  1997/09/16 15:50:29  curt
719  * Working on star alignment and time issues.
720  *
721  * Revision 1.16  1997/09/13 02:00:06  curt
722  * Mostly working on stars and generating sidereal time for accurate star
723  * placement.
724  *
725  * Revision 1.15  1997/09/05 14:17:27  curt
726  * More tweaking with stars.
727  *
728  * Revision 1.14  1997/09/05 01:35:53  curt
729  * Working on getting stars right.
730  *
731  * Revision 1.13  1997/09/04 02:17:34  curt
732  * Shufflin' stuff.
733  *
734  * Revision 1.12  1997/08/27 21:32:24  curt
735  * Restructured view calculation code.  Added stars.
736  *
737  * Revision 1.11  1997/08/27 03:30:16  curt
738  * Changed naming scheme of basic shared structures.
739  *
740  * Revision 1.10  1997/08/25 20:27:22  curt
741  * Merged in initial HUD and Joystick code.
742  *
743  * Revision 1.9  1997/08/22 21:34:39  curt
744  * Doing a bit of reorganizing and house cleaning.
745  *
746  * Revision 1.8  1997/08/19 23:55:03  curt
747  * Worked on better simulating real lighting.
748  *
749  * Revision 1.7  1997/08/16 12:22:38  curt
750  * Working on improving the lighting/shading.
751  *
752  * Revision 1.6  1997/08/13 20:24:56  curt
753  * Changes due to changing sunpos interface.
754  *
755  * Revision 1.5  1997/08/06 21:08:32  curt
756  * Sun position now *really* works (I think) ... I still have sun time warping
757  * code in place, probably should remove it soon.
758  *
759  * Revision 1.4  1997/08/06 15:41:26  curt
760  * Working on correct sun position.
761  *
762  * Revision 1.3  1997/08/06 00:24:22  curt
763  * Working on correct real time sun lighting.
764  *
765  * Revision 1.2  1997/08/04 20:25:15  curt
766  * Organizational tweaking.
767  *
768  * Revision 1.1  1997/08/02 18:45:00  curt
769  * Renamed GLmain.c GLUTmain.c
770  *
771  * Revision 1.43  1997/08/02 16:23:47  curt
772  * Misc. tweaks.
773  *
774  * Revision 1.42  1997/08/01 19:43:33  curt
775  * Making progress with coordinate system overhaul.
776  *
777  * Revision 1.41  1997/07/31 22:52:37  curt
778  * Working on redoing internal coordinate systems & scenery transformations.
779  *
780  * Revision 1.40  1997/07/30 16:12:42  curt
781  * Moved fg_random routines from Util/ to Math/
782  *
783  * Revision 1.39  1997/07/21 14:45:01  curt
784  * Minor tweaks.
785  *
786  * Revision 1.38  1997/07/19 23:04:47  curt
787  * Added an initial weather section.
788  *
789  * Revision 1.37  1997/07/19 22:34:02  curt
790  * Moved PI definitions to ../constants.h
791  * Moved random() stuff to ../Utils/ and renamed fg_random()
792  *
793  * Revision 1.36  1997/07/18 23:41:25  curt
794  * Tweaks for building with Cygnus Win32 compiler.
795  *
796  * Revision 1.35  1997/07/18 14:28:34  curt
797  * Hacked in some support for wind/turbulence.
798  *
799  * Revision 1.34  1997/07/16 20:04:48  curt
800  * Minor tweaks to aid Win32 port.
801  *
802  * Revision 1.33  1997/07/12 03:50:20  curt
803  * Added an #include <Windows32/Base.h> to help compiling for Win32
804  *
805  * Revision 1.32  1997/07/11 03:23:18  curt
806  * Solved some scenery display/orientation problems.  Still have a positioning
807  * (or transformation?) problem.
808  *
809  * Revision 1.31  1997/07/11 01:29:58  curt
810  * More tweaking of terrian floor.
811  *
812  * Revision 1.30  1997/07/10 04:26:37  curt
813  * We now can interpolated ground elevation for any position in the grid.  We
814  * can use this to enforce a "hard" ground.  We still need to enforce some
815  * bounds checking so that we don't try to lookup data points outside the
816  * grid data set.
817  *
818  * Revision 1.29  1997/07/09 21:31:12  curt
819  * Working on making the ground "hard."
820  *
821  * Revision 1.28  1997/07/08 18:20:12  curt
822  * Working on establishing a hard ground.
823  *
824  * Revision 1.27  1997/07/07 20:59:49  curt
825  * Working on scenery transformations to enable us to fly fluidly over the
826  * poles with no discontinuity/distortion in scenery.
827  *
828  * Revision 1.26  1997/07/05 20:43:34  curt
829  * renamed mat3 directory to Math so we could add other math related routines.
830  *
831  * Revision 1.25  1997/06/29 21:19:17  curt
832  * Working on scenery management system.
833  *
834  * Revision 1.24  1997/06/26 22:14:53  curt
835  * Beginning work on a scenery management system.
836  *
837  * Revision 1.23  1997/06/26 19:08:33  curt
838  * Restructuring make, adding automatic "make dep" support.
839  *
840  * Revision 1.22  1997/06/25 15:39:47  curt
841  * Minor changes to compile with rsxnt/win32.
842  *
843  * Revision 1.21  1997/06/22 21:44:41  curt
844  * Working on intergrating the VRML (subset) parser.
845  *
846  * Revision 1.20  1997/06/21 17:12:53  curt
847  * Capitalized subdirectory names.
848  *
849  * Revision 1.19  1997/06/18 04:10:31  curt
850  * A couple more runway tweaks ...
851  *
852  * Revision 1.18  1997/06/18 02:21:24  curt
853  * Hacked in a runway
854  *
855  * Revision 1.17  1997/06/17 16:51:58  curt
856  * Timer interval stuff now uses gettimeofday() instead of ftime()
857  *
858  * Revision 1.16  1997/06/17 04:19:16  curt
859  * More timer related tweaks with respect to view direction changes.
860  *
861  * Revision 1.15  1997/06/17 03:41:10  curt
862  * Nonsignal based interval timing is now working.
863  * This would be a good time to look at cleaning up the code structure a bit.
864  *
865  * Revision 1.14  1997/06/16 19:32:51  curt
866  * Starting to add general timer support.
867  *
868  * Revision 1.13  1997/06/02 03:40:06  curt
869  * A tiny bit more view tweaking.
870  *
871  * Revision 1.12  1997/06/02 03:01:38  curt
872  * Working on views (side, front, back, transitions, etc.)
873  *
874  * Revision 1.11  1997/05/31 19:16:25  curt
875  * Elevator trim added.
876  *
877  * Revision 1.10  1997/05/31 04:13:52  curt
878  * WE CAN NOW FLY!!!
879  *
880  * Continuing work on the LaRCsim flight model integration.
881  * Added some MSFS-like keyboard input handling.
882  *
883  * Revision 1.9  1997/05/30 19:27:01  curt
884  * The LaRCsim flight model is starting to look like it is working.
885  *
886  * Revision 1.8  1997/05/30 03:54:10  curt
887  * Made a bit more progress towards integrating the LaRCsim flight model.
888  *
889  * Revision 1.7  1997/05/29 22:39:49  curt
890  * Working on incorporating the LaRCsim flight model.
891  *
892  * Revision 1.6  1997/05/29 12:31:39  curt
893  * Minor tweaks, moving towards general flight model integration.
894  *
895  * Revision 1.5  1997/05/29 02:33:23  curt
896  * Updated to reflect changing interfaces in other "modules."
897  *
898  * Revision 1.4  1997/05/27 17:44:31  curt
899  * Renamed & rearranged variables and routines.   Added some initial simple
900  * timer/alarm routines so the flight model can be updated on a regular 
901  * interval.
902  *
903  * Revision 1.3  1997/05/23 15:40:25  curt
904  * Added GNU copyright headers.
905  * Fog now works!
906  *
907  * Revision 1.2  1997/05/23 00:35:12  curt
908  * Trying to get fog to work ...
909  *
910  * Revision 1.1  1997/05/21 15:57:51  curt
911  * Renamed due to added GLUT support.
912  *
913  * Revision 1.3  1997/05/19 18:22:42  curt
914  * Parameter tweaking ... starting to stub in fog support.
915  *
916  * Revision 1.2  1997/05/17 00:17:34  curt
917  * Trying to stub in support for standard OpenGL.
918  *
919  * Revision 1.1  1997/05/16 16:05:52  curt
920  * Initial revision.
921  *
922  */