I'm currently working on a plugin to establish a neat connection between C4D and Houdini. ( https://twitter.com/lasse_lauch/status/1319296533016182787?s=20 )
However, one thing that always drives me insane when transferring data between different apps is the matrix-rotation-euler-quaternion-endless-rabbit-hole when animation comes into play.
Currently I'm using these functions from the documentation as a base...
def GetGlobalPosition(obj): return obj.GetMg().off def GetGlobalRotation(obj): return c4d.utils.MatrixToHPB(obj.GetMg(), #order=c4d.ROTATIONORDER_XYZGLOBAL !? ) def GetGlobalScale(obj): m = obj.GetMg() return c4d.Vector( m.v1.GetLength(), m.v2.GetLength(), m.v3.GetLength())
... and write the components into a
myDict[frame]['tx'] = pos.x myDict[frame]['ty'] = pos.y myDict[frame]['tz'] = pos.z myDict[frame]['sx'] = scale.x myDict[frame]['sy'] = scale.y myDict[frame]['sz'] = scale.z # getter in cinema4D (rotation in radians) myDict[frame]['rx'] = rot.x myDict[frame]['ry'] = rot.y myDict[frame]['rz'] = rot.z # setter in houdini (radians to degrees): hou.hmath.radToDeg(key['rx'])
But I'm sure I somehow need to deconstruct the matrix and reconstruct in houdini.
Is this the way to go in general, or are there some other pointers to break this down to it's bare bones... I'm looking at you: @zipit … :D HELP!
When it comes to Matrices and Rotations my brain sloooowly starts to melt……
(…and yes, I've watched the 3Blue1Brown videos on quaternions... :innocent: )
Would love to provide further code details if needed.