diff --git a/src/Main/main.cxx b/src/Main/main.cxx index bb3175380..4afd1125d 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -142,8 +142,6 @@ FGTileEntry *dummy_tile; sgVec3 rway_ols; // ADA // Clip plane settings... -float cockpit_nearplane = 0.01f; -float cockpit_farplane = 5000.0f; float scene_nearplane = 0.5f; float scene_farplane = 120000.0f; @@ -186,7 +184,6 @@ void fgReshape( int width, int height ); // ssg variables ssgRoot *scene = NULL; -ssgRoot *cockpit = NULL; ssgBranch *terrain_branch = NULL; ssgBranch *gnd_lights_branch = NULL; ssgBranch *rwy_lights_branch = NULL; @@ -379,10 +376,7 @@ void trRenderFrame( void ) { ssgSetNearFar( scene_nearplane, scene_farplane ); ssgCullAndDraw( scene ); - // if in cockpit view adjust nearfar... - if (globals->get_current_view()->getType() == 0 ) - ssgSetNearFar( cockpit_nearplane, cockpit_farplane ); - ssgCullAndDraw( cockpit ); + globals->get_aircraft_model()->update(0); // draw the lights glFogf (GL_FOG_DENSITY, fog_exp2_punch_through); @@ -614,8 +608,6 @@ void fgRenderFrame( void ) { ssgSetNearFar( scene_nearplane, scene_farplane ); - globals->get_aircraft_model()->update(dt_ms); - // $$$ begin - added VS Renganthan 17 Oct 2K if(objc) fgUpdateDCS(); @@ -663,6 +655,8 @@ void fgRenderFrame( void ) { ssgSetNearFar( scene_nearplane, scene_farplane ); ssgCullAndDraw( scene ); + globals->get_aircraft_model()->update(dt_ms); + // change state for lighting here // draw lighting @@ -727,16 +721,6 @@ void fgRenderFrame( void ) { thesky->postDraw( cur_fdm_state->get_Altitude() * SG_FEET_TO_METER ); } - // if in cockpit view adjust nearfar... - if (current__view->getType() == 0 ) { - glClearDepth(1); - glClear(GL_DEPTH_BUFFER_BIT); - ssgSetNearFar( cockpit_nearplane, cockpit_farplane ); - ssgCullAndDraw( cockpit ); - } else { - ssgCullAndDraw( cockpit ); - } - // display HUD && Panel glDisable( GL_FOG ); glDisable( GL_DEPTH_TEST ); @@ -1501,10 +1485,6 @@ int mainLoop( int argc, char **argv ) { scene = new ssgRoot; scene->setName( "Scene" ); - // Scene graph root for cockpit - cockpit = new ssgRoot; - cockpit->setName( "Cockpit" ); - lighting = new ssgRoot; lighting->setName( "Lighting" ); diff --git a/src/Model/acmodel.cxx b/src/Model/acmodel.cxx index 63cacf89f..32cdb460e 100644 --- a/src/Model/acmodel.cxx +++ b/src/Model/acmodel.cxx @@ -22,8 +22,6 @@ #include
#include "acmodel.hxx" -extern ssgRoot * cockpit; // FIXME: from main.cxx - //////////////////////////////////////////////////////////////////////// @@ -31,13 +29,17 @@ extern ssgRoot * cockpit; // FIXME: from main.cxx //////////////////////////////////////////////////////////////////////// FGAircraftModel::FGAircraftModel () - : _aircraft(0) + : _aircraft(0), + _scene(new ssgRoot), + _nearplane(0.01f), + _farplane(5000.0f) { } FGAircraftModel::~FGAircraftModel () { delete _aircraft; + delete _scene; } void @@ -45,7 +47,7 @@ FGAircraftModel::init () { _aircraft = new FG3DModel; _aircraft->init(fgGetString("/sim/model/path", "Models/Geometry/glider.ac")); - cockpit->addKid(_aircraft->getSceneGraph()); + _scene->addKid(_aircraft->getSceneGraph()); } void @@ -79,6 +81,16 @@ FGAircraftModel::update (int dt) fgGetDouble("/orientation/pitch-deg"), fgGetDouble("/orientation/heading-deg")); _aircraft->update(dt); + + // OK, now adjust the clip planes and draw + // FIXME: view number shouldn't be + // hard-coded. + if (globals->get_current_view()->getType() == 0) { + glClearDepth(1); + glClear(GL_DEPTH_BUFFER_BIT); + ssgSetNearFar(_nearplane, _farplane); + } + ssgCullAndDraw(_scene); } diff --git a/src/Model/acmodel.hxx b/src/Model/acmodel.hxx index 22401df61..6e785694f 100644 --- a/src/Model/acmodel.hxx +++ b/src/Model/acmodel.hxx @@ -37,6 +37,9 @@ public: private: FG3DModel * _aircraft; + ssgRoot * _scene; + float _nearplane; + float _farplane; };