Allow a <parameters> section of a material definition, to pass parameters straight into the effect.
This commit is contained in:
@@ -388,6 +388,13 @@ SGMaterial::read_properties(const SGReaderWriterOptions* options,
|
|||||||
glyphs[name] = new SGMaterialGlyph(glyph_nodes[i]);
|
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
|
// Read conditions node
|
||||||
const SGPropertyNode *conditionNode = props->getChild("condition");
|
const SGPropertyNode *conditionNode = props->getChild("condition");
|
||||||
if (conditionNode) {
|
if (conditionNode) {
|
||||||
@@ -481,7 +488,10 @@ void SGMaterial::buildEffectProperties(const SGReaderWriterOptions* options)
|
|||||||
ref_ptr<SGMaterialUserData> user = new SGMaterialUserData(this);
|
ref_ptr<SGMaterialUserData> user = new SGMaterialUserData(this);
|
||||||
SGPropertyNode_ptr propRoot = new SGPropertyNode();
|
SGPropertyNode_ptr propRoot = new SGPropertyNode();
|
||||||
makeChild(propRoot, "inherits-from")->setStringValue(effect);
|
makeChild(propRoot, "inherits-from")->setStringValue(effect);
|
||||||
|
|
||||||
SGPropertyNode* paramProp = makeChild(propRoot, "parameters");
|
SGPropertyNode* paramProp = makeChild(propRoot, "parameters");
|
||||||
|
copyProperties(parameters, paramProp);
|
||||||
|
|
||||||
SGPropertyNode* materialProp = makeChild(paramProp, "material");
|
SGPropertyNode* materialProp = makeChild(paramProp, "material");
|
||||||
makeChild(materialProp, "ambient")->setValue(SGVec4d(ambient));
|
makeChild(materialProp, "ambient")->setValue(SGVec4d(ambient));
|
||||||
makeChild(materialProp, "diffuse")->setValue(SGVec4d(diffuse));
|
makeChild(materialProp, "diffuse")->setValue(SGVec4d(diffuse));
|
||||||
|
|||||||
@@ -485,6 +485,9 @@ private:
|
|||||||
// Condition, indicating when this material is active
|
// Condition, indicating when this material is active
|
||||||
SGSharedPtr<const SGCondition> condition;
|
SGSharedPtr<const SGCondition> condition;
|
||||||
|
|
||||||
|
// Parameters from the materials file
|
||||||
|
const SGPropertyNode* parameters;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Internal constructors and methods.
|
// Internal constructors and methods.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
Reference in New Issue
Block a user