From fb69d790ce9834afd10b537e4cb799ce4d41fc23 Mon Sep 17 00:00:00 2001 From: ehofman Date: Sun, 23 Oct 2005 13:31:13 +0000 Subject: [PATCH] Add support for seasons. --- simgear/scene/material/mat.cxx | 12 ++++++++---- simgear/scene/material/mat.hxx | 4 ++-- simgear/scene/material/matlib.cxx | 2 +- simgear/scene/material/matlib.hxx | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/simgear/scene/material/mat.cxx b/simgear/scene/material/mat.cxx index 6bded150..0c493ce8 100644 --- a/simgear/scene/material/mat.cxx +++ b/simgear/scene/material/mat.cxx @@ -1,4 +1,4 @@ -// mat.cxx -- class to handle material properties +// e mat.cxx -- class to handle material properties // // Written by Curtis Olson, started May 1998. // @@ -27,6 +27,7 @@ #include +#include #include SG_USING_STD(map); @@ -48,10 +49,10 @@ SG_USING_STD(map); //////////////////////////////////////////////////////////////////////// -SGMaterial::SGMaterial( const string &fg_root, const SGPropertyNode *props ) +SGMaterial::SGMaterial( const string &fg_root, const SGPropertyNode *props, const char *season ) { init(); - read_properties( fg_root, props ); + read_properties( fg_root, props, season ); build_ssg_state( false ); } @@ -86,13 +87,16 @@ SGMaterial::~SGMaterial (void) //////////////////////////////////////////////////////////////////////// void -SGMaterial::read_properties( const string &fg_root, const SGPropertyNode * props ) +SGMaterial::read_properties( const string &fg_root, const SGPropertyNode * props, const char *season ) { // Gather the path(s) to the texture(s) vector textures = props->getChildren("texture"); for (unsigned int i = 0; i < textures.size(); i++) { string tname = textures[i]->getStringValue(); + if (strncmp(season, "summer", 6) && tname.substr(0,7) == "Terrain") + tname.insert(7,"."+string(season)); + if (tname == "") { tname = "unknown.rgb"; } diff --git a/simgear/scene/material/mat.hxx b/simgear/scene/material/mat.hxx index a32bde32..9c2284ef 100644 --- a/simgear/scene/material/mat.hxx +++ b/simgear/scene/material/mat.hxx @@ -71,7 +71,7 @@ public: * state information for the material. This node is usually * loaded from the $FG_ROOT/materials.xml file. */ - SGMaterial( const string &fg_root, const SGPropertyNode *props ); + SGMaterial( const string &fg_root, const SGPropertyNode *props, const char *season = "summer" ); /** @@ -249,7 +249,7 @@ private: SGMaterial( const string &fg_root, const SGMaterial &mat ); // unimplemented - void read_properties( const string &fg_root, const SGPropertyNode *props ); + void read_properties( const string &fg_root, const SGPropertyNode *props, const char *season ); void build_ssg_state( bool defer_tex_load ); void set_ssg_state( ssgSimpleState *s ); diff --git a/simgear/scene/material/matlib.cxx b/simgear/scene/material/matlib.cxx index 83074ca0..3347aa85 100644 --- a/simgear/scene/material/matlib.cxx +++ b/simgear/scene/material/matlib.cxx @@ -175,7 +175,7 @@ static int gen_taxiway_dir_light_map( int r, int g, int b, int alpha ) { // Load a library of material properties -bool SGMaterialLib::load( const string &fg_root, const string& mpath ) { +bool SGMaterialLib::load( const string &fg_root, const string& mpath, const char *season ) { SGPropertyNode materials; diff --git a/simgear/scene/material/matlib.hxx b/simgear/scene/material/matlib.hxx index 28fe6906..460a723c 100644 --- a/simgear/scene/material/matlib.hxx +++ b/simgear/scene/material/matlib.hxx @@ -64,7 +64,7 @@ public: SGMaterialLib ( void ); // Load a library of material properties - bool load( const string &fg_root, const string& mpath ); + bool load( const string &fg_root, const string& mpath, const char *season = "summer" ); // Add the named texture with default properties bool add_item( const string &tex_path ); -- 2.39.5