accessing rotateOrder in MPxTransformMatrx::asMatrix

accessing rotateOrder in MPxTransformMatrx::asMatrix

jmreinhart
Advisor Advisor
1,963 Views
20 Replies
Message 1 of 21

accessing rotateOrder in MPxTransformMatrx::asMatrix

jmreinhart
Advisor
Advisor

I have a custom transform node. The calculation of the matrix requires access to the transform nodes rotateOrder attribute. I'm trying to store it using validateAndSet like the documentation suggests for custom attributes. But when I do that it prevents the rotateOrder attribute from changing .It's stuck as "XYZ".

 

MStatus normalTransformNode::validateAndSetValue(
	const MPlug& plug,
    const MDataHandle& handle)
{
    MStatus status = MS::kSuccess;
    // Make sure that there is something interesting to process.
    if (plug.isNull())
        return MS::kFailure;

    MDataBlock block = forceCache();//???
    MDataHandle blockHandle = block.outputValue(plug, &status);

	//========================
	//	Rotate
	//========================
	if (plug == rotateOrder)
	{
		MGlobal::displayInfo("validate rotateOrder");
		int rotateOrderIn = plug.asInt();//???
		MGlobal::displayInfo(MString("set to:") + rotateOrderIn);

		normalTransformMatrix *ltm = getNormalTransformMatrix();

		ltm->setRotateOrder(rotateOrderIn);

		//blockHandle.setInt(rotateOrderIn);
		//blockHandle.setClean();
		//dirtyMatrix();

		//return MS::kSuccess;
	}

This part of the code is being evaluated but it always prints a value of 0.

0 Likes
Accepted solutions (1)
1,964 Views
20 Replies
Replies (20)
Message 21 of 21

jmreinhart
Advisor
Advisor

One more note, updating the attributes in the postConstructor so the correct value gets passed to the MPxTransformMatrix does not work because when postConstructor is run the node does not yet exist in the scene.

 

I'm trying to use a MDGMessage::addNodeAddedCallback() created in the initializePlugin method to force the update. This makes the duplicated custom transform update once as soon as it's created. But deleting that callback when the plugin unloads is difficult