]> git.mxchange.org Git - flightgear.git/commitdiff
Patches from Jim Wilson:
authordavid <david>
Thu, 28 Mar 2002 16:14:04 +0000 (16:14 +0000)
committerdavid <david>
Thu, 28 Mar 2002 16:14:04 +0000 (16:14 +0000)
This patch creates a seperate scene graph for the cockpit.  The near plane is
only moved up when in the interior (pilot) view.  This is because with
rounding (I presume) it the visible ground is a bit up higher than it is with
the older nearplane setting.  Not much, but it is enough to bury the wheels.
I suspected this might be true but spliting to two sg's confirms it.  If
necessary we can adjust the model up a bit when in interior view.  This might
be good so we can set the near plane even closer when in the cockpit (its
still at 0.2m).

In general this looks a lot better on my Voodoo with this patch.  No
perceptibel change in frame rate on my system.  In terms of future plans I'd
see the sense in making the model plug into either scene.  This will be
necessary when we have multiple model instances in the frame.

src/Main/main.cxx
src/Main/model.cxx

index cdd158a13c5f47a01da861227bd067555b59fc23..1067ef38dbcfe2880848bbca4b0c975d9fd40dc8 100644 (file)
@@ -137,6 +137,12 @@ ssgTransform *lightpoints_transform = new ssgTransform;
 FGTileEntry *dummy_tile;
 sgVec3 rway_ols;
 // ADA
+// Clip plane settings...
+float cockpit_nearplane = 0.2f;
+float cockpit_farplane = 120000.0f;
+float scene_nearplane = 0.5f;
+float scene_farplane = 120000.0f;
+
 
 #ifndef FG_NEW_ENVIRONMENT
 #  include <WeatherCM/FGLocalWeatherDatabase.h>
@@ -175,6 +181,7 @@ 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;
@@ -363,10 +370,17 @@ void trRenderFrame( void ) {
     // return to the desired diffuse color
     ssgGetLight( 0 ) -> setColour( GL_DIFFUSE, l->scene_diffuse );
     glEnable( GL_DEPTH_TEST );
+    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 );
+
     // draw the lights
     glFogf (GL_FOG_DENSITY, fog_exp2_punch_through);
+    ssgSetNearFar( scene_nearplane, scene_farplane );
     ssgCullAndDraw( lighting );
 
     thesky->postDraw( cur_fdm_state->get_Altitude() * SG_FEET_TO_METER );
@@ -568,12 +582,19 @@ void fgRenderFrame( void ) {
        double agl = current_aircraft.fdm_state->get_Altitude() * SG_FEET_TO_METER
            - scenery.get_cur_elev();
 
-       if (fgGetBool("/sim/view/internal"))
-         ssgSetNearFar( 0.2f, 120000.0f );
-       else if ( agl > 10.0)
-           ssgSetNearFar( 10.0f, 120000.0f );
-       else
-           ssgSetNearFar( 0.5f, 120000.0f );
+//     if (fgGetBool("/sim/view/internal"))
+//       ssgSetNearFar( 0.2f, 120000.0f );
+//     else if ( agl > 10.0)
+
+        if ( agl > 10.0 ) {
+            scene_nearplane = 10.0f;
+            scene_farplane = 120000.0f;
+       } else {
+            scene_nearplane = 0.5f;
+            scene_farplane = 120000.0f;
+        }
+
+        ssgSetNearFar( scene_nearplane, scene_farplane );
 
        current_model.update(0); // FIXME: use real delta time
 
@@ -619,8 +640,14 @@ void fgRenderFrame( void ) {
 
        // draw the ssg scene
        glEnable( GL_DEPTH_TEST );
+        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 );
+
        // change state for lighting here
 
        // draw lighting
@@ -662,6 +689,7 @@ void fgRenderFrame( void ) {
        glEnable(GL_BLEND);
 #endif
 
+        ssgSetNearFar( scene_nearplane, scene_farplane );
        ssgCullAndDraw( lighting );
 
 #ifdef FG_EXPERIMENTAL_LIGHTING
@@ -1408,6 +1436,10 @@ 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" );
 
@@ -1865,3 +1897,4 @@ void fgUpdateDCS (void) {
 
 // $$$ end - added VS Renganathan, 15 Oct 2K
 //           added Venky         , 12 Nov 2K
+
index 7eabd4e0f916c5b4bea1510bf764fe32025e012d..2091d3e5d5e458b664f5c0516ccb54ef9cbf9d03 100644 (file)
@@ -20,7 +20,7 @@
 #include "viewmgr.hxx"
 #include "model.hxx"
 
-extern ssgRoot * scene;                // FIXME: from main.cxx
+extern ssgRoot * cockpit;              // FIXME: from main.cxx
 
 FGAircraftModel current_model; // FIXME: add to globals
 
@@ -135,7 +135,7 @@ FGAircraftModel::init ()
                                // Set up the selector node
   _selector->addKid(_position);
   _selector->clrTraversalMaskBits(SSGTRAV_HOT);
-  scene->addKid(_selector);
+  cockpit->addKid(_selector);
 }
 
 void 
@@ -387,3 +387,4 @@ FGAircraftModel::Animation::setRotation()
 
 
 
+