]> git.mxchange.org Git - flightgear.git/blob - Main/views.cxx
Added ground collision detection.
[flightgear.git] / Main / views.cxx
1 // views.cxx -- data structures and routines for managing and view
2 //               parameters.
3 //
4 // Written by Curtis Olson, started August 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 #ifdef HAVE_CONFIG_H
27 #  include <config.h>
28 #endif
29
30 #include <Debug/fg_debug.h>
31 #include <Flight/flight.h>
32 #include <Include/fg_constants.h>
33 #include <Math/mat3.h>
34 #include <Math/polar3d.hxx>
35 #include <Math/vector.hxx>
36 #include <Scenery/scenery.hxx>
37 #include <Time/fg_time.hxx>
38
39 #include "options.hxx"
40 #include "views.hxx"
41
42
43 // This is a record containing current view parameters
44 fgVIEW current_view;
45
46
47 // Constructor
48 fgVIEW::fgVIEW( void ) {
49 }
50
51
52 // Initialize a view structure
53 void fgVIEW::Init( void ) {
54     fgPrintf( FG_VIEW, FG_INFO, "Initializing View parameters\n");
55
56     view_offset = 0.0;
57     goal_view_offset = 0.0;
58
59     winWidth = 640;  // FG_DEFAULT_WIN_WIDTH
60     winHeight = 480; // FG_DEFAULT_WIN_HEIGHT
61     win_ratio = (double) winWidth / (double) winHeight;
62     update_fov = TRUE;
63 }
64
65
66 // Update the field of view parameters
67 void fgVIEW::UpdateFOV( fgOPTIONS *o ) {
68     double theta_x, theta_y;
69         
70     // printf("win_ratio = %.2f\n", win_ratio);
71     // calculate sin() and cos() of fov / 2 in X direction;
72     theta_x = (o->fov * win_ratio * DEG_TO_RAD) / 2.0;
73     // printf("theta_x = %.2f\n", theta_x);
74     sin_fov_x = sin(theta_x);
75     cos_fov_x = cos(theta_x);
76     slope_x =  - cos_fov_x / sin_fov_x;
77     // printf("slope_x = %.2f\n", slope_x);
78
79     // calculate sin() and cos() of fov / 2 in Y direction;
80     theta_y = (o->fov * DEG_TO_RAD) / 2.0;
81     // printf("theta_y = %.2f\n", theta_y);
82     sin_fov_y = sin(theta_y);
83     cos_fov_y = cos(theta_y);
84     slope_y = cos_fov_y / sin_fov_y;
85     // printf("slope_y = %.2f\n", slope_y);
86 }
87
88
89 // Update the view parameters
90 void fgVIEW::Update( fgFLIGHT *f ) {
91     fgOPTIONS *o;
92     fgPoint3d p;
93     MAT3vec vec, forward, v0, minus_z;
94     MAT3mat R, TMP, UP, LOCAL, VIEW;
95     double ntmp;
96
97     o = &current_options;
98
99     if(update_fov == TRUE) {
100         // printf("Updating fov\n");
101         UpdateFOV(o);
102         update_fov = FALSE;
103     }
104                 
105     scenery.center.x = scenery.next_center.x;
106     scenery.center.y = scenery.next_center.y;
107     scenery.center.z = scenery.next_center.z;
108
109     // printf("scenery center = %.2f %.2f %.2f\n", scenery.center.x,
110     //        scenery.center.y, scenery.center.z);
111
112     // calculate the cartesion coords of the current lat/lon/0 elev
113     p.lon = FG_Longitude;
114     p.lat = FG_Lat_geocentric;
115     p.radius = FG_Sea_level_radius * FEET_TO_METER;
116
117     cur_zero_elev = fgPolarToCart3d(p);
118
119     cur_zero_elev.x -= scenery.center.x;
120     cur_zero_elev.y -= scenery.center.y;
121     cur_zero_elev.z -= scenery.center.z;
122
123     // calculate view position in current FG view coordinate system
124     // p.lon & p.lat are already defined earlier, p.radius was set to
125     // the sea level radius, so now we add in our altitude.
126     if ( FG_Altitude * FEET_TO_METER > 
127          (scenery.cur_elev + 3.758099 * METER_TO_FEET) ) {
128         p.radius += FG_Altitude * FEET_TO_METER;
129     } else {
130         p.radius += scenery.cur_elev + 3.758099 * METER_TO_FEET;
131     }
132
133     abs_view_pos = fgPolarToCart3d(p);
134
135     view_pos.x = abs_view_pos.x - scenery.center.x;
136     view_pos.y = abs_view_pos.y - scenery.center.y;
137     view_pos.z = abs_view_pos.z - scenery.center.z;
138
139     fgPrintf( FG_VIEW, FG_DEBUG, "Absolute view pos = %.4f, %.4f, %.4f\n", 
140            abs_view_pos.x, abs_view_pos.y, abs_view_pos.z);
141     fgPrintf( FG_VIEW, FG_DEBUG, "Relative view pos = %.4f, %.4f, %.4f\n", 
142            view_pos.x, view_pos.y, view_pos.z);
143
144     // Derive the LOCAL aircraft rotation matrix (roll, pitch, yaw)
145     // from FG_T_local_to_body[3][3]
146
147     // Question: Why is the LaRCsim matrix arranged so differently
148     // than the one we need???
149     LOCAL[0][0] = FG_T_local_to_body_33;
150     LOCAL[0][1] = -FG_T_local_to_body_32;
151     LOCAL[0][2] = -FG_T_local_to_body_31;
152     LOCAL[0][3] = 0.0;
153     LOCAL[1][0] = -FG_T_local_to_body_23;
154     LOCAL[1][1] = FG_T_local_to_body_22;
155     LOCAL[1][2] = FG_T_local_to_body_21;
156     LOCAL[1][3] = 0.0;
157     LOCAL[2][0] = -FG_T_local_to_body_13;
158     LOCAL[2][1] = FG_T_local_to_body_12;
159     LOCAL[2][2] = FG_T_local_to_body_11;
160     LOCAL[2][3] = 0.0;
161     LOCAL[3][0] = LOCAL[3][1] = LOCAL[3][2] = LOCAL[3][3] = 0.0;
162     LOCAL[3][3] = 1.0;
163     // printf("LaRCsim LOCAL matrix\n");
164     // MAT3print(LOCAL, stdout);
165
166 #ifdef OLD_LOCAL_TO_BODY_CODE
167         // old code to calculate LOCAL matrix calculated from Phi,
168         // Theta, and Psi (roll, pitch, yaw)
169
170         MAT3_SET_VEC(vec, 0.0, 0.0, 1.0);
171         MAT3rotate(R, vec, FG_Phi);
172         /* printf("Roll matrix\n"); */
173         /* MAT3print(R, stdout); */
174
175         MAT3_SET_VEC(vec, 0.0, 1.0, 0.0);
176         /* MAT3mult_vec(vec, vec, R); */
177         MAT3rotate(TMP, vec, FG_Theta);
178         /* printf("Pitch matrix\n"); */
179         /* MAT3print(TMP, stdout); */
180         MAT3mult(R, R, TMP);
181
182         MAT3_SET_VEC(vec, 1.0, 0.0, 0.0);
183         /* MAT3mult_vec(vec, vec, R); */
184         /* MAT3rotate(TMP, vec, FG_Psi - FG_PI_2); */
185         MAT3rotate(TMP, vec, -FG_Psi);
186         /* printf("Yaw matrix\n");
187            MAT3print(TMP, stdout); */
188         MAT3mult(LOCAL, R, TMP);
189         // printf("FG derived LOCAL matrix\n");
190         // MAT3print(LOCAL, stdout);
191 #endif // OLD_LOCAL_TO_BODY_CODE
192
193     // Derive the local UP transformation matrix based on *geodetic*
194     // coordinates
195     MAT3_SET_VEC(vec, 0.0, 0.0, 1.0);
196     MAT3rotate(R, vec, FG_Longitude);     // R = rotate about Z axis
197     // printf("Longitude matrix\n");
198     // MAT3print(R, stdout);
199
200     MAT3_SET_VEC(vec, 0.0, 1.0, 0.0);
201     MAT3mult_vec(vec, vec, R);
202     MAT3rotate(TMP, vec, -FG_Latitude);  // TMP = rotate about X axis
203     // printf("Latitude matrix\n");
204     // MAT3print(TMP, stdout);
205
206     MAT3mult(UP, R, TMP);
207     // printf("Local up matrix\n");
208     // MAT3print(UP, stdout);
209
210     MAT3_SET_VEC(local_up, 1.0, 0.0, 0.0);
211     MAT3mult_vec(local_up, local_up, UP);
212
213     // printf( "Local Up = (%.4f, %.4f, %.4f)\n",
214     //         local_up[0], local_up[1], local_up[2]);
215     
216     // Alternative method to Derive local up vector based on
217     // *geodetic* coordinates
218     // alt_up = fgPolarToCart(FG_Longitude, FG_Latitude, 1.0);
219     // printf( "    Alt Up = (%.4f, %.4f, %.4f)\n", 
220     //         alt_up.x, alt_up.y, alt_up.z);
221
222     // Calculate the VIEW matrix
223     MAT3mult(VIEW, LOCAL, UP);
224     // printf("VIEW matrix\n");
225     // MAT3print(VIEW, stdout);
226
227     // generate the current up, forward, and fwrd-view vectors
228     MAT3_SET_VEC(vec, 1.0, 0.0, 0.0);
229     MAT3mult_vec(view_up, vec, VIEW);
230
231     MAT3_SET_VEC(vec, 0.0, 0.0, 1.0);
232     MAT3mult_vec(forward, vec, VIEW);
233     // printf( "Forward vector is (%.2f,%.2f,%.2f)\n", forward[0], forward[1], 
234     //         forward[2]);
235
236     MAT3rotate(TMP, view_up, view_offset);
237     MAT3mult_vec(view_forward, forward, TMP);
238
239     // make a vector to the current view position
240     MAT3_SET_VEC(v0, view_pos.x, view_pos.y, view_pos.z);
241
242     // Given a vector pointing straight down (-Z), map into onto the
243     // local plane representing "horizontal".  This should give us the
244     // local direction for moving "south".
245     MAT3_SET_VEC(minus_z, 0.0, 0.0, -1.0);
246     map_vec_onto_cur_surface_plane(local_up, v0, minus_z, surface_south);
247     MAT3_NORMALIZE_VEC(surface_south, ntmp);
248     // printf( "Surface direction directly south %.2f %.2f %.2f\n",
249     //         surface_south[0], surface_south[1], surface_south[2]);
250
251     // now calculate the surface east vector
252     MAT3rotate(TMP, view_up, FG_PI_2);
253     MAT3mult_vec(surface_east, surface_south, TMP);
254     // printf( "Surface direction directly east %.2f %.2f %.2f\n",
255     //         surface_east[0], surface_east[1], surface_east[2]);
256     // printf( "Should be close to zero = %.2f\n", 
257     //         MAT3_DOT_PRODUCT(surface_south, surface_east));
258 }
259
260
261 // Update the "World to Eye" transformation matrix
262 // This is most useful for view frustum culling
263 void fgVIEW::UpdateWorldToEye( fgFLIGHT *f ) {
264     MAT3mat R_Phi, R_Theta, R_Psi, R_Lat, R_Lon, T_view;
265     MAT3mat TMP;
266     MAT3hvec vec;
267
268     // if we have a view offset use slow way for now
269     if(fabs(view_offset)>FG_EPSILON){ 
270         // Roll Matrix
271         MAT3_SET_HVEC(vec, 0.0, 0.0, -1.0, 1.0);
272         MAT3rotate(R_Phi, vec, FG_Phi);
273         // printf("Roll matrix (Phi)\n");
274         // MAT3print(R_Phi, stdout);
275
276         // Pitch Matrix
277         MAT3_SET_HVEC(vec, 1.0, 0.0, 0.0, 1.0);
278         MAT3rotate(R_Theta, vec, FG_Theta);
279         // printf("\nPitch matrix (Theta)\n");
280         // MAT3print(R_Theta, stdout);
281
282         // Yaw Matrix
283         MAT3_SET_HVEC(vec, 0.0, -1.0, 0.0, 1.0);
284         MAT3rotate(R_Psi, vec, FG_Psi + FG_PI - view_offset );
285         // printf("\nYaw matrix (Psi)\n");
286         // MAT3print(R_Psi, stdout);
287
288         // aircraft roll/pitch/yaw
289         MAT3mult(TMP, R_Phi, R_Theta);
290         MAT3mult(AIRCRAFT, TMP, R_Psi);
291
292     } else { // JUST USE LOCAL_TO_BODY  NHV 5/25/98
293         // hey this is even different then LOCAL[][] above ??
294          
295         AIRCRAFT[0][0] = -FG_T_local_to_body_22;
296         AIRCRAFT[0][1] = -FG_T_local_to_body_23;
297         AIRCRAFT[0][2] = FG_T_local_to_body_21;
298         AIRCRAFT[0][3] = 0.0;
299         AIRCRAFT[1][0] = FG_T_local_to_body_32;
300         AIRCRAFT[1][1] = FG_T_local_to_body_33;
301         AIRCRAFT[1][2] = -FG_T_local_to_body_31;
302         AIRCRAFT[1][3] = 0.0;
303         AIRCRAFT[2][0] = FG_T_local_to_body_12;
304         AIRCRAFT[2][1] = FG_T_local_to_body_13;
305         AIRCRAFT[2][2] = -FG_T_local_to_body_11;
306         AIRCRAFT[2][3] = 0.0;
307         AIRCRAFT[3][0] = AIRCRAFT[3][1] = AIRCRAFT[3][2] = AIRCRAFT[3][3] = 0.0;
308         AIRCRAFT[3][3] = 1.0;
309
310         // ??? SOMETHING LIKE THIS SHOULD WORK    NHV
311         // Rotate about LOCAL_UP  (AIRCRAFT[2][])
312         // MAT3_SET_HVEC(vec, AIRCRAFT[2][0], AIRCRAFT[2][1],
313         //                        AIRCRAFT[2][2], AIRCRAFT[2][3]);
314         // MAT3rotate(TMP, vec, FG_PI - view_offset );
315         // MAT3mult(AIRCRAFT, AIRCRAFT, TMP);
316     }
317     // printf("\naircraft roll pitch yaw\n");
318     // MAT3print(AIRCRAFT, stdout);
319
320     // View position in scenery centered coordinates
321     MAT3_SET_HVEC(vec, view_pos.x, view_pos.y, view_pos.z, 1.0);
322     MAT3translate(T_view, vec);
323     // printf("\nTranslation matrix\n");
324     // MAT3print(T_view, stdout);
325
326     // Latitude
327     MAT3_SET_HVEC(vec, 1.0, 0.0, 0.0, 1.0);
328     // R_Lat = rotate about X axis
329     MAT3rotate(R_Lat, vec, FG_Latitude);
330     // printf("\nLatitude matrix\n");
331     // MAT3print(R_Lat, stdout);
332
333     // Longitude
334     MAT3_SET_HVEC(vec, 0.0, 0.0, 1.0, 1.0);
335     // R_Lon = rotate about Z axis
336     MAT3rotate(R_Lon, vec, FG_Longitude - FG_PI_2 );
337     // printf("\nLongitude matrix\n");
338     // MAT3print(R_Lon, stdout);
339
340 #ifdef THIS_IS_OLD_CODE
341     // View position in scenery centered coordinates
342     MAT3_SET_HVEC(vec, view_pos.x, view_pos.y, view_pos.z, 1.0);
343     MAT3translate(T_view, vec);
344     // printf("\nTranslation matrix\n");
345     // MAT3print(T_view, stdout);
346
347     // aircraft roll/pitch/yaw
348     MAT3mult(TMP, R_Phi, R_Theta);
349     MAT3mult(AIRCRAFT, TMP, R_Psi);
350     // printf("\naircraft roll pitch yaw\n");
351     // MAT3print(AIRCRAFT, stdout);
352 #endif THIS_IS_OLD_CODE
353
354     // lon/lat
355     MAT3mult(WORLD, R_Lat, R_Lon);
356     // printf("\nworld\n");
357     // MAT3print(WORLD, stdout);
358
359     MAT3mult(EYE_TO_WORLD, AIRCRAFT, WORLD);
360     MAT3mult(EYE_TO_WORLD, EYE_TO_WORLD, T_view);
361     // printf("\nEye to world\n");
362     // MAT3print(EYE_TO_WORLD, stdout);
363
364     MAT3invert(WORLD_TO_EYE, EYE_TO_WORLD);
365     // printf("\nWorld to eye\n");
366     // MAT3print(WORLD_TO_EYE, stdout);
367
368     // printf( "\nview_pos = %.2f %.2f %.2f\n", 
369     //         view_pos.x, view_pos.y, view_pos.z );
370
371     // MAT3_SET_HVEC(eye, 0.0, 0.0, 0.0, 1.0);
372     // MAT3mult_vec(vec, eye, EYE_TO_WORLD);
373     // printf("\neye -> world = %.2f %.2f %.2f\n", vec[0], vec[1], vec[2]);
374
375     // MAT3_SET_HVEC(vec1, view_pos.x, view_pos.y, view_pos.z, 1.0);
376     // MAT3mult_vec(vec, vec1, WORLD_TO_EYE);
377     // printf( "\nabs_view_pos -> eye = %.2f %.2f %.2f\n", 
378     //         vec[0], vec[1], vec[2]);
379 }
380
381
382 // Destructor
383 fgVIEW::~fgVIEW( void ) {
384 }
385
386
387 // Basically, this is a modified version of the Mesa gluLookAt()
388 // function that's been modified slightly so we can capture the result
389 // before sending it off to OpenGL land.
390 void fg_gluLookAt( GLdouble eyex, GLdouble eyey, GLdouble eyez,
391                    GLdouble centerx, GLdouble centery, GLdouble centerz,
392                    GLdouble upx, GLdouble upy, GLdouble upz )
393 {
394     GLdouble *m;
395     GLdouble x[3], y[3], z[3];
396     GLdouble mag;
397
398     m = current_view.MODEL_VIEW;
399
400     /* Make rotation matrix */
401
402     /* Z vector */
403     z[0] = eyex - centerx;
404     z[1] = eyey - centery;
405     z[2] = eyez - centerz;
406     mag = sqrt( z[0]*z[0] + z[1]*z[1] + z[2]*z[2] );
407     if (mag) {  /* mpichler, 19950515 */
408         z[0] /= mag;
409         z[1] /= mag;
410         z[2] /= mag;
411     }
412
413     /* Y vector */
414     y[0] = upx;
415     y[1] = upy;
416     y[2] = upz;
417
418     /* X vector = Y cross Z */
419     x[0] =  y[1]*z[2] - y[2]*z[1];
420     x[1] = -y[0]*z[2] + y[2]*z[0];
421     x[2] =  y[0]*z[1] - y[1]*z[0];
422     
423     /* Recompute Y = Z cross X */
424     y[0] =  z[1]*x[2] - z[2]*x[1];
425     y[1] = -z[0]*x[2] + z[2]*x[0];
426     y[2] =  z[0]*x[1] - z[1]*x[0];
427
428     /* mpichler, 19950515 */
429     /* cross product gives area of parallelogram, which is < 1.0 for
430      * non-perpendicular unit-length vectors; so normalize x, y here
431      */
432
433     mag = sqrt( x[0]*x[0] + x[1]*x[1] + x[2]*x[2] );
434     if (mag) {
435         x[0] /= mag;
436         x[1] /= mag;
437       x[2] /= mag;
438     }
439
440     mag = sqrt( y[0]*y[0] + y[1]*y[1] + y[2]*y[2] );
441     if (mag) {
442         y[0] /= mag;
443         y[1] /= mag;
444         y[2] /= mag;
445     }
446
447 #define M(row,col)  m[col*4+row]
448     M(0,0) = x[0];  M(0,1) = x[1];  M(0,2) = x[2];  M(0,3) = 0.0;
449     M(1,0) = y[0];  M(1,1) = y[1];  M(1,2) = y[2];  M(1,3) = 0.0;
450     M(2,0) = z[0];  M(2,1) = z[1];  M(2,2) = z[2];  M(2,3) = 0.0;
451     M(3,0) = 0.0;   M(3,1) = 0.0;   M(3,2) = 0.0;   M(3,3) = 1.0;
452 #undef M
453
454     // Translate Eye to Origin
455     // replaces: glTranslated( -eyex, -eyey, -eyez );
456     m[12] = m[0] * -eyex + m[4] * -eyey + m[8]  * -eyez + m[12];
457     m[13] = m[1] * -eyex + m[5] * -eyey + m[9]  * -eyez + m[13];
458     m[14] = m[2] * -eyex + m[6] * -eyey + m[10] * -eyez + m[14];
459     m[15] = m[3] * -eyex + m[7] * -eyey + m[11] * -eyez + m[15];
460
461     // xglMultMatrixd( m );
462     xglLoadMatrixd( m );
463 }
464
465
466 // $Log$
467 // Revision 1.15  1998/07/12 03:14:43  curt
468 // Added ground collision detection.
469 // Did some serious horsing around to be able to "hug" the ground properly
470 //   and still be able to take off.
471 // Set the near clip plane to 1.0 meters when less than 10 meters above the
472 //   ground.
473 // Did some serious horsing around getting the initial airplane position to be
474 //   correct based on rendered terrain elevation.
475 // Added a little cheat/hack that will prevent the view position from ever
476 //   dropping below the terrain, even when the flight model doesn't quite
477 //   put you as high as you'd like.
478 //
479 // Revision 1.14  1998/07/08 14:45:08  curt
480 // polar3d.h renamed to polar3d.hxx
481 // vector.h renamed to vector.hxx
482 // updated audio support so it waits to create audio classes (and tie up
483 //   /dev/dsp) until the mpg123 player is finished.
484 //
485 // Revision 1.13  1998/07/04 00:52:27  curt
486 // Add my own version of gluLookAt() (which is nearly identical to the
487 // Mesa/glu version.)  But, by calculating the Model View matrix our selves
488 // we can save this matrix without having to read it back in from the video
489 // card.  This hopefully allows us to save a few cpu cycles when rendering
490 // out the fragments because we can just use glLoadMatrixd() with the
491 // precalculated matrix for each tile rather than doing a push(), translate(),
492 // pop() for every fragment.
493 //
494 // Panel status defaults to off for now until it gets a bit more developed.
495 //
496 // Extract OpenGL driver info on initialization.
497 //
498 // Revision 1.12  1998/06/03 00:47:15  curt
499 // Updated to compile in audio support if OSS available.
500 // Updated for new version of Steve's audio library.
501 // STL includes don't use .h
502 // Small view optimizations.
503 //
504 // Revision 1.11  1998/05/27 02:24:05  curt
505 // View optimizations by Norman Vine.
506 //
507 // Revision 1.10  1998/05/17 16:59:03  curt
508 // First pass at view frustum culling now operational.
509 //
510 // Revision 1.9  1998/05/16 13:08:37  curt
511 // C++ - ified views.[ch]xx
512 // Shuffled some additional view parameters into the fgVIEW class.
513 // Changed tile-radius to tile-diameter because it is a much better
514 //   name.
515 // Added a WORLD_TO_EYE transformation to views.cxx.  This allows us
516 //  to transform world space to eye space for view frustum culling.
517 //
518 // Revision 1.8  1998/05/02 01:51:01  curt
519 // Updated polartocart conversion routine.
520 //
521 // Revision 1.7  1998/04/30 12:34:20  curt
522 // Added command line rendering options:
523 //   enable/disable fog/haze
524 //   specify smooth/flat shading
525 //   disable sky blending and just use a solid color
526 //   enable wireframe drawing mode
527 //
528 // Revision 1.6  1998/04/28 01:20:23  curt
529 // Type-ified fgTIME and fgVIEW.
530 // Added a command line option to disable textures.
531 //
532 // Revision 1.5  1998/04/26 05:10:04  curt
533 // "struct fgLIGHT" -> "fgLIGHT" because fgLIGHT is typedef'd.
534 //
535 // Revision 1.4  1998/04/25 22:04:53  curt
536 // Use already calculated LaRCsim values to create the roll/pitch/yaw
537 // transformation matrix (we call it LOCAL)
538 //
539 // Revision 1.3  1998/04/25 20:24:02  curt
540 // Cleaned up initialization sequence to eliminate interdependencies
541 // between sun position, lighting, and view position.  This creates a
542 // valid single pass initialization path.
543 //
544 // Revision 1.2  1998/04/24 00:49:22  curt
545 // Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
546 // Trying out some different option parsing code.
547 // Some code reorganization.
548 //
549 // Revision 1.1  1998/04/22 13:25:45  curt
550 // C++ - ifing the code.
551 // Starting a bit of reorganization of lighting code.
552 //
553 // Revision 1.16  1998/04/18 04:11:29  curt
554 // Moved fg_debug to it's own library, added zlib support.
555 //
556 // Revision 1.15  1998/02/20 00:16:24  curt
557 // Thursday's tweaks.
558 //
559 // Revision 1.14  1998/02/09 15:07:50  curt
560 // Minor tweaks.
561 //
562 // Revision 1.13  1998/02/07 15:29:45  curt
563 // Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
564 // <chotchkiss@namg.us.anritsu.com>
565 //
566 // Revision 1.12  1998/01/29 00:50:28  curt
567 // Added a view record field for absolute x, y, z position.
568 //
569 // Revision 1.11  1998/01/27 00:47:58  curt
570 // Incorporated Paul Bleisch's <pbleisch@acm.org> new debug message
571 // system and commandline/config file processing code.
572 //
573 // Revision 1.10  1998/01/19 19:27:09  curt
574 // Merged in make system changes from Bob Kuehne <rpk@sgi.com>
575 // This should simplify things tremendously.
576 //
577 // Revision 1.9  1998/01/13 00:23:09  curt
578 // Initial changes to support loading and management of scenery tiles.  Note,
579 // there's still a fair amount of work left to be done.
580 //
581 // Revision 1.8  1997/12/30 22:22:33  curt
582 // Further integration of event manager.
583 //
584 // Revision 1.7  1997/12/30 20:47:45  curt
585 // Integrated new event manager with subsystem initializations.
586 //
587 // Revision 1.6  1997/12/22 04:14:32  curt
588 // Aligned sky with sun so dusk/dawn effects can be correct relative to the sun.
589 //
590 // Revision 1.5  1997/12/18 04:07:02  curt
591 // Worked on properly translating and positioning the sky dome.
592 //
593 // Revision 1.4  1997/12/17 23:13:36  curt
594 // Began working on rendering a sky.
595 //
596 // Revision 1.3  1997/12/15 23:54:50  curt
597 // Add xgl wrappers for debugging.
598 // Generate terrain normals on the fly.
599 //
600 // Revision 1.2  1997/12/10 22:37:48  curt
601 // Prepended "fg" on the name of all global structures that didn't have it yet.
602 // i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
603 //
604 // Revision 1.1  1997/08/27 21:31:17  curt
605 // Initial revision.
606 //