From 82b41d7db63c8242c0c5d6b0f52ec84b45407a93 Mon Sep 17 00:00:00 2001 From: curt Date: Sun, 8 Aug 1999 01:31:30 +0000 Subject: [PATCH] Set up the model view matrix exactly as ssg does it before drawing sky, stars sun, and moon. I really should do a derived sgLeaf class so that these things can be drawn within ssgCullandDraw() but this is quicker for now ... --- src/Main/main.cxx | 82 +++++++++++++++------------------------------- src/Main/views.cxx | 26 +++++++-------- src/Main/views.hxx | 2 +- 3 files changed, 41 insertions(+), 69 deletions(-) diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 3199f0db1..45a3bd391 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -138,6 +138,14 @@ ssgBranch *terrain = NULL; ssgSelector *penguin_sel = NULL; ssgTransform *penguin_pos = NULL; +// hack +sgMat4 copy_of_ssgOpenGLAxisSwapMatrix = +{ + { 1.0f, 0.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, -1.0f, 0.0f }, + { 0.0f, 1.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 0.0f, 1.0f } +} ; // The following defines flight gear options. Because glutlib will also // want to parse its own options, those options must not be included here @@ -209,52 +217,6 @@ static void fgInitVisuals( void ) { } -#if 0 -// Draw a basic instrument panel -static void fgUpdateInstrViewParams( void ) { - - exit(0); - - fgVIEW *v = ¤t_view; - - xglViewport(0, 0 , (GLint)(v->winWidth), (GLint)(v->winHeight) / 2); - - xglMatrixMode(GL_PROJECTION); - xglPushMatrix(); - - xglLoadIdentity(); - gluOrtho2D(0, 640, 0, 480); - xglMatrixMode(GL_MODELVIEW); - xglPushMatrix(); - xglLoadIdentity(); - - xglColor3f(1.0, 1.0, 1.0); - xglIndexi(7); - - xglDisable(GL_DEPTH_TEST); - xglDisable(GL_LIGHTING); - - xglLineWidth(1); - xglColor3f (0.5, 0.5, 0.5); - - xglBegin(GL_QUADS); - xglVertex2f(0.0, 0.00); - xglVertex2f(0.0, 480.0); - xglVertex2f(640.0,480.0); - xglVertex2f(640.0, 0.0); - xglEnd(); - - xglRectf(0.0,0.0, 640, 480); - xglEnable(GL_DEPTH_TEST); - xglEnable(GL_LIGHTING); - xglMatrixMode(GL_PROJECTION); - xglPopMatrix(); - xglMatrixMode(GL_MODELVIEW); - xglPopMatrix(); -} -#endif - - // Update all Visuals (redraws anything graphics related) static void fgRenderFrame( void ) { fgLIGHT *l = &cur_light_params; @@ -316,8 +278,18 @@ static void fgRenderFrame( void ) { xglClear( clear_mask ); // Tell GL we are switching to model view parameters + + // I really should create a derived ssg node or use a call + // back or something so that I can draw the sky within the + // ssgCullandDraw() function, but for now I just mimic what + // ssg does to set up the model view matrix xglMatrixMode(GL_MODELVIEW); - // xglLoadIdentity(); + xglLoadIdentity(); + sgMat4 vm_tmp, view_mat; + sgTransposeNegateMat4 ( vm_tmp, v->sgVIEW ) ; + sgCopyMat4( view_mat, copy_of_ssgOpenGLAxisSwapMatrix ) ; + sgPreMultMat4( view_mat, vm_tmp ) ; + xglLoadMatrixf( (float *)view_mat ); // draw sky xglDisable( GL_DEPTH_TEST ); @@ -387,8 +359,8 @@ static void fgRenderFrame( void ) { // ssg test - xglMatrixMode( GL_PROJECTION ); - xglLoadIdentity(); + // xglMatrixMode( GL_PROJECTION ); + // xglLoadIdentity(); ssgSetFOV( current_options.get_fov(), 0.0f ); double agl = current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER @@ -918,13 +890,13 @@ static void fgIdleFunction ( void ) { // Handle new window size or exposure void fgReshape( int width, int height ) { if ( ! current_options.get_panel_status() ) { - current_view.set_win_ratio( (GLfloat) width / (GLfloat) height ); - xglViewport(0, 0 , (GLint)(width), (GLint)(height) ); + // current_view.set_win_ratio( (GLfloat) width / (GLfloat) height ); + // xglViewport(0, 0 , (GLint)(width), (GLint)(height) ); } else { - current_view.set_win_ratio( (GLfloat) width / - ((GLfloat) (height)*0.4232) ); - xglViewport(0, (GLint)((height)*0.5768), (GLint)(width), - (GLint)((height)*0.4232) ); + // current_view.set_win_ratio( (GLfloat) width / + // ((GLfloat) (height)*0.4232) ); + // xglViewport(0, (GLint)((height)*0.5768), (GLint)(width), + // (GLint)((height)*0.4232) ); } current_view.set_winWidth( width ); diff --git a/src/Main/views.cxx b/src/Main/views.cxx index ccdda9a57..80a9ec0d1 100644 --- a/src/Main/views.cxx +++ b/src/Main/views.cxx @@ -141,7 +141,7 @@ void FGView::cycle_view_mode() { } -#ifdef 0 +#if 0 // Basically, this is a modified version of the Mesa gluLookAt() // function that's been modified slightly so we can capture the // result before sending it off to OpenGL land. @@ -241,35 +241,35 @@ void FGView::UpdateViewParams( void ) { } if ( ! current_options.get_panel_status() ) { - xglViewport(0, 0 , (GLint)(winWidth), (GLint)(winHeight) ); + // xglViewport(0, 0 , (GLint)(winWidth), (GLint)(winHeight) ); } else { - xglViewport(0, (GLint)((winHeight)*0.5768), (GLint)(winWidth), - (GLint)((winHeight)*0.4232) ); + // xglViewport(0, (GLint)((winHeight)*0.5768), (GLint)(winWidth), + // (GLint)((winHeight)*0.4232) ); } // Tell GL we are about to modify the projection parameters - xglMatrixMode(GL_PROJECTION); - xglLoadIdentity(); + // xglMatrixMode(GL_PROJECTION); + // xglLoadIdentity(); if ( f->get_Altitude() * FEET_TO_METER - scenery.cur_elev > 10.0 ) { // ssgSetNearFar( 10.0, 100000.0 ); - gluPerspective(current_options.get_fov(), win_ratio, 10.0, 100000.0); + // gluPerspective(current_options.get_fov(), win_ratio, 10.0, 100000.0); } else { // ssgSetNearFar( 0.5, 100000.0 ); - gluPerspective(current_options.get_fov(), win_ratio, 0.5, 100000.0); + // gluPerspective(current_options.get_fov(), win_ratio, 0.5, 100000.0); // printf("Near ground, minimizing near clip plane\n"); } // } - xglMatrixMode(GL_MODELVIEW); - xglLoadIdentity(); + // xglMatrixMode(GL_MODELVIEW); + // xglLoadIdentity(); // set up our view volume (default) #if !defined(FG_VIEW_INLINE_OPTIMIZATIONS) - LookAt(view_pos.x(), view_pos.y(), view_pos.z(), + /* LookAt(view_pos.x(), view_pos.y(), view_pos.z(), view_pos.x() + view_forward[0], view_pos.y() + view_forward[1], view_pos.z() + view_forward[2], - view_up[0], view_up[1], view_up[2]); + view_up[0], view_up[1], view_up[2]); */ // look almost straight up (testing and eclipse watching) /* LookAt(view_pos.x(), view_pos.y(), view_pos.z(), @@ -387,7 +387,7 @@ void FGView::UpdateViewParams( void ) { m[15] = 1.0 /* m[3] * -view_pos.x() + m[7] * -view_pos.y() + m[11] * -view_pos.z() + m[15] */; // xglMultMatrixd( m ); - xglLoadMatrixf( m ); + // xglLoadMatrixf( m ); } #endif // FG_VIEW_INLINE_OPTIMIZATIONS diff --git a/src/Main/views.hxx b/src/Main/views.hxx index 993856a3a..0b13e4fa9 100644 --- a/src/Main/views.hxx +++ b/src/Main/views.hxx @@ -119,7 +119,7 @@ public: Point3D view_pos; // cartesion coordinates of current lon/lat if at sea level - // translated to scenery.center*/ + // translated to scenery.center Point3D cur_zero_elev; // vector in cartesian coordinates from current position to the -- 2.39.5