From 33dfddf70633958ba4381b9100892c64c91650a6 Mon Sep 17 00:00:00 2001 From: "Asad M. Zaman" Date: Fri, 18 Nov 2005 02:40:30 +0000 Subject: [PATCH] fixed the bug on plug array value retieveing --- pandatool/src/maya/mayaShaderColorDef.cxx | 52 ++++++++++++++++------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/pandatool/src/maya/mayaShaderColorDef.cxx b/pandatool/src/maya/mayaShaderColorDef.cxx index e00c78c795..1b81abb0b1 100644 --- a/pandatool/src/maya/mayaShaderColorDef.cxx +++ b/pandatool/src/maya/mayaShaderColorDef.cxx @@ -314,25 +314,49 @@ read_surface_color(MayaShader *shader, MObject color, bool trans) { maya_cat.debug() << "Found layered texture" << endl; MFnDependencyNode layered_fn(color); + + MPlugArray color_pa; + layered_fn.getConnections(color_pa); + + int blendValue; MStatus status; MPlug inputsPlug = layered_fn.findPlug("inputs", &status); MPlug blendModePlug = layered_fn.findPlug("blendMode", &status); - size_t numElements = inputsPlug.evaluateNumElements(&status); + maya_cat.spam() << "*** Start doIt... ***" << endl; maya_cat.spam() << "inputsPlug Name: " << inputsPlug.name() << endl; - // Asad:following block fills the plug array values: needed to get all the connections - int blendValue; - for (size_t i=0; i -1) { + if (li > 20) { + maya_cat.error() + << "unusual blendmode :" << li << " for :" << layered_fn.name() << endl; + exit(1); + } + logicalIdx = li; + break; + } } - // It seems our Maya, has the array of plugs in the reverse - // order. That is why I haev to query the ancestor index to the - // 2nd to last idx - status = blendModePlug.selectAncestorLogicalIndex(inputsPlug.numElements()-2,inputsPlug); - maya_cat.spam() << "blendModePlug Name: " << blendModePlug.name() << endl; + if (logicalIdx < 0) { + maya_cat.error() + << "Could not retrieve blendMode from: " << layered_fn.name() << endl; + exit(1); + } + // Now that I have the logical index, select the ancestorLogicalIndex + // on the blendModePlug to get the blendMode + status = blendModePlug.selectAncestorLogicalIndex(logicalIdx,inputsPlug); blendModePlug.getValue(blendValue); - maya_cat.spam() << "blendModePlug's value is " << blendValue << endl; + + maya_cat.spam() + << blendModePlug.name() << ": has value " << blendValue << endl; + MFnEnumAttribute blendModeEnum(blendModePlug); MString blendName = blendModeEnum.fieldName(blendValue, &status); switch (blendValue) { @@ -349,11 +373,9 @@ read_surface_color(MayaShader *shader, MObject color, bool trans) { shader->_blend_type = MayaShader::BT_modulate; } - maya_cat.spam() << "blendModePlug's field name is " << blendName << endl; + maya_cat.info() << "blendMode used " << blendName << endl; maya_cat.spam() << "*** END doIt... ***" << endl; - MPlugArray color_pa; - layered_fn.getConnections(color_pa); maya_cat.debug() << "number of connections: " << color_pa.length() << endl; bool first = true; for (size_t i=0; i