PDA

View Full Version : Object transforms through MEL/Python

 loocas05-13-2008, 10:49 AMHi there, is there such a way to get access to individual object's transforms like in 3ds Max? When I access object's in Max through MAXScript and list a transformation of an object, I get a matrix3 value like this one: (matrix3 [0.407459,-0.810476,-0.420839] [-0.0211067,-0.469063,0.882912] [-0.91298,-0.350868,-0.20823] [8.89958,9.12172,42.8305]) it describes object's full transform: rotation, scale and position (translation) How can I get such a value in Maya? I mean, I need to input this, Max, matrix3 to Maya objects' transforms, is there any such way? Thanks in advance, cheers - loocas
drGonzo
05-13-2008, 05:36 PM
// returns the composite transformation matrix
xform -q -m;

// rotation translation
xform -q -ro
xform -q -t

loocas
05-13-2008, 06:06 PM
// returns the composite transformation matrix
xform -q -m;

// rotation translation
xform -q -ro
xform -q -t

Thanks a lot! :thumbsup:

Btw: Max returns a matrix3 composed of 12 values, Maya returns a matrix composed of 16 values?

And, also, when I query only the rotation, I get eulerAngles, which isn't that useful, I mean, I can use that, but the easiest way for me is to store a full transform matrix3 from Max and set it to transform matrix in Maya.

What do the individual components mean in Maya?

Thanks a lot in advance :thumbsup:

drGonzo
05-13-2008, 07:57 PM
Btw: Max returns a matrix3 composed of 12 values, Maya returns a matrix composed of 16 values?

Have a look at this:
http://www.gamedev.net/reference/articles/article695.asp

(Thanks to Ckniffen for the link!)

And, also, when I query only the rotation, I get eulerAngles,

Have a look at the xform command. i think the -r flag will fix this.

shibumenon
05-14-2008, 09:04 AM
hi loocas,
A Transform matrix in both Max and Maya is a 4x4 matrix
In Max, the 4th column (0 0 0 1) is omitted, hence you get 12 values.
The xform value that you get through the xform command as mentioned by drGonzo above includes the 4th column, hence 16 values, as it should be.
It seems you are trying a Max to Maya thingy :
If you add 0, 0, 0, 1 respectively to the ends of the 4 components of the
matrix3 value in max, it becomes an acceptable matrix value in Maya, which can then be applied to any transform node using "xform -matrix nodeName"
Ofcourse you will need to transform the matrix to take care of the Z up in Max and Y up in Maya. Also, you may need to take care of the rot order and the shift in pivot, if any.

Maxscript has excellent methods to deal with transform matrices, but sadly, MEL doesn't.
The best way to deal with matrices in Maya, will be to use the SDK.

regards
shibu

loocas
05-14-2008, 12:44 PM
hi loocas,
A Transform matrix in both Max and Maya is a 4x4 matrix
In Max, the 4th column (0 0 0 1) is omitted, hence you get 12 values.
The xform value that you get through the xform command as mentioned by drGonzo above includes the 4th column, hence 16 values, as it should be.
It seems you are trying a Max to Maya thingy :
If you add 0, 0, 0, 1 respectively to the ends of the 4 components of the
matrix3 value in max, it becomes an acceptable matrix value in Maya, which can then be applied to any transform node using "xform -matrix nodeName"
Ofcourse you will need to transform the matrix to take care of the Z up in Max and Y up in Maya. Also, you may need to take care of the rot order and the shift in pivot, if any.

Maxscript has excellent methods to deal with transform matrices, but sadly, MEL doesn't.
The best way to deal with matrices in Maya, will be to use the SDK.

regards
shibu

Thank you very much, extremely helpful info! :beer:

Have a look at this:
http://www.gamedev.net/reference/ar.../article695.asp

Have a look at the xform command. i think the -r flag will fix this.

Thanks a lot, mate! Also very much appretiated! :thumbsup:

CGTalk Moderation
05-14-2008, 12:44 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.