# include <simgear_config.h>
#endif
-#ifdef SG_MATH_EXCEPTION_CLASH
-# include <math.h>
-#endif
-
#ifdef HAVE_WINDOWS_H
# include <windows.h>
#endif
#include SG_GL_H
#include <string.h>
-#include STL_STRING
+#include <string>
#include <osg/AlphaFunc>
#include <osg/BlendFunc>
#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"
#include "matlib.hxx"
-SG_USING_NAMESPACE(std);
SG_USING_STD(string);
// Constructor
}
// 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 );
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");