]> git.mxchange.org Git - flightgear.git/blob - Main/GLUTmain.c
A couple lighting tweaks ...
[flightgear.git] / Main / GLUTmain.c
1 /**************************************************************************
2  * GLUTmain.c -- top level sim routines
3  *
4  * Written by Curtis Olson for OpenGL, started May 1997.
5  *
6  * Copyright (C) 1997  Curtis L. Olson  - curt@infoplane.com
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License as
10  * published by the Free Software Foundation; either version 2 of the
11  * License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  *
22  * $Id$
23  * (Log is kept at end of this file)
24  **************************************************************************/
25
26
27 #ifdef WIN32
28 #  include <windows.h>                     
29 #endif
30
31 #include <GL/glut.h>
32 #include "../XGL/xgl.h"
33 #include <stdio.h>
34
35 #include "GLUTkey.h"
36 #include "fg_init.h"
37 #include "views.h"
38
39 #include "../Include/constants.h"
40 #include "../Include/general.h"
41
42 #include "../Aircraft/aircraft.h"
43 #include "../Cockpit/cockpit.h"
44 #include "../Joystick/joystick.h"
45 #include "../Math/fg_geodesy.h"
46 #include "../Math/mat3.h"
47 #include "../Math/polar.h"
48 #include "../Scenery/mesh.h"
49 #include "../Scenery/moon.h"
50 #include "../Scenery/scenery.h"
51 #include "../Scenery/sky.h"
52 #include "../Scenery/stars.h"
53 #include "../Scenery/sun.h"
54 #include "../Time/fg_time.h"
55 #include "../Time/fg_timer.h"
56 #include "../Time/sunpos.h"
57 #include "../Weather/weather.h"
58
59
60 /* This is a record containing global housekeeping information */
61 struct fgGENERAL general;
62
63 /* view parameters */
64 static GLfloat win_ratio = 1.0;
65
66 /* temporary hack */
67 /* pointer to scenery structure */
68 /* static GLint scenery, runway; */
69
70 double Simtime;
71
72 /* Another hack */
73 int use_signals = 0;
74
75 /* Yet another hack. This one used by the HUD code. Michele */
76 int show_hud;
77
78
79 /**************************************************************************
80  * fgInitVisuals() -- Initialize various GL/view parameters
81  **************************************************************************/
82
83 static void fgInitVisuals() {
84     struct fgLIGHT *l;
85     struct fgTIME *t;
86     struct fgWEATHER *w;
87
88     l = &cur_light_params;
89     t = &cur_time_params;
90     w = &current_weather;
91
92     
93     /* xglDisable( GL_DITHER ); */
94
95     /* If enabled, normal vectors specified with glNormal are scaled
96        to unit length after transformation.  See glNormal. */
97     xglEnable( GL_NORMALIZE );
98
99     xglEnable( GL_LIGHTING );
100     xglEnable( GL_LIGHT0 );
101     xglLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec );
102
103     xglFogi (GL_FOG_MODE, GL_LINEAR);
104     /* xglFogf (GL_FOG_START, 1.0); */
105     xglFogf (GL_FOG_END, w->visibility);
106     /* xglFogf (GL_FOG_DENSITY, w->visibility); */
107     xglHint (GL_FOG_HINT, GL_NICEST /* GL_FASTEST */ );
108 }
109
110
111 /**************************************************************************
112  * Update the view volume, position, and orientation
113  **************************************************************************/
114
115 static void fgUpdateViewParams() {
116     struct fgFLIGHT *f;
117     struct fgLIGHT *l;
118     struct fgTIME *t;
119     struct fgVIEW *v;
120
121     double x_2, x_4, x_8, x_10;
122     double light, ambient, diffuse, sky_brightness;
123     /* if the 4th field is 0.0, this specifies a direction ... */
124     /* base sky color */
125     GLfloat base_sky_color[4] =        {0.60, 0.60, 0.90, 1.0};
126     /* base fog color */
127     GLfloat base_fog_color[4] = {0.70, 0.70, 0.70, 1.0};
128
129     GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 };
130
131     f = &current_aircraft.flight;
132     l = &cur_light_params;
133     t = &cur_time_params;
134     v = &current_view;
135
136     fgViewUpdate(f, v, l);
137
138     /* Tell GL we are about to modify the projection parameters */
139     xglMatrixMode(GL_PROJECTION);
140     xglLoadIdentity();
141     gluPerspective(55.0, 1.0/win_ratio, 1.0, 100000.0);
142
143     xglMatrixMode(GL_MODELVIEW);
144     xglLoadIdentity();
145     
146     /* set up our view volume (default) */
147     gluLookAt(v->view_pos.x, v->view_pos.y, v->view_pos.z,
148                v->view_pos.x + v->view_forward[0], 
149                v->view_pos.y + v->view_forward[1], 
150                v->view_pos.z + v->view_forward[2],
151                v->view_up[0], v->view_up[1], v->view_up[2]);
152
153     /* lock view horizontally towards sun (testing) */
154     /* gluLookAt(v->view_pos.x, v->view_pos.y, v->view_pos.z,
155                v->view_pos.x + v->surface_to_sun[0], 
156                v->view_pos.y + v->surface_to_sun[1], 
157                v->view_pos.z + v->surface_to_sun[2],
158                v->view_up[0], v->view_up[1], v->view_up[2]); */
159
160     /* lock view horizontally towards south (testing) */
161     /* gluLookAt(v->view_pos.x, v->view_pos.y, v->view_pos.z,
162                v->view_pos.x + v->surface_south[0], 
163                v->view_pos.y + v->surface_south[1], 
164                v->view_pos.z + v->surface_south[2],
165                v->view_up[0], v->view_up[1], v->view_up[2]); */
166
167     /* set the sun position */
168     xglLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec );
169
170     /* calculate lighting parameters based on sun's relative angle to
171      * local up */
172     /* ya kind'a have to plot this to see how it works */
173
174     /* x = t->sun_angle^8 */
175     x_2 = l->sun_angle * l->sun_angle;
176     x_4 = x_2 * x_2;
177     x_8 = x_4 * x_4;
178     x_10 = x_8 * x_2;
179
180     light = pow(1.1, -x_10 / 30.0);
181     ambient = 0.2 * light;
182     diffuse = 0.9 * light;
183
184     sky_brightness = 0.85 * pow(1.2, -x_8 / 20.0) + 0.15;
185
186     /* sky_brightness = 0.15; */ /* to force a dark sky (for testing) */
187
188     if ( ambient < 0.02 ) { ambient = 0.02; }
189     if ( diffuse < 0.0 ) { diffuse = 0.0; }
190
191     if ( sky_brightness < 0.1 ) { sky_brightness = 0.1; }
192
193     l->scene_ambient[0] = white[0] * ambient;
194     l->scene_ambient[1] = white[1] * ambient;
195     l->scene_ambient[2] = white[2] * ambient;
196
197     l->scene_diffuse[0] = white[0] * diffuse;
198     l->scene_diffuse[1] = white[1] * diffuse;
199     l->scene_diffuse[2] = white[2] * diffuse;
200
201     /* set fog color */
202     l->fog_color[0] = base_fog_color[0] * (ambient + diffuse);
203     l->fog_color[1] = base_fog_color[1] * (ambient + diffuse);
204     l->fog_color[2] = base_fog_color[2] * (ambient + diffuse);
205     l->fog_color[3] = base_fog_color[3];
206
207     /* set sky color */
208     l->sky_color[0] = base_sky_color[0] * sky_brightness;
209     l->sky_color[1] = base_sky_color[1] * sky_brightness;
210     l->sky_color[2] = base_sky_color[2] * sky_brightness;
211     l->sky_color[3] = base_sky_color[3];
212
213     /* mental note: this should really be done every 10-30 seconds I suppose */
214     fgSkyColorsInit();
215 }
216
217
218 /**************************************************************************
219  * Update all Visuals (redraws anything graphics related)
220  **************************************************************************/
221
222 static void fgRenderFrame( void ) {
223     struct fgLIGHT *l;
224     struct fgTIME *t;
225     struct fgVIEW *v;
226     double angle;
227     static double lastAstroUpdate = 0;
228     GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 };
229
230     l = &cur_light_params;
231     t = &cur_time_params;
232     v = &current_view;
233
234     /* update view volume parameters */
235     fgUpdateViewParams();
236
237     xglClear( GL_DEPTH_BUFFER_BIT /* | GL_COLOR_BUFFER_BIT */ );
238
239     /* Tell GL we are switching to model view parameters */
240     xglMatrixMode(GL_MODELVIEW);
241     /* xglLoadIdentity(); */
242
243     /* draw sky */
244     xglDisable( GL_DEPTH_TEST );
245     xglDisable( GL_LIGHTING );
246     xglDisable( GL_CULL_FACE );
247     xglDisable( GL_FOG );
248     xglShadeModel( GL_SMOOTH );
249     fgSkyRender();
250
251     /* a hack: Force sun and moon position to be updated on an hourly basis */
252     if (((t->gst - lastAstroUpdate) > 1) || (t->gst < lastAstroUpdate)) {
253         lastAstroUpdate = t->gst;
254         fgSunInit();
255         fgMoonInit();
256     }
257
258     /* setup transformation for drawing astronomical objects */
259     xglPushMatrix();
260     /* Translate to view position */
261     xglTranslatef( v->view_pos.x, v->view_pos.y, v->view_pos.z );
262     /* Rotate based on gst (side real time) */
263     angle = t->gst * 15.041085; /* should be 15.041085, Curt thought it was 15*/
264     /* printf("Rotating astro objects by %.2f degrees\n",angle); */
265     xglRotatef( angle, 0.0, 0.0, -1.0 );
266
267     /* draw stars and planets */
268     fgStarsRender();
269
270     /* draw the sun */
271     fgSunRender();
272
273     /* render the moon */
274     xglEnable( GL_LIGHTING );
275     /* set lighting parameters */
276     xglLightfv(GL_LIGHT0, GL_AMBIENT, white );
277     xglLightfv(GL_LIGHT0, GL_DIFFUSE, white );
278     xglEnable( GL_CULL_FACE );
279     fgMoonRender();
280
281     xglPopMatrix();
282
283     /* draw scenery */
284     xglShadeModel( GL_SMOOTH ); 
285     xglEnable( GL_DEPTH_TEST );
286     xglEnable( GL_FOG );
287     xglFogfv (GL_FOG_COLOR, l->fog_color);
288     /* set lighting parameters */
289     xglLightfv(GL_LIGHT0, GL_AMBIENT, l->scene_ambient );
290     xglLightfv(GL_LIGHT0, GL_DIFFUSE, l->scene_diffuse );
291     fgSceneryRender();
292
293     /* display HUD */
294     /* if( show_hud )
295         fgCockpitUpdate(); */
296
297     #ifdef GLUT
298       xglutSwapBuffers();
299     #endif
300 }
301
302
303 /**************************************************************************
304  * Update internal time dependent calculations (i.e. flight model)
305  **************************************************************************/
306
307 void fgUpdateTimeDepCalcs(int multi_loop) {
308     struct fgFLIGHT *f;
309     struct fgTIME *t;
310     struct fgVIEW *v;
311     int i;
312
313     f = &current_aircraft.flight;
314     t = &cur_time_params;
315     v = &current_view;
316
317     /* update the flight model */
318     if ( multi_loop < 0 ) {
319         multi_loop = DEFAULT_MULTILOOP;
320     }
321
322     /* printf("updating flight model x %d\n", multi_loop); */
323     fgFlightModelUpdate(FG_LARCSIM, f, multi_loop);
324
325     /* refresh shared sun position and sun_vec */
326     fgUpdateSunPos(scenery.center);
327
328     /* update the view angle */
329     for ( i = 0; i < multi_loop; i++ ) {
330         if ( fabs(v->goal_view_offset - v->view_offset) < 0.05 ) {
331             v->view_offset = v->goal_view_offset;
332             break;
333         } else {
334             /* move v->view_offset towards v->goal_view_offset */
335             if ( v->goal_view_offset > v->view_offset ) {
336                 if ( v->goal_view_offset - v->view_offset < FG_PI ) {
337                     v->view_offset += 0.01;
338                 } else {
339                     v->view_offset -= 0.01;
340                 }
341             } else {
342                 if ( v->view_offset - v->goal_view_offset < FG_PI ) {
343                     v->view_offset -= 0.01;
344                 } else {
345                     v->view_offset += 0.01;
346                 }
347             }
348             if ( v->view_offset > FG_2PI ) {
349                 v->view_offset -= FG_2PI;
350             } else if ( v->view_offset < 0 ) {
351                 v->view_offset += FG_2PI;
352             }
353         }
354     }
355 }
356
357
358 void fgInitTimeDepCalcs() {
359     /* initialize timer */
360
361 #ifdef USE_ITIMER
362     fgTimerInit( 1.0 / DEFAULT_TIMER_HZ, fgUpdateTimeDepCalcs );
363 #endif USE_ITIMER
364
365 }
366
367
368 /**************************************************************************
369  * Scenery management routines
370  **************************************************************************/
371
372 /* static void fgSceneryInit_OLD() { */
373     /* make scenery */
374 /*     scenery = fgSceneryCompile_OLD();
375     runway = fgRunwayHack_OLD(0.69, 53.07);
376 } */
377
378
379 /* create the scenery */
380 /* GLint fgSceneryCompile_OLD() {
381     GLint scenery;
382
383     scenery = mesh2GL(mesh_ptr_OLD);
384
385     return(scenery);
386 }
387 */
388
389 /* hack in a runway */
390 /* GLint fgRunwayHack_OLD(double width, double length) {
391     static GLfloat concrete[4] = { 0.5, 0.5, 0.5, 1.0 };
392     static GLfloat line[4]     = { 0.9, 0.9, 0.9, 1.0 };
393     int i;
394     int num_lines = 16;
395     float line_len, line_width_2, cur_pos;
396
397     runway = xglGenLists(1);
398     xglNewList(runway, GL_COMPILE);
399     */
400     /* draw concrete */
401 /*    xglBegin(GL_POLYGON);
402     xglMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, concrete );
403     xglNormal3f(0.0, 0.0, 1.0);
404
405     xglVertex3d( 0.0,   -width/2.0, 0.0);
406     xglVertex3d( 0.0,    width/2.0, 0.0);
407     xglVertex3d(length,  width/2.0, 0.0);
408     xglVertex3d(length, -width/2.0, 0.0);
409     xglEnd();
410     */
411     /* draw center line */
412 /*    xglMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, line );
413     line_len = length / ( 2 * num_lines + 1);
414     printf("line_len = %.3f\n", line_len);
415     line_width_2 = 0.02;
416     cur_pos = line_len;
417     for ( i = 0; i < num_lines; i++ ) {
418         xglBegin(GL_POLYGON);
419         xglVertex3d( cur_pos, -line_width_2, 0.005);
420         xglVertex3d( cur_pos,  line_width_2, 0.005);
421         cur_pos += line_len;
422         xglVertex3d( cur_pos,  line_width_2, 0.005);
423         xglVertex3d( cur_pos, -line_width_2, 0.005);
424         cur_pos += line_len;
425         xglEnd();
426     }
427
428     xglEndList();
429
430     return(runway);
431 }
432 */
433
434 /* draw the scenery */
435 /*static void fgSceneryDraw_OLD() {
436     static float z = 32.35;
437
438     xglPushMatrix();
439
440     xglCallList(scenery);
441
442     printf("*** Drawing runway at %.2f\n", z);
443
444     xglTranslatef( -398391.28, 120070.41, 32.35);
445     xglRotatef(170.0, 0.0, 0.0, 1.0);
446     xglCallList(runway);
447
448     xglPopMatrix();
449 }
450 */
451
452 /* What should we do when we have nothing else to do?  How about get
453  * ready for the next move and update the display? */
454 static void fgMainLoop( void ) {
455     static int remainder = 0;
456     int elapsed, multi_loop;
457     double cur_elev;
458     double joy_x, joy_y;
459     int joy_b1, joy_b2;
460     struct fgAIRCRAFT *a;
461     struct fgFLIGHT *f;
462     struct fgTIME *t;
463
464     a = &current_aircraft;
465     f = &a->flight;
466     t = &cur_time_params;
467
468     /* update "time" */
469     fgTimeUpdate(f, t);
470
471     /* Read joystick */
472     /* fgJoystickRead( &joy_x, &joy_y, &joy_b1, &joy_b2 );
473     printf( "Joystick X %f  Y %f  B1 %d  B2 %d\n",  
474             joy_x, joy_y, joy_b1, joy_b2 );
475     fgElevSet( -joy_y );
476     fgAileronSet( joy_x ); */
477
478     /* update the weather for our current position */
479     fgWeatherUpdate(FG_Longitude * RAD_TO_ARCSEC, 
480                     FG_Latitude * RAD_TO_ARCSEC, 
481                     FG_Altitude * FEET_TO_METER);
482
483     /* Calculate model iterations needed */
484     elapsed = fgGetTimeInterval();
485     printf("Time interval is = %d, previous remainder is = %d\n", elapsed, 
486            remainder);
487     printf("--> Frame rate is = %.2f\n", 1000.0 / (float)elapsed);
488     elapsed += remainder;
489
490     multi_loop = ((float)elapsed * 0.001) * DEFAULT_MODEL_HZ;
491     remainder = elapsed - ((multi_loop*1000) / DEFAULT_MODEL_HZ);
492     printf("Model iterations needed = %d, new remainder = %d\n", multi_loop, 
493            remainder);
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     fgAircraftOutputCurrent(a);
519
520     /* redraw display */
521     fgRenderFrame();
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     xglViewport(0, 0, (GLint)width, (GLint)height);
538
539     fgUpdateViewParams();
540     
541     /* xglClear( 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 fgFLIGHT *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       xglutInit(&argc, argv);
563
564       /* Define Display Parameters */
565       xglutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
566
567       /* Define initial window size */
568       xglutInitWindowSize(640, 480);
569
570       /* Initialize windows */
571       xglutCreateWindow("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       xglutReshapeFunc( fgReshape );
599
600       /* call key() on keyboard event */
601       xglutKeyboardFunc( GLUTkey );
602       glutSpecialFunc( GLUTspecialkey );
603
604       /* call fgMainLoop() whenever there is nothing else to do */
605       xglutIdleFunc( fgMainLoop );
606
607       /* draw the scene */
608       xglutDisplayFunc( fgRenderFrame );
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.41  1997/12/30 13:06:56  curt
627 /* A couple lighting tweaks ...
628 /*
629  * Revision 1.40  1997/12/30 01:38:37  curt
630  * Switched back to per vertex normals and smooth shading for terrain.
631  *
632  * Revision 1.39  1997/12/22 23:45:45  curt
633  * First stab at sunset/sunrise sky glow effects.
634  *
635  * Revision 1.38  1997/12/22 04:14:28  curt
636  * Aligned sky with sun so dusk/dawn effects can be correct relative to the sun.
637  *
638  * Revision 1.37  1997/12/19 23:34:03  curt
639  * Lot's of tweaking with sky rendering and lighting.
640  *
641  * Revision 1.36  1997/12/19 16:44:57  curt
642  * Working on scene rendering order and options.
643  *
644  * Revision 1.35  1997/12/18 23:32:32  curt
645  * First stab at sky dome actually starting to look reasonable. :-)
646  *
647  * Revision 1.34  1997/12/17 23:13:34  curt
648  * Began working on rendering a sky.
649  *
650  * Revision 1.33  1997/12/15 23:54:45  curt
651  * Add xgl wrappers for debugging.
652  * Generate terrain normals on the fly.
653  *
654  * Revision 1.32  1997/12/15 20:59:08  curt
655  * Misc. tweaks.
656  *
657  * Revision 1.31  1997/12/12 21:41:25  curt
658  * More light/material property tweaking ... still a ways off.
659  *
660  * Revision 1.30  1997/12/12 19:52:47  curt
661  * Working on lightling and material properties.
662  *
663  * Revision 1.29  1997/12/11 04:43:54  curt
664  * Fixed sun vector and lighting problems.  I thing the moon is now lit
665  * correctly.
666  *
667  * Revision 1.28  1997/12/10 22:37:45  curt
668  * Prepended "fg" on the name of all global structures that didn't have it yet.
669  * i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
670  *
671  * Revision 1.27  1997/12/09 05:11:54  curt
672  * Working on tweaking lighting.
673  *
674  * Revision 1.26  1997/12/09 04:25:29  curt
675  * Working on adding a global lighting params structure.
676  *
677  * Revision 1.25  1997/12/08 22:54:09  curt
678  * Enabled GL_CULL_FACE.
679  *
680  * Revision 1.24  1997/11/25 19:25:32  curt
681  * Changes to integrate Durk's moon/sun code updates + clean up.
682  *
683  * Revision 1.23  1997/11/15 18:16:34  curt
684  * minor tweaks.
685  *
686  * Revision 1.22  1997/10/30 12:38:41  curt
687  * Working on new scenery subsystem.
688  *
689  * Revision 1.21  1997/09/23 00:29:38  curt
690  * Tweaks to get things to compile with gcc-win32.
691  *
692  * Revision 1.20  1997/09/22 14:44:19  curt
693  * Continuing to try to align stars correctly.
694  *
695  * Revision 1.19  1997/09/18 16:20:08  curt
696  * At dusk/dawn add/remove stars in stages.
697  *
698  * Revision 1.18  1997/09/16 22:14:51  curt
699  * Tweaked time of day lighting equations.  Don't draw stars during the day.
700  *
701  * Revision 1.17  1997/09/16 15:50:29  curt
702  * Working on star alignment and time issues.
703  *
704  * Revision 1.16  1997/09/13 02:00:06  curt
705  * Mostly working on stars and generating sidereal time for accurate star
706  * placement.
707  *
708  * Revision 1.15  1997/09/05 14:17:27  curt
709  * More tweaking with stars.
710  *
711  * Revision 1.14  1997/09/05 01:35:53  curt
712  * Working on getting stars right.
713  *
714  * Revision 1.13  1997/09/04 02:17:34  curt
715  * Shufflin' stuff.
716  *
717  * Revision 1.12  1997/08/27 21:32:24  curt
718  * Restructured view calculation code.  Added stars.
719  *
720  * Revision 1.11  1997/08/27 03:30:16  curt
721  * Changed naming scheme of basic shared structures.
722  *
723  * Revision 1.10  1997/08/25 20:27:22  curt
724  * Merged in initial HUD and Joystick code.
725  *
726  * Revision 1.9  1997/08/22 21:34:39  curt
727  * Doing a bit of reorganizing and house cleaning.
728  *
729  * Revision 1.8  1997/08/19 23:55:03  curt
730  * Worked on better simulating real lighting.
731  *
732  * Revision 1.7  1997/08/16 12:22:38  curt
733  * Working on improving the lighting/shading.
734  *
735  * Revision 1.6  1997/08/13 20:24:56  curt
736  * Changes due to changing sunpos interface.
737  *
738  * Revision 1.5  1997/08/06 21:08:32  curt
739  * Sun position now *really* works (I think) ... I still have sun time warping
740  * code in place, probably should remove it soon.
741  *
742  * Revision 1.4  1997/08/06 15:41:26  curt
743  * Working on correct sun position.
744  *
745  * Revision 1.3  1997/08/06 00:24:22  curt
746  * Working on correct real time sun lighting.
747  *
748  * Revision 1.2  1997/08/04 20:25:15  curt
749  * Organizational tweaking.
750  *
751  * Revision 1.1  1997/08/02 18:45:00  curt
752  * Renamed GLmain.c GLUTmain.c
753  *
754  * Revision 1.43  1997/08/02 16:23:47  curt
755  * Misc. tweaks.
756  *
757  * Revision 1.42  1997/08/01 19:43:33  curt
758  * Making progress with coordinate system overhaul.
759  *
760  * Revision 1.41  1997/07/31 22:52:37  curt
761  * Working on redoing internal coordinate systems & scenery transformations.
762  *
763  * Revision 1.40  1997/07/30 16:12:42  curt
764  * Moved fg_random routines from Util/ to Math/
765  *
766  * Revision 1.39  1997/07/21 14:45:01  curt
767  * Minor tweaks.
768  *
769  * Revision 1.38  1997/07/19 23:04:47  curt
770  * Added an initial weather section.
771  *
772  * Revision 1.37  1997/07/19 22:34:02  curt
773  * Moved PI definitions to ../constants.h
774  * Moved random() stuff to ../Utils/ and renamed fg_random()
775  *
776  * Revision 1.36  1997/07/18 23:41:25  curt
777  * Tweaks for building with Cygnus Win32 compiler.
778  *
779  * Revision 1.35  1997/07/18 14:28:34  curt
780  * Hacked in some support for wind/turbulence.
781  *
782  * Revision 1.34  1997/07/16 20:04:48  curt
783  * Minor tweaks to aid Win32 port.
784  *
785  * Revision 1.33  1997/07/12 03:50:20  curt
786  * Added an #include <Windows32/Base.h> to help compiling for Win32
787  *
788  * Revision 1.32  1997/07/11 03:23:18  curt
789  * Solved some scenery display/orientation problems.  Still have a positioning
790  * (or transformation?) problem.
791  *
792  * Revision 1.31  1997/07/11 01:29:58  curt
793  * More tweaking of terrian floor.
794  *
795  * Revision 1.30  1997/07/10 04:26:37  curt
796  * We now can interpolated ground elevation for any position in the grid.  We
797  * can use this to enforce a "hard" ground.  We still need to enforce some
798  * bounds checking so that we don't try to lookup data points outside the
799  * grid data set.
800  *
801  * Revision 1.29  1997/07/09 21:31:12  curt
802  * Working on making the ground "hard."
803  *
804  * Revision 1.28  1997/07/08 18:20:12  curt
805  * Working on establishing a hard ground.
806  *
807  * Revision 1.27  1997/07/07 20:59:49  curt
808  * Working on scenery transformations to enable us to fly fluidly over the
809  * poles with no discontinuity/distortion in scenery.
810  *
811  * Revision 1.26  1997/07/05 20:43:34  curt
812  * renamed mat3 directory to Math so we could add other math related routines.
813  *
814  * Revision 1.25  1997/06/29 21:19:17  curt
815  * Working on scenery management system.
816  *
817  * Revision 1.24  1997/06/26 22:14:53  curt
818  * Beginning work on a scenery management system.
819  *
820  * Revision 1.23  1997/06/26 19:08:33  curt
821  * Restructuring make, adding automatic "make dep" support.
822  *
823  * Revision 1.22  1997/06/25 15:39:47  curt
824  * Minor changes to compile with rsxnt/win32.
825  *
826  * Revision 1.21  1997/06/22 21:44:41  curt
827  * Working on intergrating the VRML (subset) parser.
828  *
829  * Revision 1.20  1997/06/21 17:12:53  curt
830  * Capitalized subdirectory names.
831  *
832  * Revision 1.19  1997/06/18 04:10:31  curt
833  * A couple more runway tweaks ...
834  *
835  * Revision 1.18  1997/06/18 02:21:24  curt
836  * Hacked in a runway
837  *
838  * Revision 1.17  1997/06/17 16:51:58  curt
839  * Timer interval stuff now uses gettimeofday() instead of ftime()
840  *
841  * Revision 1.16  1997/06/17 04:19:16  curt
842  * More timer related tweaks with respect to view direction changes.
843  *
844  * Revision 1.15  1997/06/17 03:41:10  curt
845  * Nonsignal based interval timing is now working.
846  * This would be a good time to look at cleaning up the code structure a bit.
847  *
848  * Revision 1.14  1997/06/16 19:32:51  curt
849  * Starting to add general timer support.
850  *
851  * Revision 1.13  1997/06/02 03:40:06  curt
852  * A tiny bit more view tweaking.
853  *
854  * Revision 1.12  1997/06/02 03:01:38  curt
855  * Working on views (side, front, back, transitions, etc.)
856  *
857  * Revision 1.11  1997/05/31 19:16:25  curt
858  * Elevator trim added.
859  *
860  * Revision 1.10  1997/05/31 04:13:52  curt
861  * WE CAN NOW FLY!!!
862  *
863  * Continuing work on the LaRCsim flight model integration.
864  * Added some MSFS-like keyboard input handling.
865  *
866  * Revision 1.9  1997/05/30 19:27:01  curt
867  * The LaRCsim flight model is starting to look like it is working.
868  *
869  * Revision 1.8  1997/05/30 03:54:10  curt
870  * Made a bit more progress towards integrating the LaRCsim flight model.
871  *
872  * Revision 1.7  1997/05/29 22:39:49  curt
873  * Working on incorporating the LaRCsim flight model.
874  *
875  * Revision 1.6  1997/05/29 12:31:39  curt
876  * Minor tweaks, moving towards general flight model integration.
877  *
878  * Revision 1.5  1997/05/29 02:33:23  curt
879  * Updated to reflect changing interfaces in other "modules."
880  *
881  * Revision 1.4  1997/05/27 17:44:31  curt
882  * Renamed & rearranged variables and routines.   Added some initial simple
883  * timer/alarm routines so the flight model can be updated on a regular 
884  * interval.
885  *
886  * Revision 1.3  1997/05/23 15:40:25  curt
887  * Added GNU copyright headers.
888  * Fog now works!
889  *
890  * Revision 1.2  1997/05/23 00:35:12  curt
891  * Trying to get fog to work ...
892  *
893  * Revision 1.1  1997/05/21 15:57:51  curt
894  * Renamed due to added GLUT support.
895  *
896  * Revision 1.3  1997/05/19 18:22:42  curt
897  * Parameter tweaking ... starting to stub in fog support.
898  *
899  * Revision 1.2  1997/05/17 00:17:34  curt
900  * Trying to stub in support for standard OpenGL.
901  *
902  * Revision 1.1  1997/05/16 16:05:52  curt
903  * Initial revision.
904  *
905  */