]> git.mxchange.org Git - flightgear.git/commitdiff
Moved some scenery component initialization into FGScenery.
authorcurt <curt>
Tue, 14 May 2002 06:08:28 +0000 (06:08 +0000)
committercurt <curt>
Tue, 14 May 2002 06:08:28 +0000 (06:08 +0000)
src/Main/fg_init.cxx
src/Main/main.cxx
src/Scenery/scenery.cxx
src/Scenery/scenery.hxx

index b639560a00873868a1511077a41aef16ff9fa84f..5eb89321fd7d7ec78880ea55e36082c0eb4d8b6b 100644 (file)
@@ -745,9 +745,6 @@ bool fgInitSubsystems( void ) {
     // Initialize the scenery management subsystem.
     ////////////////////////////////////////////////////////////////////
 
-    globals->get_scenery()->init();
-    globals->get_scenery()->bind();
-
     if ( global_tile_mgr.init() ) {
        // Load the local scenery data
        double visibility_meters = fgGetDouble("/environment/visibility-m");
@@ -796,7 +793,7 @@ bool fgInitSubsystems( void ) {
 
 
     ////////////////////////////////////////////////////////////////////
-    // Initialize the lighting subsystem.
+    // Initialize the lightingsubsystem.
     ////////////////////////////////////////////////////////////////////
 
     // fgUpdateSunPos() needs a few position and view parameters set
index 1ea7344e0acf9efb8839623827396dccd4d46ffc..dc0ec237fe3e11c891b4265d001400cc7825cb25 100644 (file)
@@ -195,9 +195,6 @@ static GLfloat fog_exp_density;
 static GLfloat fog_exp2_density;
 static GLfloat fog_exp2_punch_through;
 
-ssgRoot *lighting = NULL;
-// ssgBranch *airport = NULL;
-
 #ifdef FG_NETWORK_OLK
 ssgSelector *fgd_sel = NULL;
 ssgTransform *fgd_pos = NULL;
@@ -378,7 +375,7 @@ void trRenderFrame( void ) {
     // draw the lights
     glFogf (GL_FOG_DENSITY, fog_exp2_punch_through);
     ssgSetNearFar( scene_nearplane, scene_farplane );
-    ssgCullAndDraw( lighting );
+    ssgCullAndDraw( globals->get_scenery()->get_lighting() );
 
     thesky->postDraw( cur_fdm_state->get_Altitude() * SG_FEET_TO_METER );
 
@@ -687,7 +684,7 @@ void fgRenderFrame() {
 #endif
 
         ssgSetNearFar( scene_nearplane, scene_farplane );
-       ssgCullAndDraw( lighting );
+       ssgCullAndDraw( globals->get_scenery()->get_lighting() );
 
 
 #ifdef FG_EXPERIMENTAL_LIGHTING
@@ -1454,35 +1451,8 @@ int mainLoop( int argc, char **argv ) {
 
     // Initialize the global scenery manager
     globals->set_scenery( new FGScenery );
-
-    // Scene graph root
-    globals->get_scenery()->set_scene_graph(new ssgRoot);
-    globals->get_scenery()->get_scene_graph()->setName( "Scene" );
-
-    lighting = new ssgRoot;
-    lighting->setName( "Lighting" );
-
-    // Terrain branch
-    globals->get_scenery()->set_terrain_branch(new ssgBranch);
-    globals->get_scenery()->get_terrain_branch()->setName( "Terrain" );
-    globals->get_scenery()->get_scene_graph()->addKid( globals->get_scenery()->get_terrain_branch() );
-
-    globals->get_scenery()->set_models_branch(new ssgBranch);
-    globals->get_scenery()->get_models_branch()->setName( "Models" );
-    globals->get_scenery()->get_scene_graph()->addKid( globals->get_scenery()->get_models_branch() );
-
-    globals->get_scenery()->set_aircraft_branch(new ssgBranch);
-    globals->get_scenery()->get_aircraft_branch()->setName( "Aircraft" );
-    globals->get_scenery()->get_scene_graph()->addKid( globals->get_scenery()->get_aircraft_branch() );
-
-    // Lighting
-    globals->get_scenery()->set_gnd_lights_branch(new ssgBranch);
-    globals->get_scenery()->get_gnd_lights_branch()->setName( "Ground Lighting" );
-    lighting->addKid( globals->get_scenery()->get_gnd_lights_branch() );
-
-    globals->get_scenery()->set_rwy_lights_branch(new ssgBranch);
-    globals->get_scenery()->get_rwy_lights_branch()->setName( "Runway Lighting" );
-    lighting->addKid( globals->get_scenery()->get_rwy_lights_branch() );
+    globals->get_scenery()->init();
+    globals->get_scenery()->bind();
 
     ////////////////////////////////////////////////////////////////////
     // Initialize the general model subsystem.
index 66b0536843e2b249e4737f11ccc55c0b04ceddc3..b319cefe8a29352f90e0590d2e77726eef0677ff 100644 (file)
@@ -50,21 +50,54 @@ FGScenery::FGScenery() {
     cur_elev = -9999;
 }
 
+
 // Initialize the Scenery Management system
 FGScenery::~FGScenery() {
 }
 
+
 void FGScenery::init() {
+    // Scene graph root
+    scene_graph = new ssgRoot;
+    scene_graph->setName( "Scene" );
+
+    lighting = new ssgRoot;
+    lighting->setName( "Lighting" );
+
+    // Terrain branch
+    terrain_branch = new ssgBranch;
+    terrain_branch->setName( "Terrain" );
+    scene_graph->addKid( terrain_branch );
+
+    models_branch = new ssgBranch;
+    models_branch->setName( "Models" );
+    scene_graph->addKid( models_branch );
+
+    aircraft_branch = new ssgBranch;
+    aircraft_branch->setName( "Aircraft" );
+    scene_graph->addKid( aircraft_branch );
+
+    // Lighting
+    gnd_lights_branch = new ssgBranch;
+    gnd_lights_branch->setName( "Ground Lighting" );
+    lighting->addKid( gnd_lights_branch );
+
+    rwy_lights_branch = new ssgBranch;
+    rwy_lights_branch->setName( "Runway Lighting" );
+    lighting->addKid( rwy_lights_branch );
 }
 
+
 void FGScenery::update(double dt) {
 }
 
+
 void FGScenery::bind() {
     fgTie("/environment/ground-elevation-m", this,
          &FGScenery::get_cur_elev, &FGScenery::set_cur_elev);
 }
 
+
 void FGScenery::unbind() {
     fgUntie("/environment/ground-elevation-m");
 }
index 6802956db158db77c98cb4464c3d825478f5e080..c4bf330c81e971349c8ee3ce95b02f681ef69a65 100644 (file)
@@ -68,6 +68,8 @@ class FGScenery : public FGSubsystem {
     ssgBranch * models_branch;
     ssgBranch * aircraft_branch;
 
+    ssgRoot *lighting;
+
 public:
 
     FGScenery();
@@ -124,6 +126,9 @@ public:
     inline void set_aircraft_branch (ssgBranch * t) {
       aircraft_branch = t;
     }
+
+    inline ssgRoot * get_lighting () const { return lighting; }
+    inline void set_lighting (ssgRoot *l) { lighting = l; }
 };