]> git.mxchange.org Git - flightgear.git/commitdiff
The 3D aircraft model scene is now managed by
authordavid <david>
Tue, 9 Apr 2002 21:08:28 +0000 (21:08 +0000)
committerdavid <david>
Tue, 9 Apr 2002 21:08:28 +0000 (21:08 +0000)
FGAircraftModel::update.  We should do the same thing for the scenery,
to simplify the top-level loop.

src/Main/main.cxx
src/Model/acmodel.cxx
src/Model/acmodel.hxx

index bb3175380950c0ca9f3ebd4514b8b4fce8d1d14e..4afd1125dc3db9bdbcfaa87a4e9241714051f6de 100644 (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" );
 
index 63cacf89f5ca34b97ba9cfee6f61cfba1e0deadf..32cdb460eb97d3899574fb647e963a021343d260 100644 (file)
@@ -22,8 +22,6 @@
 #include <Main/viewmgr.hxx>
 #include "acmodel.hxx"
 
-extern ssgRoot * cockpit;              // FIXME: from main.cxx
-
 
 \f
 ////////////////////////////////////////////////////////////////////////
@@ -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);
 }
 
 
index 22401df6100fd29301f166dd80736fb5adc0be79..6e785694f9a2c38ab486b8791cbaafbd67484115 100644 (file)
@@ -37,6 +37,9 @@ public:
 private:
 
   FG3DModel * _aircraft;
+  ssgRoot * _scene;
+  float _nearplane;
+  float _farplane;
 
 };