Add support for seasons.

This commit is contained in:
ehofman
2005-10-23 13:31:13 +00:00
parent debd066edd
commit fb69d790ce
4 changed files with 12 additions and 8 deletions

View File

@@ -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 <simgear/compiler.h>
#include <string.h>
#include <map>
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<SGPropertyNode_ptr> 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";
}

View File

@@ -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 );

View File

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

View File

@@ -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 );