1
0
Fork 0

Consolodating scenery structures in scenery.hxx.

This commit is contained in:
curt 2002-05-14 05:49:47 +00:00
parent 47825dcbae
commit 92a58f6555
10 changed files with 87 additions and 83 deletions

View 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";
}

View 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();

View 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.
*/

View 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;

View 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

View 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;

View 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;

View 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();
}

View 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;
}
};

View 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 "
}