From: Stuart Buchanan Date: Wed, 1 Aug 2012 20:06:59 +0000 (+0100) Subject: Allow a section of a material definition, to pass parameters straight... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=8b585db2386d289d812ece809db32027dcdd4c3b;p=simgear.git Allow a section of a material definition, to pass parameters straight into the effect. --- diff --git a/simgear/scene/material/mat.cxx b/simgear/scene/material/mat.cxx index 6152cc55..7f70c633 100644 --- a/simgear/scene/material/mat.cxx +++ b/simgear/scene/material/mat.cxx @@ -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 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)); diff --git a/simgear/scene/material/mat.hxx b/simgear/scene/material/mat.hxx index 7115a8ef..57b6c24c 100644 --- a/simgear/scene/material/mat.hxx +++ b/simgear/scene/material/mat.hxx @@ -484,6 +484,9 @@ private: // Condition, indicating when this material is active SGSharedPtr condition; + + // Parameters from the materials file + const SGPropertyNode* parameters; //////////////////////////////////////////////////////////////////// // Internal constructors and methods.