Itoo Software Forum

Author Topic: Export data - transformation matrix  (Read 1269 times)

UB8512

  • Newbie
  • *
  • Posts: 34
Export data - transformation matrix
« on: February 21, 2019, 07:52:29 PM »
Hi,

please, how can I convert rotation matrix to numbers in degrees? I tried sin/cos, but I can not obtain same rotation numbers like in transform type-in window(after instantiate FP objects).

If I set in FP rotation only for one axis e.g. X: from 15° to 15°, then I am able to find number 0.258819...(sin 15°) in transform matrix. But After I set rotation in FP for all XYZ axis, then none of the numbers seems to be sin or cos of those angles.

Thanks for help.

iToo

  • Administrator
  • Hero Member
  • *****
  • Posts: 4388
    • iToo Software
Re: Export data - transformation matrix
« Reply #1 on: February 22, 2019, 12:01:23 PM »
Hi,

For C++, i use the "GetYawPitchRoll" function, which is available in the Max SDK.

For Maxscript, i'm not familiar with it, but i think you must extract the rotation part of the matrix with "rotation", which is expressed as a Quaternion, and then "quatToEuler2" to convert to angles.
http://help.autodesk.com/view/3DSMAX/2015/ENU/?guid=__files_GUID_D77C780A_4E8A_4528_949F_CC09AAE048DA_htm

You can find some theory here: http://www.gregslabaugh.net/publications/euler.pdf.

I don't know what you want to get, but in most of cases it's easier to transform the item directly with the full transformation matrix ("localTM" or "finalTM" in the exporter).

« Last Edit: February 22, 2019, 12:06:14 PM by iToo »
Carlos Quintero
iToo Software

UB8512

  • Newbie
  • *
  • Posts: 34
Re: Export data - transformation matrix
« Reply #2 on: February 22, 2019, 03:09:14 PM »
OK, thanks, the link to autodesk matrix3 helped me. Now I can export FP items transformation values to unity3d engine with few commands  without instantiating in max ;)
Code: [Select]
$.trees.count()
$.namelist
$.namelist[$.trees.getGeomID 0]
($.trees.getFullTransform 0).rotationpart as eulerAngles)
($.trees.getFullTransform 0).scalepart
($.trees.getFullTransform 0).translationpart
I am not a big friend with Matrices, so I am happy that easier solution exist  :)