Hello guys,
I'm new to maya API. I hope my question is not silly. I've been writing a parent constraint node, and I'd like it to have
an option of additional rotation/translation/scale input so the slave node can be animated on top of being constrained.
I'm reading the transformations into the node, I would like to convert them into a matrix, and then multiply my initial slave matrix by this matrix
before it is sent into a chain of other matrix multiplications.
I've got stuck on a problem- seems like set and add functions of MTransformationMatrix don't want to do their job. I would appreciate any input that wiser people
could give me
This is a summary of how I'm setting everything- in this test I'm defining translations, rotations and scales instead of reading them so it looks simpler.
Also the rotation order is set in this example.
// ----------- test:
MStatus stat;
MMatrix test_matrix;
MTransformationMatrix mtm (test_matrix);
const double setTrans[3] = {1.0,2.0,3.0};
const double setRot[3] = {0.2,0.1,0.5};
const double setScale[3] = {2,2,2};
mtm.setRotation (setRot, MTransformationMatrix::RotationOrder::kXYZ);
//mtm.addRotation (setRot, MTransformationMatrix::RotationOrder::kXYZ);
mtm.setTranslation (setTrans, MSpace::kTransform);
//mtm.addTranslation (setTrans, MSpace::kTransform);
mtm.setScale (setScale, MSpace::kTransform);
//mtm.addScale (setScale, MSpace::kTransform);
// here I'm only reading the set values back ... but I'm getting an identity matrix instead!
MVector pos = MTransformationMatrix( test_matrix ).getTranslation( MSpace::kPostTransform );
double getRot[3]= {0.0,0.0,0.0};
MTransformationMatrix::RotationOrder getRotOrder;
stat = MTransformationMatrix( test_matrix ).getRotation( getRot, getRotOrder );
double getScale[3]={1.0, 1.0, 1.0};
stat = MTransformationMatrix( matrix_boss ).getScale( getScale, MSpace::kPostTransform );
MString output = MString (" tx: ") + pos.x + MString (" ty: ")+ pos.y + MString (" tz: ")+ pos.z;
MGlobal::displayInfo (output);
output = MString (" rx: ") + getRot[0] + MString (" ry: ")+ getRot[1] + MString (" rz: ")+ getRot[2];
MGlobal::displayInfo (output);
output = MString (" sx: ") + getScale[0] + MString (" sy: ")+ getScale[1] + MString (" sz: ")+ getScale[2];
MGlobal::displayInfo (output);
// this is what it prints out (an identity matrix)
// tx: 0 ty: 0 tz: 0 //
// rx: 0 ry: 0 rz: 0 //
// sx: 1 sy: 1 sz: 1 //
Thank you very much for any help!