MTransformationMatrix api question

303 views
Skip to first unread message

John Cassella

unread,
Aug 30, 2010, 1:39:48 PM8/30/10
to maya...@googlegroups.com
Anybody  got a snippit of code to share  what would help me figure out  how to properly set/add a rotation using the MTransformationMatrix  ?

I'm doing this...


MVector txOffset, rxOffset;
double rxOffsetRadians[3];

(filling  txOffset and rxOffsetRadians with  values)
(changing  rxOffset  in  degrees to  radians and repopulating  rxOffsetRadians)

MTransformationMatrix  diffTxMatrix =  inverseWorldMatrix; (defined from  object)

diffTxMatrix.addTranslation (txOffset, MSpace::kTransform);  (this works.)

diffTxMatrix.addRotation( rxOffsetRadians, MTransformationMatrix::kXYZ,  MSpace::kTransform);

addRotation does not do anything.. 


is there  a trick or something that I'm missing in  my code? 
the  "setRotation" documentation says  the  double[3] has to be in radians,  but is  "addRotation" also in radians?


any help would be greatly  appreciated.

api  why you gotta be so confusing   some days?
:-)

-john

j...@janberger.de

unread,
Aug 30, 2010, 1:52:10 PM8/30/10
to maya...@googlegroups.com

 

Yes, it should be all in radians. Why the addRotation thing does not work for you is strange as it seems good to me. Maybe get the MStatus and check what it tells you.

 

John Cassella <redp...@gmail.com> hat am 30. August 2010 um 19:39 geschrieben:

Peter Shipkov

unread,
Aug 31, 2010, 12:28:39 AM8/31/10
to maya...@googlegroups.com
Did you check MFnTransform ?
In case you want to edit xform nodes in the scene.

--- On Mon, 8/30/10, John Cassella <redp...@gmail.com> wrote:

j...@janberger.de

unread,
Aug 31, 2010, 3:22:41 AM8/31/10
to maya...@googlegroups.com

Hi,

I just looked a little bit in some cpp files  and I didnt`t find any cases exactly like yours. Usually I create an MEulerRotation or MQuaternion and use that to rotate an MTransformationMatrix. Here is an example of an MEulerRotation:

 

  
         MEulerRotation rotOffEuler ( rotOff[0], rotOff[1], rotOff[2], (MEulerRotation::RotationOrder) rotOrder );

         MTransformationMatrix rotOffTMatrix;
         rotOffTMatrix.rotateBy(rotOffEuler, MSpace::kTransform, &stat);

 

What I like about the MEulerRotation is that it can be used as a matrix using the .asMatrix() member function. I hope this helps a little bit.

Cheers,

Jan

 

 

 

 

"j...@janberger.de" <j...@janberger.de> hat am 30. August 2010 um 19:52 geschrieben:
Reply all
Reply to author
Forward
0 new messages