From d6ae1c22059640521cc2be7e82015a7745006e85 Mon Sep 17 00:00:00 2001 From: curt Date: Wed, 14 May 2003 18:33:56 +0000 Subject: [PATCH] Create an instance of SGMaterialLib in the "globals" structure and use that. --- src/Main/fg_init.cxx | 2 +- src/Main/globals.hxx | 7 ++ src/Main/main.cxx | 3 +- src/Objects/apt_signs.cxx | 12 ++-- src/Objects/apt_signs.hxx | 8 ++- src/Objects/obj.cxx | 116 +++++++++++++++++------------- src/Objects/obj.hxx | 10 +-- src/Objects/pt_lights.cxx | 147 +++++++++++++++++--------------------- src/Objects/pt_lights.hxx | 1 + src/Scenery/tileentry.cxx | 35 +++++---- src/Scenery/tileentry.hxx | 17 ++--- 11 files changed, 195 insertions(+), 163 deletions(-) diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index adf2f936b..9949478d4 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -1314,7 +1314,7 @@ bool fgInitSubsystems() { SGPath mpath( globals->get_fg_root() ); mpath.append( "materials.xml" ); - if ( ! material_lib.load( globals->get_fg_root(), mpath.str() ) ) { + if ( ! globals->get_matlib()->load(globals->get_fg_root(), mpath.str()) ) { SG_LOG( SG_GENERAL, SG_ALERT, "Error loading material lib!" ); exit(-1); } diff --git a/src/Main/globals.hxx b/src/Main/globals.hxx index 4a6dda600..905752c6d 100644 --- a/src/Main/globals.hxx +++ b/src/Main/globals.hxx @@ -52,6 +52,7 @@ class SGEphemeris; class SGCommandMgr; class SGMagVar; +class SGMaterialLib; class SGModelLoader; class SGPropertyNode; class SGRoute; @@ -120,6 +121,9 @@ private: // Magnetic Variation SGMagVar *mag; + // Material properties library + SGMaterialLib *matlib; + // Current autopilot FGAutopilot *autopilot; @@ -232,6 +236,9 @@ public: inline SGMagVar *get_mag() const { return mag; } inline void set_mag( SGMagVar *m ) { mag = m; } + inline SGMaterialLib *get_matlib() const { return matlib; } + inline void set_matlib( SGMaterialLib *m ) { matlib = m; } + inline FGAutopilot *get_autopilot() const { return autopilot; } inline void set_autopilot( FGAutopilot *ap) { autopilot = ap; } diff --git a/src/Main/main.cxx b/src/Main/main.cxx index d7c3c38d5..24f294a6e 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -1228,7 +1228,7 @@ static void fgMainLoop( void ) { globals->get_io()->update( delta_time_sec ); // see if we need to load any deferred-load textures - material_lib.load_next_deferred(); + globals->get_matlib()->load_next_deferred(); // Run audio scheduler #ifdef ENABLE_AUDIO_SUPPORT @@ -1681,6 +1681,7 @@ static bool fgMainInit( int argc, char **argv ) { ssgModelPath( (char *)modelpath.c_str() ); // Initialize the global scenery manager + globals->set_matlib( new SGMaterialLib ); globals->set_scenery( new FGScenery ); globals->get_scenery()->init(); globals->get_scenery()->bind(); diff --git a/src/Objects/apt_signs.cxx b/src/Objects/apt_signs.cxx index ee377b64e..cf842a857 100644 --- a/src/Objects/apt_signs.cxx +++ b/src/Objects/apt_signs.cxx @@ -28,7 +28,9 @@ #include "obj.hxx" -ssgBranch *gen_taxi_sign( const string path, const string content ) { +ssgBranch *gen_taxi_sign( SGMaterialLib *matlib, + const string path, const string content ) +{ // for demo purposes we assume each element (letter) is 1x1 meter. // Sign is placed 0.25 meters above the ground @@ -95,7 +97,7 @@ ssgBranch *gen_taxi_sign( const string path, const string content ) { tex_index.push_back( 2 ); tex_index.push_back( 3 ); - ssgLeaf *leaf = gen_leaf( path, GL_TRIANGLE_STRIP, material, + ssgLeaf *leaf = gen_leaf( path, GL_TRIANGLE_STRIP, matlib, material, nodes, normals, texcoords, vertex_index, normal_index, tex_index, false, NULL ); @@ -107,7 +109,9 @@ ssgBranch *gen_taxi_sign( const string path, const string content ) { } -ssgBranch *gen_runway_sign( const string path, const string name ) { +ssgBranch *gen_runway_sign( SGMaterialLib *matlib, + const string path, const string name ) +{ // for demo purposes we assume each element (letter) is 1x1 meter. // Sign is placed 0.25 meters above the ground @@ -152,7 +156,7 @@ ssgBranch *gen_runway_sign( const string path, const string name ) { tex_index.push_back( 2 ); tex_index.push_back( 3 ); - ssgLeaf *leaf = gen_leaf( path, GL_TRIANGLE_STRIP, material, + ssgLeaf *leaf = gen_leaf( path, GL_TRIANGLE_STRIP, matlib, material, nodes, normals, texcoords, vertex_index, normal_index, tex_index, false, NULL ); diff --git a/src/Objects/apt_signs.hxx b/src/Objects/apt_signs.hxx index 1c0df1c15..edd96dfb1 100644 --- a/src/Objects/apt_signs.hxx +++ b/src/Objects/apt_signs.hxx @@ -36,15 +36,19 @@ #include // plib include +class SGMaterialLib; // forward declaration + SG_USING_STD(string); // Generate a taxi sign -ssgBranch *gen_taxi_sign( const string path, const string content ); +ssgBranch *gen_taxi_sign( SGMaterialLib *matlib, + const string path, const string content ); // Generate a runway sign -ssgBranch *gen_runway_sign( const string path, const string name ); +ssgBranch *gen_runway_sign( SGMaterialLib *matlib, + const string path, const string name ); #endif // _APT_SIGNS_HXX diff --git a/src/Objects/obj.cxx b/src/Objects/obj.cxx index 85395e309..0beeb9eb3 100644 --- a/src/Objects/obj.cxx +++ b/src/Objects/obj.cxx @@ -1,4 +1,4 @@ -// obj.hxx -- routines to handle loading scenery and building the plib +// obj.cxx -- routines to handle loading scenery and building the plib // scene graph. // // Written by Curtis Olson, started October 1997. @@ -58,7 +58,6 @@ #include
#include
#include