]> git.mxchange.org Git - flightgear.git/commitdiff
Consolodating scenery structures in scenery.hxx.
authorcurt <curt>
Tue, 14 May 2002 05:49:47 +0000 (05:49 +0000)
committercurt <curt>
Tue, 14 May 2002 05:49:47 +0000 (05:49 +0000)
src/ATC/AIEntity.cxx
src/Main/fg_init.cxx
src/Main/globals.hxx
src/Main/main.cxx
src/Model/acmodel.cxx
src/Model/modelmgr.cxx
src/Scenery/hitlist.cxx
src/Scenery/newcache.cxx
src/Scenery/scenery.hxx
src/Scenery/tilemgr.cxx

index 828b9dde8ee4479c1f6d550ecff941fc6b3aaa70..f3b06ff9cf904f5cb9b2f9368dcf2baf5b5c31ee 100644 (file)
@@ -53,7 +53,7 @@ void FGAIEntity::Transform() {
     sgCoord shippos;
     FastWorldCoordinate(&shippos, sc);
     position->setTransform( &shippos );
-    globals->get_scene_graph()->addKid(position);
+    globals->get_scenery()->get_scene_graph()->addKid(position);
     //cout << "Transform called\n";
 }
 
index 5803f952c8192afed150fd80584701d821a147c8..b639560a00873868a1511077a41aef16ff9fa84f 100644 (file)
@@ -745,7 +745,6 @@ bool fgInitSubsystems( void ) {
     // Initialize the scenery management subsystem.
     ////////////////////////////////////////////////////////////////////
 
-    globals->set_scenery( new FGScenery );
     globals->get_scenery()->init();
     globals->get_scenery()->bind();
 
index af8dd7f991688f852736143e57dc480ac36431c1..f89f110899703430fee0c0714a93f4015a4d4ded 100644 (file)
@@ -68,9 +68,6 @@ class FGAircraftModel;
 class FGModelMgr;
 class FGScenery;
 
-class ssgRoot;
-class ssgBranch;
-
 
 /**
  * Bucket for subsystem pointers representing the sim's state.
@@ -165,14 +162,6 @@ private:
     // FlightGear scenery manager
     FGScenery *scenery;
 
-    // SSG scene graph
-    ssgRoot * scene_graph;
-    ssgBranch * terrain_branch;
-    ssgBranch * gnd_lights_branch;
-    ssgBranch * rwy_lights_branch;
-    ssgBranch * models_branch;
-    ssgBranch * aircraft_branch;
-
 public:
 
     FGGlobals();
@@ -284,41 +273,6 @@ public:
     inline FGScenery * get_scenery () const { return scenery; }
     inline void set_scenery ( FGScenery *s ) { scenery = s; }
 
-    inline ssgRoot * get_scene_graph () const { return scene_graph; }
-    inline void set_scene_graph (ssgRoot * s) { scene_graph = s; }
-
-    inline ssgBranch * get_terrain_branch () const { return terrain_branch; }
-    inline void set_terrain_branch (ssgBranch * t) { terrain_branch = t; }
-
-    inline ssgBranch * get_gnd_lights_branch () const {
-      return gnd_lights_branch;
-    }
-    inline void set_gnd_lights_branch (ssgBranch * t) {
-      gnd_lights_branch = t;
-    }
-
-    inline ssgBranch * get_rwy_lights_branch () const {
-      return rwy_lights_branch;
-    }
-    inline void set_rwy_lights_branch (ssgBranch * t) {
-      rwy_lights_branch = t;
-    }
-
-    inline ssgBranch * get_models_branch () const {
-      return models_branch;
-    }
-    inline void set_models_branch (ssgBranch * t) {
-      models_branch = t;
-    }
-
-    inline ssgBranch * get_aircraft_branch () const {
-      return aircraft_branch;
-    }
-    inline void set_aircraft_branch (ssgBranch * t) {
-      aircraft_branch = t;
-    }
-
-
     /**
      * Save the current state as the initial state.
      */
index cf6f521bb348e83e719aa91b5f9c9ac293e4a99e..1ea7344e0acf9efb8839623827396dccd4d46ffc 100644 (file)
@@ -373,7 +373,7 @@ void trRenderFrame( void ) {
     ssgGetLight( 0 ) -> setColour( GL_DIFFUSE, l->scene_diffuse );
     glEnable( GL_DEPTH_TEST );
     ssgSetNearFar( scene_nearplane, scene_farplane );
-    ssgCullAndDraw( globals->get_scene_graph() );
+    ssgCullAndDraw( globals->get_scenery()->get_scene_graph() );
 
     // draw the lights
     glFogf (GL_FOG_DENSITY, fog_exp2_punch_through);
@@ -643,7 +643,7 @@ void fgRenderFrame() {
        glEnable( GL_DEPTH_TEST );
 
         ssgSetNearFar( scene_nearplane, scene_farplane );
-       ssgCullAndDraw( globals->get_scene_graph() );
+       ssgCullAndDraw( globals->get_scenery()->get_scene_graph() );
 
        // change state for lighting here
 
@@ -1451,35 +1451,38 @@ int mainLoop( int argc, char **argv ) {
 
     SGPath modelpath( globals->get_fg_root() );
     ssgModelPath( (char *)modelpath.c_str() );
-  
+
+    // Initialize the global scenery manager
+    globals->set_scenery( new FGScenery );
+
     // Scene graph root
-    globals->set_scene_graph(new ssgRoot);
-    globals->get_scene_graph()->setName( "Scene" );
+    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->set_terrain_branch(new ssgBranch);
-    globals->get_terrain_branch()->setName( "Terrain" );
-    globals->get_scene_graph()->addKid( globals->get_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->set_models_branch(new ssgBranch);
-    globals->get_models_branch()->setName( "Models" );
-    globals->get_scene_graph()->addKid( globals->get_models_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->set_aircraft_branch(new ssgBranch);
-    globals->get_aircraft_branch()->setName( "Aircraft" );
-    globals->get_scene_graph()->addKid( globals->get_aircraft_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->set_gnd_lights_branch(new ssgBranch);
-    globals->get_gnd_lights_branch()->setName( "Ground Lighting" );
-    lighting->addKid( globals->get_gnd_lights_branch() );
+    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->set_rwy_lights_branch(new ssgBranch);
-    globals->get_rwy_lights_branch()->setName( "Runway Lighting" );
-    lighting->addKid( globals->get_rwy_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() );
 
     ////////////////////////////////////////////////////////////////////
     // Initialize the general model subsystem.
@@ -1558,7 +1561,7 @@ int mainLoop( int argc, char **argv ) {
     // Do the network intialization
     if ( fgGetBool("/sim/networking/network-olk") ) {
        printf("Multipilot mode %s\n",
-              fg_net_init( globals->get_scene_graph() ) );
+              fg_net_init( globals->get_scenery()->get_scene_graph() ) );
     }
 #endif
 
@@ -1797,7 +1800,7 @@ void fgLoadDCS(void) {
                                                    //dummy_tile->lightmaps_sequence->setTraversalMaskBits( SSGTRAV_HOT );
                                                        lightpoints_transform->addKid( dummy_tile->lightmaps_sequence );
                                                        lightpoints_transform->ref();
-                                                       globals->get_gnd_lights_branch()->addKid( lightpoints_transform );
+                                                       globals->get_scenery()->get_gnd_lights_branch()->addKid( lightpoints_transform );
                                                } 
                                        } //if in1 
                 } //if objc
@@ -1811,7 +1814,7 @@ void fgLoadDCS(void) {
 
         SG_LOG ( SG_TERRAIN, SG_ALERT, "Finished object processing." );
 
-        globals->get_terrain_branch()->addKid( ship_sel ); //add selector node to root node 
+        globals->get_scenery()->get_terrain_branch()->addKid( ship_sel ); //add selector node to root node 
     }
 
     return;
index b56578a9b0858aeef07414857f439d0e1f51541e..d1dc1bed5ad1f77fbf85975c8b9352bd81d05907 100644 (file)
@@ -20,6 +20,7 @@
 #include <Main/globals.hxx>
 #include <Main/fg_props.hxx>
 #include <Main/viewmgr.hxx>
+#include <Scenery/scenery.hxx>
 
 #include "acmodel.hxx"
 #include "model.hxx"
@@ -44,7 +45,7 @@ FGAircraftModel::~FGAircraftModel ()
   delete _aircraft;
   delete _scene;
                                // SSG will delete it
-  globals->get_aircraft_branch()->removeKid(_selector);
+  globals->get_scenery()->get_aircraft_branch()->removeKid(_selector);
 }
 
 void 
@@ -54,7 +55,7 @@ FGAircraftModel::init ()
   _aircraft->init(fgGetString("/sim/model/path", "Models/Geometry/glider.ac"));
   _scene->addKid(_aircraft->getSceneGraph());
   _selector->addKid(_aircraft->getSceneGraph());
-  globals->get_aircraft_branch()->addKid(_selector);
+  globals->get_scenery()->get_aircraft_branch()->addKid(_selector);
 }
 
 void 
index ead08801c489cb8ac194fce11f2f89f009e609cc..5d7f2afd44e18de53812bce3a278c63ef3509a1c 100644 (file)
@@ -6,6 +6,7 @@
 #include <plib/ssg.h>
 
 #include <Main/fg_props.hxx>
+#include <Scenery/scenery.hxx>
 
 #include "modelmgr.hxx"
 #include "model.hxx"
@@ -18,8 +19,8 @@ FGModelMgr::FGModelMgr ()
 
 FGModelMgr::~FGModelMgr ()
 {
-  for (int i = 0; i < _instances.size(); i++) {
-    globals->get_models_branch()
+  for (unsigned int i = 0; i < _instances.size(); i++) {
+    globals->get_scenery()->get_models_branch()
       ->removeKid(_instances[i]->model->getSceneGraph());
     delete _instances[i];
   }
@@ -30,7 +31,7 @@ FGModelMgr::init ()
 {
   vector<SGPropertyNode_ptr> model_nodes =
     fgGetNode("/models", true)->getChildren("model");
-  for (int i = 0; i < model_nodes.size(); i++) {
+  for (unsigned int i = 0; i < model_nodes.size(); i++) {
     SGPropertyNode * node = model_nodes[i];
     SG_LOG(SG_GENERAL, SG_INFO,
           "Adding model " << node->getStringValue("name", "[unnamed]"));
@@ -79,7 +80,7 @@ FGModelMgr::init ()
       model->setHeadingDeg(node->getDoubleValue("heading-deg"));
 
                                // Add this model to the global scene graph
-    globals->get_scene_graph()->addKid(model->getSceneGraph());
+    globals->get_scenery()->get_scene_graph()->addKid(model->getSceneGraph());
 
                                // Save this instance for updating
     _instances.push_back(instance);
@@ -99,7 +100,7 @@ FGModelMgr::unbind ()
 void
 FGModelMgr::update (double dt)
 {
-  for (int i = 0; i < _instances.size(); i++) {
+  for (unsigned int i = 0; i < _instances.size(); i++) {
     Instance * instance = _instances[i];
     FG3DModel * model = instance->model;
 
index 3736908d8e5563d82b1480ea6b7ef4b585a4d1a6..856b175a2184cafee67cf1ad480b38a53cb6fb44 100644 (file)
@@ -17,6 +17,7 @@
 
 #include <Main/globals.hxx>
 #include <Main/viewer.hxx>
+#include <Scenery/scenery.hxx>
 
 #include "hitlist.hxx"
 
@@ -509,7 +510,8 @@ bool fgCurrentElev( sgdVec3 abs_view_pos, sgdVec3 scenery_center,
     sgdCopyVec3(orig, view_pos );
     sgdCopyVec3(dir, abs_view_pos );
 
-    hit_list->Intersect( globals->get_terrain_branch(), orig, dir );
+    hit_list->Intersect( globals->get_scenery()->get_terrain_branch(),
+                         orig, dir );
 
     int this_hit=0;
     Point3D geoc;
index f7f599fb9b7e669962849727e9fb489cbc9bd814..93f9d5eb2b73512699bee4b568f9fbc4fc2b2dea 100644 (file)
@@ -197,7 +197,7 @@ void FGNewCache::clear_cache() {
     }
 
     // and ... just in case we missed something ... 
-    globals->get_terrain_branch()->removeAllKids();
+    globals->get_scenery()->get_terrain_branch()->removeAllKids();
 }
 
 
index 53724bae4f3c921c7aedac6e902248723603e9bc..6802956db158db77c98cb4464c3d825478f5e080 100644 (file)
@@ -31,6 +31,8 @@
 
 
 #include <plib/sg.h>
+#include <plib/ssg.h>
+
 #include <simgear/math/point3d.hxx>
 
 #include <Main/fgfs.hxx>
@@ -58,6 +60,14 @@ class FGScenery : public FGSubsystem {
     // unit normal at point used to determine current elevation
     sgdVec3 cur_normal;
 
+    // SSG scene graph
+    ssgRoot * scene_graph;
+    ssgBranch * terrain_branch;
+    ssgBranch * gnd_lights_branch;
+    ssgBranch * rwy_lights_branch;
+    ssgBranch * models_branch;
+    ssgBranch * aircraft_branch;
+
 public:
 
     FGScenery();
@@ -80,6 +90,40 @@ public:
 
     inline void set_cur_radius( double r ) { cur_radius = r; }
     inline void set_cur_normal( sgdVec3 n ) { sgdCopyVec3( cur_normal, n ); }
+
+    inline ssgRoot * get_scene_graph () const { return scene_graph; }
+    inline void set_scene_graph (ssgRoot * s) { scene_graph = s; }
+
+    inline ssgBranch * get_terrain_branch () const { return terrain_branch; }
+    inline void set_terrain_branch (ssgBranch * t) { terrain_branch = t; }
+
+    inline ssgBranch * get_gnd_lights_branch () const {
+      return gnd_lights_branch;
+    }
+    inline void set_gnd_lights_branch (ssgBranch * t) {
+      gnd_lights_branch = t;
+    }
+
+    inline ssgBranch * get_rwy_lights_branch () const {
+      return rwy_lights_branch;
+    }
+    inline void set_rwy_lights_branch (ssgBranch * t) {
+      rwy_lights_branch = t;
+    }
+
+    inline ssgBranch * get_models_branch () const {
+      return models_branch;
+    }
+    inline void set_models_branch (ssgBranch * t) {
+      models_branch = t;
+    }
+
+    inline ssgBranch * get_aircraft_branch () const {
+      return aircraft_branch;
+    }
+    inline void set_aircraft_branch (ssgBranch * t) {
+      aircraft_branch = t;
+    }
 };
 
 
index 0ed9903cc199b65d2c143212acb1d3e3cca8ae89..d8463071c30a32fb0abdce33d6f0a0ba90ed98b3 100644 (file)
@@ -330,9 +330,9 @@ int FGTileMgr::update( double lon, double lat, double visibility_meters ) {
        FGTileEntry* e = attach_queue.front();
        attach_queue.pop();
 #endif
-       e->add_ssg_nodes( globals->get_terrain_branch(),
-                         globals->get_gnd_lights_branch(),
-                         globals->get_rwy_lights_branch() );
+       e->add_ssg_nodes( globals->get_scenery()->get_terrain_branch(),
+                         globals->get_scenery()->get_gnd_lights_branch(),
+                         globals->get_scenery()->get_rwy_lights_branch() );
        // cout << "Adding ssg nodes for "
     }