]> git.mxchange.org Git - simgear.git/commitdiff
Allow a <parameters> section of a material definition, to pass parameters straight...
authorStuart Buchanan <stuart_d_buchanan@yahoo.co.uk>
Wed, 1 Aug 2012 20:06:59 +0000 (21:06 +0100)
committerStuart Buchanan <stuart_d_buchanan@yahoo.co.uk>
Wed, 1 Aug 2012 20:06:59 +0000 (21:06 +0100)
simgear/scene/material/mat.cxx
simgear/scene/material/mat.hxx

index 6152cc554fdf0cd1f26273e4db92046a3ebf2a9d..7f70c63328ebcc55bef883c330617528f4f13cda 100644 (file)
@@ -387,6 +387,13 @@ SGMaterial::read_properties(const SGReaderWriterOptions* options,
         if (name)
             glyphs[name] = new SGMaterialGlyph(glyph_nodes[i]);
     }
+    
+    // Read parameters entry, which is passed into the effect
+    if (props->hasChild("parameters")) {
+        parameters = props->getChild("parameters");
+    } else {
+        parameters = new SGPropertyNode();
+    }
 
     // Read conditions node
     const SGPropertyNode *conditionNode = props->getChild("condition");
@@ -481,7 +488,10 @@ void SGMaterial::buildEffectProperties(const SGReaderWriterOptions* options)
     ref_ptr<SGMaterialUserData> user = new SGMaterialUserData(this);
     SGPropertyNode_ptr propRoot = new SGPropertyNode();
     makeChild(propRoot, "inherits-from")->setStringValue(effect);
+    
     SGPropertyNode* paramProp = makeChild(propRoot, "parameters");
+    copyProperties(parameters, paramProp);
+    
     SGPropertyNode* materialProp = makeChild(paramProp, "material");
     makeChild(materialProp, "ambient")->setValue(SGVec4d(ambient));
     makeChild(materialProp, "diffuse")->setValue(SGVec4d(diffuse));
index 7115a8ef28b57caa74a2bf418e2857ab9642024d..57b6c24cd1c21720de3809c28c9f07b0b25d3b53 100644 (file)
@@ -484,6 +484,9 @@ private:
   
   // Condition, indicating when this material is active
   SGSharedPtr<const SGCondition> condition;
+  
+  // Parameters from the materials file
+  const SGPropertyNode* parameters;
 
   ////////////////////////////////////////////////////////////////////
   // Internal constructors and methods.