Invert rotations in a Matrix4

   1784   1   1
User Avatar
Member
24 posts
Joined: Oct. 2014
Offline
Hi,

I'm using Python to get the local transformations from Houdini to a game engine, but I realized that the rotations are reversed. I can't change how the engine works, so I need to export the rotation values in the matrix already inverted.

I'm a complete failure when it comes to properly understanding Matrices, and couldn't figure out how to invert just the rotation vectors in a Matrix4 object obtained with objNode.localTransform(). I even tried numpy, but my own math incompetence wins. :-(

Is there a way to do that from Python in Houdini?
Thanks!
User Avatar
Member
24 posts
Joined: Oct. 2014
Offline
Never mind, figured it out… maybe not the best method, so here it goes (Tz, Rx and Ry are inverted in this case):
values = dict()
values["translate"] = ( n.parm("tx").eval(), n.parm("ty").eval(), n.parm("tz").eval()*-1 )
values["rotate"] = ( n.parm("rx").eval()*-1, n.parm("ry").eval()*-1, n.parm("rz").eval() )
values["scale"] = ( n.parm("sx").eval(), n.parm("sy").eval(), n.parm("sz").eval() )

xform = hou.hmath.buildTransform( values )
Edited by Ethernaut - May 22, 2018 00:49:30
  • Quick Links