Message 1 of 2
Help getting worldMatrix values?

Not applicable
11-11-2012
07:59 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I'm developing Maya plug-in where I need to get worldMatrix values. Using pure Maya SDK, the output is always identity matrix. But I get correct worldMatrix if I call getAttr using MGlobal::executePythonCommand. Does anyone know what's wrong? Here's code snippet:
Thanks !!
I'm developing Maya plug-in where I need to get worldMatrix values. Using pure Maya SDK, the output is always identity matrix. But I get correct worldMatrix if I call getAttr using MGlobal::executePythonCommand. Does anyone know what's wrong? Here's code snippet:
-----------------------------------------
MStatus stat;
MFnDagNode fnThisNode(particleNode);
MObject attrObj = fnThisNode.attribute(MString("worldMatrix"), &stat);
if (stat == MStatus::kFailure) {
MGlobal::displayError(MString("Unable to get worldMatrix attribute"));
return;
}
MPlug worldMatrixPlug(particleNode,attrObj);
// this always outputs identity matrix
MObject worldMatrix;
worldMatrixPlug.getValue(worldMatrix);
MFnMatrixData fnWorldMatrix(worldMatrix);
MMatrix wm = fnWorldMatrix.matrix(&stat);
double world;
wm.get(world);
for (unsigned int i = 0; i < 4; i++)
for (unsigned int j = 0; j < 4; j++)
cout << " i " << i << " j " << j << " value " << world<< endl;
// using getAttr gives correct worldMatrix
MString nodeName = fnThisNode.fullPathName();
const MString getAttrCmd = MString("cmds.getAttr('") + nodeName + MString(".worldMatrix')");
MDoubleArray myWorld;
MGlobal::executePythonCommand(getAttrCmd, myWorld);
for (unsigned int i = 0; i < 16; i++)
cout << " i " << i << " value " << myWorld << endl;
----------------------------------------------
Thanks !!