]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/material/EffectBuilder.cxx
Improved tile cache priority scheme.
[simgear.git] / simgear / scene / material / EffectBuilder.cxx
index b1f0920771eed4511114a98fcb534f44f700288b..338fc9aa33a34f274598225bc967e7cb89d86e5c 100644 (file)
@@ -1,3 +1,12 @@
+#ifdef HAVE_CONFIG_H
+#  include <simgear_config.h>
+#endif
+
+#include <simgear/scene/model/SGReaderWriterXMLOptions.hxx>
+#include <simgear/scene/tgdb/userdata.hxx>
+
+#include <simgear/math/SGMath.hxx>
+
 #include "EffectBuilder.hxx"
 #include "Effect.hxx"
 
@@ -33,6 +42,34 @@ const SGPropertyNode* getEffectPropertyChild(Effect* effect,
         return getEffectPropertyNode(effect, child);
 }
 
+string getGlobalProperty(const SGPropertyNode* prop,
+                         const SGReaderWriterXMLOptions* options)
+{
+    if (!prop)
+        return string();
+    const SGPropertyNode* useProp = prop->getChild("use");
+    if (!useProp)
+        return string();
+    string propName = useProp->getStringValue();
+    SGPropertyNode_ptr propRoot;
+    if (propName[0] == '/') {
+        return propName;
+    } else if ((propRoot = options->getPropRoot())) {
+        string result = propRoot->getPath();
+        result.append("/");
+        result.append(propName);
+        return result;
+    } else {
+        throw effect::
+            BuilderException("No property root to use with relative name "
+                             + propName);
+    }
+        
+    return useProp->getStringValue();
+}
+
+namespace effect
+{
 BuilderException::BuilderException()
 {
 }
@@ -50,5 +87,19 @@ BuilderException::BuilderException(const std::string& message,
 
 BuilderException::~BuilderException() throw()
 {
+
+}
+}
+
+bool isAttributeActive(Effect* effect, const SGPropertyNode* prop)
+{
+    const SGPropertyNode* activeProp
+        = getEffectPropertyChild(effect, prop, "active");
+    return !activeProp || activeProp->getValue<bool>();
+}
+
+namespace effect
+{
+const char* colorFields[] = {"red", "green", "blue", "alpha"};
 }
 }