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