RotateManipulator.setInitialRotation not working with rotateOrder

RotateManipulator.setInitialRotation not working with rotateOrder

jmreinhart
Advisor Advisor
773 Views
3 Replies
Message 1 of 4

RotateManipulator.setInitialRotation not working with rotateOrder

jmreinhart
Advisor
Advisor

I have a custom transform node that has an offset rotation attribute (similar to the joint orient attribute). I'm working on a custom rotationManipulator to work with it. I'm using the standard rotateManip but using callback methods to connect the plug and manipulator so that I can take into account the offset). This is working perfectly in XYZ rotation order, but when I switch to another one, the setInitialRotation method gives unexpected results.

 

It seems as though it expects the input rotation to be XYZ. If that's the case then I just need to convert my rotation from whatever order it has to XYZ but keep the same end orientation. How can I do that?

0 Likes
Accepted solutions (1)
774 Views
3 Replies
Replies (3)
Message 2 of 4

jmreinhart
Advisor
Advisor
MMatrix resultMatrix = (rotateQuat).asMatrix();
MTransformationMatrix mt(resultMatrix);
double resRot[3];
MTransformationMatrix::RotationOrder mtRotateOrder;
mtRotateOrder = MTransformationMatrix::kXYZ;
mt.getRotation(resRot, mtRotateOrder);
MGlobal::displayInfo(MString("initX:") + resRot[0]);
MGlobal::displayInfo(MString("initY:") + resRot[1]);
MGlobal::displayInfo(MString("initZ:") + resRot[2]);
mtRotateOrder = MTransformationMatrix::kYZX;
mt.getRotation(resRot, mtRotateOrder);
MGlobal::displayInfo(MString("initX:") + resRot[0]);
MGlobal::displayInfo(MString("initY:") + resRot[1]);
MGlobal::displayInfo(MString("initZ:") + resRot[2]);

So I thought that this method would work but no matter what value I assign to "mtRotateOrder" it always gets an XYZ rotation. 

Message 3 of 4

jmreinhart
Advisor
Advisor
mtRotateOrder = MTransformationMatrix::kZYX;
mt.reorderRotation(mtRotateOrder);
mt.getRotation(resRot, mtRotateOrder);

MGlobal::displayInfo(MString("initX:") + resRot[0]);
MGlobal::displayInfo(MString("initY:") + resRot[1]);
MGlobal::displayInfo(MString("initZ:") + resRot[2]);

I also tried this method but no matter what rotateOrder I chose to convert to it always worked when the object was in XYZ mode but not in any other mode.

0 Likes
Message 4 of 4

jmreinhart
Advisor
Advisor
Accepted solution

So it turns out that when you are in object mode rotation you should setInitialRotation using an EulerRotation with the same rotateOrder as your object. Seems obvious, I was getting weird results in my tests because I didn't realize the plugToManipCallback was being called.

0 Likes