Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Help getting worldMatrix values?

Help getting worldMatrix values?

Anonymous
Not applicable
396 Views
1 Reply
Message 1 of 2

Help getting worldMatrix values?

Anonymous
Not applicable
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:


-----------------------------------------
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 !!
0 Likes
397 Views
1 Reply
Reply (1)
Message 2 of 2

tim.milstead
Observer
Observer

Is this a compute node or a command?

If it is the former then you need to get values from the data block.

0 Likes