2 # include <simgear_config.h>
5 #include <simgear/scene/tgdb/userdata.hxx>
7 #include <simgear/math/SGMath.hxx>
9 #include "EffectBuilder.hxx"
15 // Given a property node from a pass, get its value either from it or
16 // from the effect parameters.
17 const SGPropertyNode* getEffectPropertyNode(Effect* effect,
18 const SGPropertyNode* prop)
22 if (prop->nChildren() > 0) {
23 const SGPropertyNode* useProp = prop->getChild("use");
24 if (!useProp || !effect->parametersProp)
26 return effect->parametersProp->getNode(useProp->getStringValue());
31 // Get a named child property from pass parameters or effect
33 const SGPropertyNode* getEffectPropertyChild(Effect* effect,
34 const SGPropertyNode* prop,
37 const SGPropertyNode* child = prop->getChild(name);
41 return getEffectPropertyNode(effect, child);
44 string getGlobalProperty(const SGPropertyNode* prop)
48 const SGPropertyNode* useProp = prop->getChild("use");
51 return useProp->getStringValue();
56 BuilderException::BuilderException()
60 BuilderException::BuilderException(const char* message, const char* origin)
61 : sg_exception(message, origin)
65 BuilderException::BuilderException(const std::string& message,
66 const std::string& origin)
67 : sg_exception(message, origin)
71 BuilderException::~BuilderException() throw()
77 bool isAttributeActive(Effect* effect, const SGPropertyNode* prop)
79 const SGPropertyNode* activeProp
80 = getEffectPropertyChild(effect, prop, "active");
81 return !activeProp || activeProp->getValue<bool>();
86 const char* colorFields[] = {"red", "green", "blue", "alpha"};