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