Csaba HALASZ: implement conditional (e.g. seasonal) texture loading at startup

This commit is contained in:
mfranz
2008-02-15 17:54:01 +00:00
parent ac4245013f
commit 2883a36c76
2 changed files with 18 additions and 4 deletions

View File

@@ -63,6 +63,7 @@
#include <simgear/misc/sg_path.hxx>
#include <simgear/misc/sgstream.hxx>
#include <simgear/props/props_io.hxx>
#include <simgear/props/condition.hxx>
#include <simgear/scene/tgdb/userdata.hxx>
#include "mat.hxx"
@@ -77,8 +78,9 @@ SGMaterialLib::SGMaterialLib ( void ) {
}
// Load a library of material properties
bool SGMaterialLib::load( const string &fg_root, const string& mpath, const char *season ) {
bool SGMaterialLib::load( const string &fg_root, const string& mpath, const char *season,
SGPropertyNode *prop_root )
{
SGPropertyNode materials;
SG_LOG( SG_INPUT, SG_INFO, "Reading materials from " << mpath );
@@ -92,8 +94,18 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath, const char
int nMaterials = materials.nChildren();
for (int i = 0; i < nMaterials; i++) {
const SGPropertyNode * node = materials.getChild(i);
const SGPropertyNode *node = materials.getChild(i);
if (!strcmp(node->getName(), "material")) {
const SGPropertyNode *conditionNode = node->getChild("condition");
if (conditionNode) {
SGSharedPtr<const SGCondition> condition = sgReadCondition(prop_root, conditionNode);
if (!condition->test()) {
SG_LOG(SG_INPUT, SG_DEBUG, "Skipping material entry #"
<< i << " (condition false)");
continue;
}
}
SGSharedPtr<SGMaterial> m = new SGMaterial(fg_root, node, season);
vector<SGPropertyNode_ptr>names = node->getChildren("name");

View File

@@ -41,6 +41,7 @@
#include <osg/StateSet>
class SGMaterial;
class SGPropertyNode;
SG_USING_STD(string);
SG_USING_STD(map);
@@ -65,7 +66,8 @@ public:
SGMaterialLib ( void );
// Load a library of material properties
bool load( const string &fg_root, const string& mpath, const char *season );
bool load( const string &fg_root, const string& mpath, const char *season,
SGPropertyNode *prop_root );
// Add the named texture with default properties
bool add_item( const string &tex_path );