1
0
Fork 0

The 3D aircraft model scene is now managed by

FGAircraftModel::update.  We should do the same thing for the scenery,
to simplify the top-level loop.
This commit is contained in:
david 2002-04-09 21:08:28 +00:00
parent cde90e06d5
commit a82e15a653
3 changed files with 22 additions and 27 deletions

View file

@ -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" );

View file

@ -22,8 +22,6 @@
#include <Main/viewmgr.hxx>
#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);
}

View file

@ -37,6 +37,9 @@ public:
private:
FG3DModel * _aircraft;
ssgRoot * _scene;
float _nearplane;
float _farplane;
};