00001 #ifdef HAVE_CONFIG_H
00002 # include <simgear_config.h>
00003 #endif
00004
00005 #include <simgear/scene/tgdb/userdata.hxx>
00006
00007 #include <simgear/math/SGMath.hxx>
00008
00009 #include "EffectBuilder.hxx"
00010 #include "Effect.hxx"
00011
00012 namespace simgear
00013 {
00014
00015
00016
00017 const SGPropertyNode* getEffectPropertyNode(Effect* effect,
00018 const SGPropertyNode* prop)
00019 {
00020 if (!prop)
00021 return 0;
00022 if (prop->nChildren() > 0) {
00023 const SGPropertyNode* useProp = prop->getChild("use");
00024 if (!useProp || !effect->parametersProp)
00025 return prop;
00026 return effect->parametersProp->getNode(useProp->getStringValue());
00027 }
00028 return prop;
00029 }
00030
00031
00032
00033 const SGPropertyNode* getEffectPropertyChild(Effect* effect,
00034 const SGPropertyNode* prop,
00035 const char* name)
00036 {
00037 const SGPropertyNode* child = prop->getChild(name);
00038 if (!child)
00039 return 0;
00040 else
00041 return getEffectPropertyNode(effect, child);
00042 }
00043
00044 string getGlobalProperty(const SGPropertyNode* prop)
00045 {
00046 if (!prop)
00047 return string();
00048 const SGPropertyNode* useProp = prop->getChild("use");
00049 if (!useProp)
00050 return string();
00051 return useProp->getStringValue();
00052 }
00053
00054 namespace effect
00055 {
00056 BuilderException::BuilderException()
00057 {
00058 }
00059
00060 BuilderException::BuilderException(const char* message, const char* origin)
00061 : sg_exception(message, origin)
00062 {
00063 }
00064
00065 BuilderException::BuilderException(const std::string& message,
00066 const std::string& origin)
00067 : sg_exception(message, origin)
00068 {
00069 }
00070
00071 BuilderException::~BuilderException() throw()
00072 {
00073
00074 }
00075 }
00076
00077 bool isAttributeActive(Effect* effect, const SGPropertyNode* prop)
00078 {
00079 const SGPropertyNode* activeProp
00080 = getEffectPropertyChild(effect, prop, "active");
00081 return !activeProp || activeProp->getValue<bool>();
00082 }
00083
00084 namespace effect
00085 {
00086 const char* colorFields[] = {"red", "green", "blue", "alpha"};
00087 }
00088 }