get worldMatrix by c++ api

get worldMatrix by c++ api

egoldid1
Advocate Advocate
382 Views
1 Reply
Message 1 of 2

get worldMatrix by c++ api

egoldid1
Advocate
Advocate

hi, How do I know the value of one locator node's "worldMatrix" attribute? (c++)

 

I used the following code, but it gives abnormal values or numbers. Are the following codes wrong?

 

MPlug worldMatrixplug = depNode.findPlug("worldMatrix", true, &status);
MPlug worldMatrixplug_ele = worldMatrixplug.elementByLogicalIndex(0);

MMatrix locMatrixA( worldMatrixplug_ele .asMDataHandle().asMatrix() );
MTransformationMatrix locMatrix( worldMatrixplug_ele .asMDataHandle().asMatrix() );

0 Likes
Accepted solutions (1)
383 Views
1 Reply
Reply (1)
Message 2 of 2

cheng_xi_li
Autodesk Support
Autodesk Support
Accepted solution

Hi,

 

Getting data from a matrix attribute should like below:

 

 

// worldMatrixplug_ele is worldMatrix plug
auto handle = worldMatrixplug_ele.asMDataHandle();

// Get the data and use MFnMatrixData
MObject worldMatrixData = handle.data();
MFnMatrixData fnMatrixData(worldMatrixData);

// Get the matrix
auto locMatrixA = fnMatrixData.matrix();

 

 

Yours,

Li