1 // views.cxx -- data structures and routines for managing and view
4 // Written by Curtis Olson, started August 1997.
6 // Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
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.
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.
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.
23 // (Log is kept at end of this file)
30 #include <Aircraft/aircraft.hxx>
31 #include <Cockpit/panel.hxx>
32 #include <Debug/logstream.hxx>
33 #include <Include/fg_constants.h>
34 #include <Math/mat3.h>
35 #include <Math/point3d.hxx>
36 #include <Math/polar3d.hxx>
37 #include <Math/vector.hxx>
38 #include <Scenery/scenery.hxx>
39 #include <Time/fg_time.hxx>
41 #include "options.hxx"
45 // temporary (hopefully) hack
46 static int panel_hist = 0;
49 // specify code paths ... these are done as variable rather than
50 // #define's because down the road we may want to choose between them
51 // on the fly for different flight models ... this way magic carpet
52 // and external modes wouldn't need to recreate the LaRCsim matrices
55 static const bool use_larcsim_local_to_body = false;
58 // This is a record containing current view parameters
63 FGView::FGView( void ) {
67 // Initialize a view structure
68 void FGView::Init( void ) {
69 FG_LOG( FG_VIEW, FG_INFO, "Initializing View parameters" );
72 goal_view_offset = 0.0;
74 winWidth = current_options.get_xsize();
75 winHeight = current_options.get_ysize();
77 if ( ! current_options.get_panel_status() ) {
78 current_view.set_win_ratio( (GLfloat) winWidth / (GLfloat) winHeight );
80 current_view.set_win_ratio( (GLfloat) winWidth /
81 ((GLfloat) (winHeight)*0.4232) );
84 force_update_fov_math();
88 // Update the field of view coefficients
89 void FGView::UpdateFOV( const fgOPTIONS& o ) {
90 double fov, theta_x, theta_y;
94 // printf("win_ratio = %.2f\n", win_ratio);
95 // calculate sin() and cos() of fov / 2 in X direction;
96 theta_x = (fov * win_ratio * DEG_TO_RAD) / 2.0;
97 // printf("theta_x = %.2f\n", theta_x);
98 sin_fov_x = sin(theta_x);
99 cos_fov_x = cos(theta_x);
100 slope_x = -cos_fov_x / sin_fov_x;
101 // printf("slope_x = %.2f\n", slope_x);
103 #if defined( USE_FAST_FOV_CLIP )
104 fov_x_clip = slope_x*cos_fov_x - sin_fov_x;
105 #endif // defined( USE_FAST_FOV_CLIP )
107 // calculate sin() and cos() of fov / 2 in Y direction;
108 theta_y = (fov * DEG_TO_RAD) / 2.0;
109 // printf("theta_y = %.2f\n", theta_y);
110 sin_fov_y = sin(theta_y);
111 cos_fov_y = cos(theta_y);
112 slope_y = cos_fov_y / sin_fov_y;
113 // printf("slope_y = %.2f\n", slope_y);
115 #if defined( USE_FAST_FOV_CLIP )
116 fov_y_clip = -(slope_y*cos_fov_y + sin_fov_y);
117 #endif // defined( USE_FAST_FOV_CLIP )
121 // Basically, this is a modified version of the Mesa gluLookAt()
122 // function that's been modified slightly so we can capture the
123 // result before sending it off to OpenGL land.
124 void FGView::LookAt( GLdouble eyex, GLdouble eyey, GLdouble eyez,
125 GLdouble centerx, GLdouble centery, GLdouble centerz,
126 GLdouble upx, GLdouble upy, GLdouble upz ) {
128 GLdouble x[3], y[3], z[3];
131 m = current_view.MODEL_VIEW;
133 /* Make rotation matrix */
136 z[0] = eyex - centerx;
137 z[1] = eyey - centery;
138 z[2] = eyez - centerz;
139 mag = sqrt( z[0]*z[0] + z[1]*z[1] + z[2]*z[2] );
140 if (mag) { /* mpichler, 19950515 */
151 /* X vector = Y cross Z */
152 x[0] = y[1]*z[2] - y[2]*z[1];
153 x[1] = -y[0]*z[2] + y[2]*z[0];
154 x[2] = y[0]*z[1] - y[1]*z[0];
156 /* Recompute Y = Z cross X */
157 y[0] = z[1]*x[2] - z[2]*x[1];
158 y[1] = -z[0]*x[2] + z[2]*x[0];
159 y[2] = z[0]*x[1] - z[1]*x[0];
161 /* mpichler, 19950515 */
162 /* cross product gives area of parallelogram, which is < 1.0 for
163 * non-perpendicular unit-length vectors; so normalize x, y here
166 mag = sqrt( x[0]*x[0] + x[1]*x[1] + x[2]*x[2] );
173 mag = sqrt( y[0]*y[0] + y[1]*y[1] + y[2]*y[2] );
180 #define M(row,col) m[col*4+row]
181 M(0,0) = x[0]; M(0,1) = x[1]; M(0,2) = x[2]; M(0,3) = 0.0;
182 M(1,0) = y[0]; M(1,1) = y[1]; M(1,2) = y[2]; M(1,3) = 0.0;
183 M(2,0) = z[0]; M(2,1) = z[1]; M(2,2) = z[2]; M(2,3) = 0.0;
184 // the following is part of the original gluLookAt(), but we are
185 // commenting it out because we know we are going to be doing a
186 // translation below which will set these values anyways
187 // M(3,0) = 0.0; M(3,1) = 0.0; M(3,2) = 0.0; M(3,3) = 1.0;
190 // Translate Eye to Origin
191 // replaces: glTranslated( -eyex, -eyey, -eyez );
193 // this has been slightly modified from the original glTranslate()
194 // code because we know that coming into this m[12] = m[13] =
195 // m[14] = 0.0, and m[15] = 1.0;
196 m[12] = m[0] * -eyex + m[4] * -eyey + m[8] * -eyez /* + m[12] */;
197 m[13] = m[1] * -eyex + m[5] * -eyey + m[9] * -eyez /* + m[13] */;
198 m[14] = m[2] * -eyex + m[6] * -eyey + m[10] * -eyez /* + m[14] */;
199 m[15] = 1.0 /* m[3] * -eyex + m[7] * -eyey + m[11] * -eyez + m[15] */;
201 // xglMultMatrixd( m );
206 // Update the view volume, position, and orientation
207 void FGView::UpdateViewParams( void ) {
208 FGInterface *f = current_aircraft.fdm_state;
213 if ((current_options.get_panel_status() != panel_hist) && (current_options.get_panel_status()))
215 FGPanel::OurPanel->ReInit( 0, 0, 1024, 768);
218 if ( ! current_options.get_panel_status() ) {
219 xglViewport(0, 0 , (GLint)(winWidth), (GLint)(winHeight) );
221 xglViewport(0, (GLint)((winHeight)*0.5768), (GLint)(winWidth),
222 (GLint)((winHeight)*0.4232) );
225 // Tell GL we are about to modify the projection parameters
226 xglMatrixMode(GL_PROJECTION);
228 if ( f->get_Altitude() * FEET_TO_METER - scenery.cur_elev > 10.0 ) {
229 gluPerspective(current_options.get_fov(), win_ratio, 10.0, 100000.0);
231 gluPerspective(current_options.get_fov(), win_ratio, 0.5, 100000.0);
232 // printf("Near ground, minimizing near clip plane\n");
236 xglMatrixMode(GL_MODELVIEW);
239 // set up our view volume (default)
240 LookAt(view_pos.x(), view_pos.y(), view_pos.z(),
241 view_pos.x() + view_forward[0],
242 view_pos.y() + view_forward[1],
243 view_pos.z() + view_forward[2],
244 view_up[0], view_up[1], view_up[2]);
246 // look almost straight up (testing and eclipse watching)
247 /* LookAt(view_pos.x(), view_pos.y(), view_pos.z(),
248 view_pos.x() + view_up[0] + .001,
249 view_pos.y() + view_up[1] + .001,
250 view_pos.z() + view_up[2] + .001,
251 view_up[0], view_up[1], view_up[2]); */
253 // lock view horizontally towards sun (testing)
254 /* LookAt(view_pos.x(), view_pos.y(), view_pos.z(),
255 view_pos.x() + surface_to_sun[0],
256 view_pos.y() + surface_to_sun[1],
257 view_pos.z() + surface_to_sun[2],
258 view_up[0], view_up[1], view_up[2]); */
260 // lock view horizontally towards south (testing)
261 /* LookAt(view_pos.x(), view_pos.y(), view_pos.z(),
262 view_pos.x() + surface_south[0],
263 view_pos.y() + surface_south[1],
264 view_pos.z() + surface_south[2],
265 view_up[0], view_up[1], view_up[2]); */
267 panel_hist = current_options.get_panel_status();
271 // Update the view parameters
272 void FGView::UpdateViewMath( FGInterface *f ) {
274 MAT3vec vec, forward, v0, minus_z;
275 MAT3mat R, TMP, UP, LOCAL, VIEW;
279 // printf("Updating fov\n");
280 UpdateFOV( current_options );
284 scenery.center = scenery.next_center;
286 // printf("scenery center = %.2f %.2f %.2f\n", scenery.center.x,
287 // scenery.center.y, scenery.center.z);
289 // calculate the cartesion coords of the current lat/lon/0 elev
290 p = Point3D( f->get_Longitude(),
291 f->get_Lat_geocentric(),
292 f->get_Sea_level_radius() * FEET_TO_METER );
294 cur_zero_elev = fgPolarToCart3d(p) - scenery.center;
296 // calculate view position in current FG view coordinate system
297 // p.lon & p.lat are already defined earlier, p.radius was set to
298 // the sea level radius, so now we add in our altitude.
299 if ( f->get_Altitude() * FEET_TO_METER >
300 (scenery.cur_elev + 0.5 * METER_TO_FEET) ) {
301 p.setz( p.radius() + f->get_Altitude() * FEET_TO_METER );
303 p.setz( p.radius() + scenery.cur_elev + 0.5 * METER_TO_FEET );
306 abs_view_pos = fgPolarToCart3d(p);
307 view_pos = abs_view_pos - scenery.center;
309 FG_LOG( FG_VIEW, FG_DEBUG, "Polar view pos = " << p );
310 FG_LOG( FG_VIEW, FG_DEBUG, "Absolute view pos = " << abs_view_pos );
311 FG_LOG( FG_VIEW, FG_DEBUG, "Relative view pos = " << view_pos );
313 // Derive the LOCAL aircraft rotation matrix (roll, pitch, yaw)
314 // from FG_T_local_to_body[3][3]
316 if ( use_larcsim_local_to_body ) {
318 // Question: Why is the LaRCsim matrix arranged so differently
319 // than the one we need???
321 // Answer (I think): The LaRCsim matrix is generated in a
322 // different reference frame than we've set up for our world
324 LOCAL[0][0] = f->get_T_local_to_body_33();
325 LOCAL[0][1] = -f->get_T_local_to_body_32();
326 LOCAL[0][2] = -f->get_T_local_to_body_31();
328 LOCAL[1][0] = -f->get_T_local_to_body_23();
329 LOCAL[1][1] = f->get_T_local_to_body_22();
330 LOCAL[1][2] = f->get_T_local_to_body_21();
332 LOCAL[2][0] = -f->get_T_local_to_body_13();
333 LOCAL[2][1] = f->get_T_local_to_body_12();
334 LOCAL[2][2] = f->get_T_local_to_body_11();
336 LOCAL[3][0] = LOCAL[3][1] = LOCAL[3][2] = LOCAL[3][3] = 0.0;
339 // printf("LaRCsim LOCAL matrix\n");
340 // MAT3print(LOCAL, stdout);
344 // code to calculate LOCAL matrix calculated from Phi, Theta, and
345 // Psi (roll, pitch, yaw) in case we aren't running LaRCsim as our
348 MAT3_SET_VEC(vec, 0.0, 0.0, 1.0);
349 MAT3rotate(R, vec, f->get_Phi());
350 /* printf("Roll matrix\n"); */
351 /* MAT3print(R, stdout); */
353 MAT3_SET_VEC(vec, 0.0, 1.0, 0.0);
354 /* MAT3mult_vec(vec, vec, R); */
355 MAT3rotate(TMP, vec, f->get_Theta());
356 /* printf("Pitch matrix\n"); */
357 /* MAT3print(TMP, stdout); */
360 MAT3_SET_VEC(vec, 1.0, 0.0, 0.0);
361 /* MAT3mult_vec(vec, vec, R); */
362 /* MAT3rotate(TMP, vec, FG_Psi - FG_PI_2); */
363 MAT3rotate(TMP, vec, -f->get_Psi());
364 /* printf("Yaw matrix\n");
365 MAT3print(TMP, stdout); */
366 MAT3mult(LOCAL, R, TMP);
367 // printf("FG derived LOCAL matrix\n");
368 // MAT3print(LOCAL, stdout);
370 } // if ( use_larcsim_local_to_body )
372 // Derive the local UP transformation matrix based on *geodetic*
374 MAT3_SET_VEC(vec, 0.0, 0.0, 1.0);
375 MAT3rotate(R, vec, f->get_Longitude()); // R = rotate about Z axis
376 // printf("Longitude matrix\n");
377 // MAT3print(R, stdout);
379 MAT3_SET_VEC(vec, 0.0, 1.0, 0.0);
380 MAT3mult_vec(vec, vec, R);
381 MAT3rotate(TMP, vec, -f->get_Latitude()); // TMP = rotate about X axis
382 // printf("Latitude matrix\n");
383 // MAT3print(TMP, stdout);
385 MAT3mult(UP, R, TMP);
386 // printf("Local up matrix\n");
387 // MAT3print(UP, stdout);
389 MAT3_SET_VEC(local_up, 1.0, 0.0, 0.0);
390 MAT3mult_vec(local_up, local_up, UP);
392 // printf( "Local Up = (%.4f, %.4f, %.4f)\n",
393 // local_up[0], local_up[1], local_up[2]);
395 // Alternative method to Derive local up vector based on
396 // *geodetic* coordinates
397 // alt_up = fgPolarToCart(FG_Longitude, FG_Latitude, 1.0);
398 // printf( " Alt Up = (%.4f, %.4f, %.4f)\n",
399 // alt_up.x, alt_up.y, alt_up.z);
401 // Calculate the VIEW matrix
402 MAT3mult(VIEW, LOCAL, UP);
403 // printf("VIEW matrix\n");
404 // MAT3print(VIEW, stdout);
406 // generate the current up, forward, and fwrd-view vectors
407 MAT3_SET_VEC(vec, 1.0, 0.0, 0.0);
408 MAT3mult_vec(view_up, vec, VIEW);
410 MAT3_SET_VEC(vec, 0.0, 0.0, 1.0);
411 MAT3mult_vec(forward, vec, VIEW);
412 // printf( "Forward vector is (%.2f,%.2f,%.2f)\n", forward[0], forward[1],
415 MAT3rotate(TMP, view_up, view_offset);
416 MAT3mult_vec(view_forward, forward, TMP);
418 // make a vector to the current view position
419 MAT3_SET_VEC(v0, view_pos.x(), view_pos.y(), view_pos.z());
421 // Given a vector pointing straight down (-Z), map into onto the
422 // local plane representing "horizontal". This should give us the
423 // local direction for moving "south".
424 MAT3_SET_VEC(minus_z, 0.0, 0.0, -1.0);
425 map_vec_onto_cur_surface_plane(local_up, v0, minus_z, surface_south);
426 MAT3_NORMALIZE_VEC(surface_south, ntmp);
427 // printf( "Surface direction directly south %.2f %.2f %.2f\n",
428 // surface_south[0], surface_south[1], surface_south[2]);
430 // now calculate the surface east vector
431 MAT3rotate(TMP, view_up, FG_PI_2);
432 MAT3mult_vec(surface_east, surface_south, TMP);
433 // printf( "Surface direction directly east %.2f %.2f %.2f\n",
434 // surface_east[0], surface_east[1], surface_east[2]);
435 // printf( "Should be close to zero = %.2f\n",
436 // MAT3_DOT_PRODUCT(surface_south, surface_east));
440 // Update the "World to Eye" transformation matrix
441 // This is most useful for view frustum culling
442 void FGView::UpdateWorldToEye( FGInterface *f ) {
443 MAT3mat R_Phi, R_Theta, R_Psi, R_Lat, R_Lon, T_view;
447 if ( use_larcsim_local_to_body ) {
449 // Question: hey this is even different then LOCAL[][] above??
450 // Answer: yet another coordinate system, this time the
451 // coordinate system in which we do our view frustum culling.
453 AIRCRAFT[0][0] = -f->get_T_local_to_body_22();
454 AIRCRAFT[0][1] = -f->get_T_local_to_body_23();
455 AIRCRAFT[0][2] = f->get_T_local_to_body_21();
456 AIRCRAFT[0][3] = 0.0;
457 AIRCRAFT[1][0] = f->get_T_local_to_body_32();
458 AIRCRAFT[1][1] = f->get_T_local_to_body_33();
459 AIRCRAFT[1][2] = -f->get_T_local_to_body_31();
460 AIRCRAFT[1][3] = 0.0;
461 AIRCRAFT[2][0] = f->get_T_local_to_body_12();
462 AIRCRAFT[2][1] = f->get_T_local_to_body_13();
463 AIRCRAFT[2][2] = -f->get_T_local_to_body_11();
464 AIRCRAFT[2][3] = 0.0;
465 AIRCRAFT[3][0] = AIRCRAFT[3][1] = AIRCRAFT[3][2] = AIRCRAFT[3][3] = 0.0;
466 AIRCRAFT[3][3] = 1.0;
471 MAT3_SET_HVEC(vec, 0.0, 0.0, -1.0, 1.0);
472 MAT3rotate(R_Phi, vec, f->get_Phi());
473 // printf("Roll matrix (Phi)\n");
474 // MAT3print(R_Phi, stdout);
477 MAT3_SET_HVEC(vec, 1.0, 0.0, 0.0, 1.0);
478 MAT3rotate(R_Theta, vec, f->get_Theta());
479 // printf("\nPitch matrix (Theta)\n");
480 // MAT3print(R_Theta, stdout);
483 MAT3_SET_HVEC(vec, 0.0, -1.0, 0.0, 1.0);
484 MAT3rotate(R_Psi, vec, f->get_Psi() + FG_PI /* - view_offset */ );
485 // MAT3rotate(R_Psi, vec, f->get_Psi() + FG_PI - view_offset );
486 // printf("\nYaw matrix (Psi)\n");
487 // MAT3print(R_Psi, stdout);
489 // aircraft roll/pitch/yaw
490 MAT3mult(TMP, R_Phi, R_Theta);
491 MAT3mult(AIRCRAFT, TMP, R_Psi);
493 } // if ( use_larcsim_local_to_body )
495 // printf("AIRCRAFT matrix\n");
496 // MAT3print(AIRCRAFT, stdout);
498 // View rotation matrix relative to current aircraft orientation
499 MAT3_SET_HVEC(vec, 0.0, -1.0, 0.0, 1.0);
500 MAT3mult_vec(vec, vec, AIRCRAFT);
501 // printf("aircraft up vector = %.2f %.2f %.2f\n",
502 // vec[0], vec[1], vec[2]);
503 MAT3rotate(TMP, vec, -view_offset );
504 MAT3mult(VIEW_OFFSET, AIRCRAFT, TMP);
505 // printf("VIEW_OFFSET matrix\n");
506 // MAT3print(VIEW_OFFSET, stdout);
508 // View position in scenery centered coordinates
509 MAT3_SET_HVEC(vec, view_pos.x(), view_pos.y(), view_pos.z(), 1.0);
510 MAT3translate(T_view, vec);
511 // printf("\nTranslation matrix\n");
512 // MAT3print(T_view, stdout);
515 MAT3_SET_HVEC(vec, 1.0, 0.0, 0.0, 1.0);
516 // R_Lat = rotate about X axis
517 MAT3rotate(R_Lat, vec, f->get_Latitude());
518 // printf("\nLatitude matrix\n");
519 // MAT3print(R_Lat, stdout);
522 MAT3_SET_HVEC(vec, 0.0, 0.0, 1.0, 1.0);
523 // R_Lon = rotate about Z axis
524 MAT3rotate(R_Lon, vec, f->get_Longitude() - FG_PI_2 );
525 // printf("\nLongitude matrix\n");
526 // MAT3print(R_Lon, stdout);
529 MAT3mult(WORLD, R_Lat, R_Lon);
530 // printf("\nworld\n");
531 // MAT3print(WORLD, stdout);
533 MAT3mult(EYE_TO_WORLD, VIEW_OFFSET, WORLD);
534 MAT3mult(EYE_TO_WORLD, EYE_TO_WORLD, T_view);
535 // printf("\nEye to world\n");
536 // MAT3print(EYE_TO_WORLD, stdout);
538 MAT3invert(WORLD_TO_EYE, EYE_TO_WORLD);
539 // printf("\nWorld to eye\n");
540 // MAT3print(WORLD_TO_EYE, stdout);
542 // printf( "\nview_pos = %.2f %.2f %.2f\n",
543 // view_pos.x, view_pos.y, view_pos.z );
545 // MAT3_SET_HVEC(eye, 0.0, 0.0, 0.0, 1.0);
546 // MAT3mult_vec(vec, eye, EYE_TO_WORLD);
547 // printf("\neye -> world = %.2f %.2f %.2f\n", vec[0], vec[1], vec[2]);
549 // MAT3_SET_HVEC(vec1, view_pos.x, view_pos.y, view_pos.z, 1.0);
550 // MAT3mult_vec(vec, vec1, WORLD_TO_EYE);
551 // printf( "\nabs_view_pos -> eye = %.2f %.2f %.2f\n",
552 // vec[0], vec[1], vec[2]);
557 // Reject non viewable spheres from current View Frustrum by Curt
558 // Olson curt@me.umn.edu and Norman Vine nhv@yahoo.com with 'gentle
559 // guidance' from Steve Baker sbaker@link.com
561 FGView::SphereClip( const Point3D& cp, const double radius )
573 mat = (double *)(WORLD_TO_EYE);
575 eye[2] = x*mat[2] + y*mat[6] + z*mat[10] + mat[14];
577 // Check near and far clip plane
578 if( ( eye[2] > radius ) ||
579 ( eye[2] + radius + current_weather.visibility < 0) )
580 // ( eye[2] + radius + far_plane < 0) )
585 // check right and left clip plane (from eye perspective)
586 x1 = radius * fov_x_clip;
587 eye[0] = (x*mat[0] + y*mat[4] + z*mat[8] + mat[12]) * slope_x;
588 if( (eye[2] > -(eye[0]+x1)) || (eye[2] > (eye[0]-x1)) ) {
592 // check bottom and top clip plane (from eye perspective)
593 y1 = radius * fov_y_clip;
594 eye[1] = (x*mat[1] + y*mat[5] + z*mat[9] + mat[13]) * slope_y;
595 if( (eye[2] > -(eye[1]+y1)) || (eye[2] > (eye[1]-y1)) ) {
605 FGView::~FGView( void ) {
610 // Revision 1.34 1999/03/08 21:56:41 curt
611 // Added panel changes sent in by Friedemann.
612 // Added a splash screen randomization since we have several nice splash screens.
614 // Revision 1.33 1999/02/05 21:29:14 curt
615 // Modifications to incorporate Jon S. Berndts flight model code.
617 // Revision 1.32 1999/01/07 20:25:12 curt
618 // Updated struct fgGENERAL to class FGGeneral.
620 // Revision 1.31 1998/12/11 20:26:28 curt
621 // Fixed view frustum culling accuracy bug so we can look out the sides and
622 // back without tri-stripes dropping out.
624 // Revision 1.30 1998/12/09 18:50:28 curt
625 // Converted "class fgVIEW" to "class FGView" and updated to make data
626 // members private and make required accessor functions.
628 // Revision 1.29 1998/12/05 15:54:24 curt
629 // Renamed class fgFLIGHT to class FGState as per request by JSB.
631 // Revision 1.28 1998/12/03 01:17:20 curt
632 // Converted fgFLIGHT to a class.
634 // Revision 1.27 1998/11/16 14:00:06 curt
635 // Added pow() macro bug work around.
636 // Added support for starting FGFS at various resolutions.
637 // Added some initial serial port support.
638 // Specify default log levels in main().
640 // Revision 1.26 1998/11/09 23:39:25 curt
641 // Tweaks for the instrument panel.
643 // Revision 1.25 1998/11/06 21:18:15 curt
644 // Converted to new logstream debugging facility. This allows release
645 // builds with no messages at all (and no performance impact) by using
646 // the -DFG_NDEBUG flag.
648 // Revision 1.24 1998/10/18 01:17:19 curt
651 // Revision 1.23 1998/10/17 01:34:26 curt
654 // Revision 1.22 1998/10/16 00:54:03 curt
655 // Converted to Point3D class.
657 // Revision 1.21 1998/09/17 18:35:33 curt
658 // Added F8 to toggle fog and F9 to toggle texturing.
660 // Revision 1.20 1998/09/08 15:04:35 curt
661 // Optimizations by Norman Vine.
663 // Revision 1.19 1998/08/20 20:32:34 curt
664 // Reshuffled some of the code in and around views.[ch]xx
666 // Revision 1.18 1998/07/24 21:57:02 curt
667 // Set near clip plane to 0.5 meters when close to the ground. Also, let the view get a bit closer to the ground before hitting the hard limit.
669 // Revision 1.17 1998/07/24 21:39:12 curt
670 // Debugging output tweaks.
671 // Cast glGetString to (char *) to avoid compiler errors.
672 // Optimizations to fgGluLookAt() by Norman Vine.
674 // Revision 1.16 1998/07/13 21:01:41 curt
675 // Wrote access functions for current fgOPTIONS.
677 // Revision 1.15 1998/07/12 03:14:43 curt
678 // Added ground collision detection.
679 // Did some serious horsing around to be able to "hug" the ground properly
680 // and still be able to take off.
681 // Set the near clip plane to 1.0 meters when less than 10 meters above the
683 // Did some serious horsing around getting the initial airplane position to be
684 // correct based on rendered terrain elevation.
685 // Added a little cheat/hack that will prevent the view position from ever
686 // dropping below the terrain, even when the flight model doesn't quite
687 // put you as high as you'd like.
689 // Revision 1.14 1998/07/08 14:45:08 curt
690 // polar3d.h renamed to polar3d.hxx
691 // vector.h renamed to vector.hxx
692 // updated audio support so it waits to create audio classes (and tie up
693 // /dev/dsp) until the mpg123 player is finished.
695 // Revision 1.13 1998/07/04 00:52:27 curt
696 // Add my own version of gluLookAt() (which is nearly identical to the
697 // Mesa/glu version.) But, by calculating the Model View matrix our selves
698 // we can save this matrix without having to read it back in from the video
699 // card. This hopefully allows us to save a few cpu cycles when rendering
700 // out the fragments because we can just use glLoadMatrixd() with the
701 // precalculated matrix for each tile rather than doing a push(), translate(),
702 // pop() for every fragment.
704 // Panel status defaults to off for now until it gets a bit more developed.
706 // Extract OpenGL driver info on initialization.
708 // Revision 1.12 1998/06/03 00:47:15 curt
709 // Updated to compile in audio support if OSS available.
710 // Updated for new version of Steve's audio library.
711 // STL includes don't use .h
712 // Small view optimizations.
714 // Revision 1.11 1998/05/27 02:24:05 curt
715 // View optimizations by Norman Vine.
717 // Revision 1.10 1998/05/17 16:59:03 curt
718 // First pass at view frustum culling now operational.
720 // Revision 1.9 1998/05/16 13:08:37 curt
721 // C++ - ified views.[ch]xx
722 // Shuffled some additional view parameters into the fgVIEW class.
723 // Changed tile-radius to tile-diameter because it is a much better
725 // Added a WORLD_TO_EYE transformation to views.cxx. This allows us
726 // to transform world space to eye space for view frustum culling.
728 // Revision 1.8 1998/05/02 01:51:01 curt
729 // Updated polartocart conversion routine.
731 // Revision 1.7 1998/04/30 12:34:20 curt
732 // Added command line rendering options:
733 // enable/disable fog/haze
734 // specify smooth/flat shading
735 // disable sky blending and just use a solid color
736 // enable wireframe drawing mode
738 // Revision 1.6 1998/04/28 01:20:23 curt
739 // Type-ified fgTIME and fgVIEW.
740 // Added a command line option to disable textures.
742 // Revision 1.5 1998/04/26 05:10:04 curt
743 // "struct fgLIGHT" -> "fgLIGHT" because fgLIGHT is typedef'd.
745 // Revision 1.4 1998/04/25 22:04:53 curt
746 // Use already calculated LaRCsim values to create the roll/pitch/yaw
747 // transformation matrix (we call it LOCAL)
749 // Revision 1.3 1998/04/25 20:24:02 curt
750 // Cleaned up initialization sequence to eliminate interdependencies
751 // between sun position, lighting, and view position. This creates a
752 // valid single pass initialization path.
754 // Revision 1.2 1998/04/24 00:49:22 curt
755 // Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
756 // Trying out some different option parsing code.
757 // Some code reorganization.
759 // Revision 1.1 1998/04/22 13:25:45 curt
760 // C++ - ifing the code.
761 // Starting a bit of reorganization of lighting code.
763 // Revision 1.16 1998/04/18 04:11:29 curt
764 // Moved fg_debug to it's own library, added zlib support.
766 // Revision 1.15 1998/02/20 00:16:24 curt
767 // Thursday's tweaks.
769 // Revision 1.14 1998/02/09 15:07:50 curt
772 // Revision 1.13 1998/02/07 15:29:45 curt
773 // Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
774 // <chotchkiss@namg.us.anritsu.com>
776 // Revision 1.12 1998/01/29 00:50:28 curt
777 // Added a view record field for absolute x, y, z position.
779 // Revision 1.11 1998/01/27 00:47:58 curt
780 // Incorporated Paul Bleisch's <pbleisch@acm.org> new debug message
781 // system and commandline/config file processing code.
783 // Revision 1.10 1998/01/19 19:27:09 curt
784 // Merged in make system changes from Bob Kuehne <rpk@sgi.com>
785 // This should simplify things tremendously.
787 // Revision 1.9 1998/01/13 00:23:09 curt
788 // Initial changes to support loading and management of scenery tiles. Note,
789 // there's still a fair amount of work left to be done.
791 // Revision 1.8 1997/12/30 22:22:33 curt
792 // Further integration of event manager.
794 // Revision 1.7 1997/12/30 20:47:45 curt
795 // Integrated new event manager with subsystem initializations.
797 // Revision 1.6 1997/12/22 04:14:32 curt
798 // Aligned sky with sun so dusk/dawn effects can be correct relative to the sun.
800 // Revision 1.5 1997/12/18 04:07:02 curt
801 // Worked on properly translating and positioning the sky dome.
803 // Revision 1.4 1997/12/17 23:13:36 curt
804 // Began working on rendering a sky.
806 // Revision 1.3 1997/12/15 23:54:50 curt
807 // Add xgl wrappers for debugging.
808 // Generate terrain normals on the fly.
810 // Revision 1.2 1997/12/10 22:37:48 curt
811 // Prepended "fg" on the name of all global structures that didn't have it yet.
812 // i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
814 // Revision 1.1 1997/08/27 21:31:17 curt