1
0
Fork 0

Further restructuring of the scenery loading code.

This commit is contained in:
curt 2002-03-03 23:20:55 +00:00
parent b9e866cfdd
commit 73b92a697d
7 changed files with 64 additions and 30 deletions

View file

@ -173,11 +173,12 @@ void fgReshape( int width, int height );
// ssg variables // ssg variables
ssgRoot *scene = NULL; ssgRoot *scene = NULL;
ssgBranch *terrain = NULL; ssgBranch *terrain_branch = NULL;
ssgBranch *gnd_lights_branch = NULL;
ssgBranch *rwy_lights_branch = NULL;
ssgRoot *lighting = NULL; ssgRoot *lighting = NULL;
ssgBranch *ground = NULL; // ssgBranch *airport = NULL;
ssgBranch *airport = NULL;
#ifdef FG_NETWORK_OLK #ifdef FG_NETWORK_OLK
ssgSelector *fgd_sel = NULL; ssgSelector *fgd_sel = NULL;
@ -1552,18 +1553,22 @@ int mainLoop( int argc, char **argv ) {
globals->set_mag( magvar ); globals->set_mag( magvar );
// Terrain branch // Terrain branch
terrain = new ssgBranch; terrain_branch = new ssgBranch;
terrain->setName( "Terrain" ); terrain_branch->setName( "Terrain" );
scene->addKid( terrain ); scene->addKid( terrain_branch );
// Lighting // Lighting
ground = new ssgBranch; gnd_lights_branch = new ssgBranch;
ground->setName( "Ground Lighting" ); gnd_lights_branch->setName( "Ground Lighting" );
lighting->addKid( ground ); lighting->addKid( gnd_lights_branch );
airport = new ssgBranch; rwy_lights_branch = new ssgBranch;
airport->setName( "Airport Lighting" ); rwy_lights_branch->setName( "Runway Lighting" );
lighting->addKid( airport ); lighting->addKid( rwy_lights_branch );
// airport = new ssgBranch;
// airport->setName( "Airport Lighting" );
// lighting->addKid( airport );
// ADA // ADA
fgLoadDCS(); fgLoadDCS();
@ -1812,7 +1817,7 @@ void fgLoadDCS(void) {
//dummy_tile->lightmaps_sequence->setTraversalMaskBits( SSGTRAV_HOT ); //dummy_tile->lightmaps_sequence->setTraversalMaskBits( SSGTRAV_HOT );
lightpoints_transform->addKid( dummy_tile->lightmaps_sequence ); lightpoints_transform->addKid( dummy_tile->lightmaps_sequence );
lightpoints_transform->ref(); lightpoints_transform->ref();
ground->addKid( lightpoints_transform ); gnd_lights_branch->addKid( lightpoints_transform );
} }
} //if in1 } //if in1
} //if objc } //if objc
@ -1826,7 +1831,7 @@ void fgLoadDCS(void) {
SG_LOG ( SG_TERRAIN, SG_ALERT, "Finished object processing." ); SG_LOG ( SG_TERRAIN, SG_ALERT, "Finished object processing." );
terrain->addKid( ship_sel ); //add selector node to root node terrain_branch->addKid( ship_sel ); //add selector node to root node
} }
return; return;

View file

@ -930,18 +930,25 @@ bool fgBinObjLoad( const string& path, const bool is_base,
point_list normals = obj.get_normals(); point_list normals = obj.get_normals();
point_list texcoords = obj.get_texcoords(); point_list texcoords = obj.get_texcoords();
string material; string material, tmp_mat;
int_list vertex_index; int_list vertex_index;
int_list tex_index; int_list tex_index;
int i; int i;
bool is_lighting = false;
// generate points // generate points
string_list pt_materials = obj.get_pt_materials(); string_list pt_materials = obj.get_pt_materials();
group_list pts_v = obj.get_pts_v(); group_list pts_v = obj.get_pts_v();
for ( i = 0; i < (int)pts_v.size(); ++i ) { for ( i = 0; i < (int)pts_v.size(); ++i ) {
cout << "pts_v.size() = " << pts_v.size() << endl; cout << "pts_v.size() = " << pts_v.size() << endl;
material = pt_materials[i]; tmp_mat = pt_materials[i];
if ( tmp_mat.substr(0, 3) == "RWY" ) {
material = "LIGHTS";
is_lighting = true;
} else {
material = tmp_mat;
}
vertex_index = pts_v[i]; vertex_index = pts_v[i];
tex_index.clear(); tex_index.clear();
ssgLeaf *leaf = gen_leaf( path, GL_POINTS, material, ssgLeaf *leaf = gen_leaf( path, GL_POINTS, material,
@ -949,7 +956,11 @@ bool fgBinObjLoad( const string& path, const bool is_base,
vertex_index, tex_index, vertex_index, tex_index,
false, ground_lights ); false, ground_lights );
geometry->addKid( leaf ); if ( is_lighting ) {
rwy_lights->addKid( leaf );
} else {
geometry->addKid( leaf );
}
} }
// generate triangles // generate triangles

View file

@ -27,7 +27,7 @@
#include "hitlist.hxx" #include "hitlist.hxx"
extern ssgBranch *terrain; extern ssgBranch *terrain_branch;
#if 0 #if 0
// check to see if the intersection point is // check to see if the intersection point is
@ -558,7 +558,7 @@ bool fgCurrentElev( sgdVec3 abs_view_pos, sgdVec3 scenery_center,
sgdCopyVec3(orig, view_pos ); sgdCopyVec3(orig, view_pos );
sgdCopyVec3(dir, abs_view_pos ); sgdCopyVec3(dir, abs_view_pos );
hit_list->Intersect( terrain, orig, dir ); hit_list->Intersect( terrain_branch, orig, dir );
int this_hit=0; int this_hit=0;
Point3D geoc; Point3D geoc;

View file

@ -183,7 +183,7 @@ bool FGNewCache::make_space() {
// Clear all completely loaded tiles (ignores partially loaded tiles) // Clear all completely loaded tiles (ignores partially loaded tiles)
void FGNewCache::clear_cache() { void FGNewCache::clear_cache() {
// This is a hack that should really get cleaned up at some point // This is a hack that should really get cleaned up at some point
extern ssgBranch *terrain; extern ssgBranch *terrain_branch;
tile_map_iterator current = tile_cache.begin(); tile_map_iterator current = tile_cache.begin();
tile_map_iterator end = tile_cache.end(); tile_map_iterator end = tile_cache.end();
@ -199,7 +199,7 @@ void FGNewCache::clear_cache() {
} }
// and ... just in case we missed something ... // and ... just in case we missed something ...
terrain->removeAllKids(); terrain_branch->removeAllKids();
} }

View file

@ -1029,6 +1029,10 @@ FGTileEntry::load( const SGPath& base, bool is_base )
ssgBranch* new_tile = new ssgBranch; ssgBranch* new_tile = new ssgBranch;
// runway lights
rwy_lights_transform = NULL;
rwy_lights_range = NULL;
// Check for master .stg (scene terra gear) file // Check for master .stg (scene terra gear) file
SGPath stg_name = basename; SGPath stg_name = basename;
stg_name.concat( ".stg" ); stg_name.concat( ".stg" );
@ -1382,12 +1386,14 @@ FGTileEntry::load( const SGPath& base, bool is_base )
void void
FGTileEntry::add_ssg_nodes( ssgBranch* terrain, ssgBranch* ground ) FGTileEntry::add_ssg_nodes( ssgBranch* terrain_branch,
ssgBranch* gnd_lights_branch,
ssgBranch* rwy_lights_branch )
{ {
// bump up the ref count so we can remove this later without // bump up the ref count so we can remove this later without
// having ssg try to free the memory. // having ssg try to free the memory.
terra_transform->ref(); terra_transform->ref();
terrain->addKid( terra_transform ); terrain_branch->addKid( terra_transform );
SG_LOG( SG_TERRAIN, SG_DEBUG, SG_LOG( SG_TERRAIN, SG_DEBUG,
"connected a tile into scene graph. terra_transform = " "connected a tile into scene graph. terra_transform = "
@ -1395,11 +1401,18 @@ FGTileEntry::add_ssg_nodes( ssgBranch* terrain, ssgBranch* ground )
SG_LOG( SG_TERRAIN, SG_DEBUG, "num parents now = " SG_LOG( SG_TERRAIN, SG_DEBUG, "num parents now = "
<< terra_transform->getNumParents() ); << terra_transform->getNumParents() );
if ( gnd_lights_transform != 0 ) { if ( gnd_lights_transform != NULL ) {
// bump up the ref count so we can remove this later without // bump up the ref count so we can remove this later without
// having ssg try to free the memory. // having ssg try to free the memory.
gnd_lights_transform->ref(); gnd_lights_transform->ref();
ground->addKid( gnd_lights_transform ); gnd_lights_branch->addKid( gnd_lights_transform );
}
if ( rwy_lights_transform != NULL ) {
// bump up the ref count so we can remove this later without
// having ssg try to free the memory.
rwy_lights_transform->ref();
rwy_lights_branch->addKid( rwy_lights_transform );
} }
// ADA // ADA
@ -1407,7 +1420,7 @@ FGTileEntry::add_ssg_nodes( ssgBranch* terrain, ssgBranch* ground )
// bump up the ref count so we can remove this later without // bump up the ref count so we can remove this later without
// having ssg try to free the memory. // having ssg try to free the memory.
lightmaps_transform->ref(); lightmaps_transform->ref();
ground->addKid( lightmaps_transform ); gnd_lights_branch->addKid( lightmaps_transform );
} }
// ADA // ADA

View file

@ -255,7 +255,9 @@ public:
/** /**
* Add terrain mesh and ground lighting to scene graph. * Add terrain mesh and ground lighting to scene graph.
*/ */
void add_ssg_nodes( ssgBranch* terrain, ssgBranch* ground ); void add_ssg_nodes( ssgBranch* terrain_branch,
ssgBranch* gnd_lights_branch,
ssgBranch* rwy_lights_branch );
/** /**
* disconnect terrain mesh and ground lighting nodes from scene * disconnect terrain mesh and ground lighting nodes from scene

View file

@ -52,8 +52,9 @@
#define TEST_LAST_HIT_CACHE #define TEST_LAST_HIT_CACHE
extern ssgRoot *scene; extern ssgRoot *scene;
extern ssgBranch *terrain; extern ssgBranch *terrain_branch; // branch that holds world geometry
extern ssgBranch *ground; extern ssgBranch *gnd_lights_branch; // branch that holds ground lighting
extern ssgBranch *rwy_lights_branch; // branch that holds runway lighting
// the tile manager // the tile manager
FGTileMgr global_tile_mgr; FGTileMgr global_tile_mgr;
@ -333,7 +334,9 @@ int FGTileMgr::update( double lon, double lat ) {
FGTileEntry* e = attach_queue.front(); FGTileEntry* e = attach_queue.front();
attach_queue.pop(); attach_queue.pop();
#endif #endif
e->add_ssg_nodes( terrain, ground ); e->add_ssg_nodes( terrain_branch,
gnd_lights_branch,
rwy_lights_branch );
// cout << "Adding ssg nodes for " // cout << "Adding ssg nodes for "
} }