From 7a5fbf1ba357509ce3afb6be1ba62ff62772fa4a Mon Sep 17 00:00:00 2001 From: curt Date: Thu, 14 Oct 1999 17:32:34 +0000 Subject: [PATCH] Fixed up external view mode so it works once again. --- src/Main/fg_init.cxx | 36 ++++++++++++++++++------------------ src/Main/main.cxx | 39 +++++++++++++++++---------------------- src/Main/views.cxx | 2 +- src/Main/views.hxx | 2 +- 4 files changed, 37 insertions(+), 42 deletions(-) diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index c55841088..c435786c7 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -224,7 +224,6 @@ bool fgInitSubsystems( void ) { fgLIGHT *l = &cur_light_params; FGTime *t = FGTime::cur_time_params; - FGView *v = ¤t_view; FG_LOG( FG_GENERAL, FG_INFO, "Initialize Subsystems"); FG_LOG( FG_GENERAL, FG_INFO, "========== =========="); @@ -314,7 +313,7 @@ bool fgInitSubsystems( void ) { << (cur_fdm_state->get_Altitude() * FEET_TO_METER) << ")" ); // We need to calculate a few more values here that would normally - // be calculated by the FDM so that the v->UpdateViewMath() + // be calculated by the FDM so that the current_view.UpdateViewMath() // routine doesn't get hosed. double sea_level_radius_meters; @@ -372,12 +371,14 @@ bool fgInitSubsystems( void ) { t->update(*cur_fdm_state); // Initialize view parameters - FG_LOG( FG_GENERAL, FG_DEBUG, "Before v->init()"); - v->Init(); - FG_LOG( FG_GENERAL, FG_DEBUG, "After v->init()"); - v->UpdateViewMath(*cur_fdm_state); - FG_LOG( FG_GENERAL, FG_DEBUG, " abs_view_pos = " << v->get_abs_view_pos()); - // v->UpdateWorldToEye(f); + FG_LOG( FG_GENERAL, FG_DEBUG, "Before current_view.init()"); + current_view.Init(); + pilot_view.Init(); + FG_LOG( FG_GENERAL, FG_DEBUG, "After current_view.init()"); + current_view.UpdateViewMath(*cur_fdm_state); + pilot_view.UpdateViewMath(*cur_fdm_state); + FG_LOG( FG_GENERAL, FG_DEBUG, " abs_view_pos = " << current_view.get_abs_view_pos()); + // current_view.UpdateWorldToEye(f); // Build the solar system //fgSolarSystemInit(*t); @@ -503,7 +504,6 @@ bool fgInitSubsystems( void ) { void fgReInitSubsystems( void ) { - FGView *v = ¤t_view; FGTime *t = FGTime::cur_time_params; int toggle_pause = t->getPause(); @@ -572,15 +572,15 @@ void fgReInitSubsystems( void ) cur_fdm_state->set_CG_Position( 0.0, 0.0, 0.0 ); // Initialize view parameters - // FG_LOG( FG_GENERAL, FG_DEBUG, "Before v->init()"); - // v->Init(); - v->set_view_offset( 0.0 ); - v->set_goal_view_offset( 0.0 ); - - FG_LOG( FG_GENERAL, FG_DEBUG, "After v->init()"); - v->UpdateViewMath(*cur_fdm_state); - FG_LOG( FG_GENERAL, FG_DEBUG, " abs_view_pos = " << v->get_abs_view_pos()); - // v->UpdateWorldToEye(f); + current_view.set_view_offset( 0.0 ); + current_view.set_goal_view_offset( 0.0 ); + pilot_view.set_view_offset( 0.0 ); + pilot_view.set_goal_view_offset( 0.0 ); + + FG_LOG( FG_GENERAL, FG_DEBUG, "After current_view.init()"); + current_view.UpdateViewMath(*cur_fdm_state); + pilot_view.UpdateViewMath(*cur_fdm_state); + FG_LOG( FG_GENERAL, FG_DEBUG, " abs_view_pos = " << current_view.get_abs_view_pos()); // fgFDMInit( current_options.get_flight_model(), cur_fdm_state, // 1.0 / current_options.get_model_hz() ); diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 3705cb246..cc13c554e 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -141,6 +141,9 @@ ssgBranch *terrain = NULL; ssgSelector *penguin_sel = NULL; ssgTransform *penguin_pos = NULL; +// current fdm/position used for view +FGInterface cur_view_fdm; + // hack sgMat4 copy_of_ssgOpenGLAxisSwapMatrix = { @@ -251,7 +254,10 @@ static void fgRenderFrame( void ) { // end of hack // update view volume parameters - current_view.UpdateViewParams(*cur_fdm_state); + // cout << "before pilot_view update" << endl; + pilot_view.UpdateViewParams(*cur_fdm_state); + // cout << "after pilot_view update" << endl; + current_view.UpdateViewParams(cur_view_fdm); // set the sun position xglLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec ); @@ -377,17 +383,9 @@ static void fgRenderFrame( void ) { ssgSetNearFar( 0.5f, 100000.0f ); } - // sgMat4 sgVIEW; - // while ( current_view.follow.size() > 25 ) { - // current_view.follow.pop_front(); - // } - if ( current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FIRST_PERSON ) { - // select current view matrix - // sgCopyMat4( sgVIEW, current_view.sgVIEW ); - // disable TuX penguin_sel->select(0); } else if ( current_options.get_view_mode() == @@ -402,9 +400,9 @@ static void fgRenderFrame( void ) { sgMat4 sgTRANS; sgMakeTransMat4( sgTRANS, - current_view.view_pos.x(), - current_view.view_pos.y(), - current_view.view_pos.z() ); + pilot_view.view_pos.x(), + pilot_view.view_pos.y(), + pilot_view.view_pos.z() ); sgVec3 ownship_up; sgSetVec3( ownship_up, 0.0, 0.0, 1.0); @@ -414,7 +412,7 @@ static void fgRenderFrame( void ) { sgMat4 sgTMP; sgMat4 sgTUX; - sgMultMat4( sgTMP, sgROT, current_view.VIEW_ROT ); + sgMultMat4( sgTMP, sgROT, pilot_view.VIEW_ROT ); sgMultMat4( sgTUX, sgTMP, sgTRANS ); sgCoord tuxpos; @@ -472,8 +470,6 @@ void fgUpdateTimeDepCalcs(int multi_loop, int remainder) { multi_loop = 1; } - // fdm_state = *cur_fdm_state; - if ( !t->getPause() ) { // run Autopilot system fgAPRun(); @@ -490,18 +486,17 @@ void fgUpdateTimeDepCalcs(int multi_loop, int remainder) { cur_fdm_state->update( 0 ); } - /* - fdm_list.push_back( fdm_state ); - while ( fdm_list.size() > 25 ) { + fdm_list.push_back( *cur_fdm_state ); + while ( fdm_list.size() > 15 ) { fdm_list.pop_front(); } if ( current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FIRST_PERSON ) { - *cur_fdm_state = fdm_state; + cur_view_fdm = *cur_fdm_state; + // do nothing } else if ( current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW ) { - *cur_fdm_state = fdm_list.front(); + cur_view_fdm = fdm_list.front(); } - */ // update the view angle for ( i = 0; i < multi_loop; i++ ) { @@ -957,7 +952,7 @@ void fgReshape( int width, int height ) { // the main loop, so this will now work without seg faulting // the system. solarSystemRebuild(); - current_view.UpdateViewParams(*cur_fdm_state); + current_view.UpdateViewParams(cur_view_fdm); if ( current_options.get_panel_status() ) { FGPanel::OurPanel->ReInit(0, 0, 1024, 768); } diff --git a/src/Main/views.cxx b/src/Main/views.cxx index 275bc3cc9..9e1835a22 100644 --- a/src/Main/views.cxx +++ b/src/Main/views.cxx @@ -3,7 +3,7 @@ // // Written by Curtis Olson, started August 1997. // -// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com +// Copyright (C) 1997 Curtis L. Olson - curt@flightgear.org // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as diff --git a/src/Main/views.hxx b/src/Main/views.hxx index 9f499db40..916cbcf8c 100644 --- a/src/Main/views.hxx +++ b/src/Main/views.hxx @@ -2,7 +2,7 @@ // // Written by Curtis Olson, started August 1997. // -// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com +// Copyright (C) 1997 Curtis L. Olson - curt@flightgear.org // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as -- 2.39.5