Hey guys,
just wanted to let you know, that I've cracked the case in the meantime.
Here are my findings:
def convert_matrix_left_to_right(m):
# http://www.techart3d.com/2016/02/convert-left-handed-to-right-handed-coordinates/
# m = op.GetMg()
new_m = c4d.Matrix( m.off,
m.v1*-1,
m.v2,
m.v3)
return new_m
def rotate_y_axis_180():
# Construct your own matrix based on rotation of axis
# https://www.mathworks.com/help/phased/ref/roty.html
x = c4d.Vector(-1, 0, 0)
y = c4d.Vector(0, 1, 0)
z = c4d.Vector(0, 0, -1)
off = c4d.Vector(0, 0, 0)
return c4d.Matrix(off, x, y, z)
def GetGlobalRotation(obj):
m = obj.GetMg()
new_m = rotate_y_axis_180() * convert_matrix_left_to_right(m)
return c4d.utils.MatrixToHPB(new_m, order=c4d.ROTATIONORDER_XYZGLOBAL)
Indeed you have to convert from a left-handed (c4d) (hpb) to a right-handed (houdini) (xyz) coordinate system... plus I've found that you need to add 180° to the y axis, so I constructed a matrix in rotate_y_axis_180 that I can multiply to my converted matrix.
Hope it helps someone...
Thank you guys for your input! Have a great weekend and stay safe!
Cheers,
Lasse