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