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