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