2 # include <simgear_config.h>
5 #include <simgear/scene/model/SGReaderWriterXMLOptions.hxx>
6 #include <simgear/scene/tgdb/userdata.hxx>
8 #include <simgear/math/SGMath.hxx>
10 #include "EffectBuilder.hxx"
16 // Given a property node from a pass, get its value either from it or
17 // from the effect parameters.
18 const SGPropertyNode* getEffectPropertyNode(Effect* effect,
19 const SGPropertyNode* prop)
23 if (prop->nChildren() > 0) {
24 const SGPropertyNode* useProp = prop->getChild("use");
25 if (!useProp || !effect->parametersProp)
27 return effect->parametersProp->getNode(useProp->getStringValue());
32 // Get a named child property from pass parameters or effect
34 const SGPropertyNode* getEffectPropertyChild(Effect* effect,
35 const SGPropertyNode* prop,
38 const SGPropertyNode* child = prop->getChild(name);
42 return getEffectPropertyNode(effect, child);
45 string getGlobalProperty(const SGPropertyNode* prop)
49 const SGPropertyNode* useProp = prop->getChild("use");
52 return useProp->getStringValue();
57 BuilderException::BuilderException()
61 BuilderException::BuilderException(const char* message, const char* origin)
62 : sg_exception(message, origin)
66 BuilderException::BuilderException(const std::string& message,
67 const std::string& origin)
68 : sg_exception(message, origin)
72 BuilderException::~BuilderException() throw()
78 bool isAttributeActive(Effect* effect, const SGPropertyNode* prop)
80 const SGPropertyNode* activeProp
81 = getEffectPropertyChild(effect, prop, "active");
82 return !activeProp || activeProp->getValue<bool>();
87 const char* colorFields[] = {"red", "green", "blue", "alpha"};