chaoticbob / Cinder-3DTools

8 stars 3 forks source link

C4DExporter: Lh Rh conversion. #3

Open simongeilfus opened 7 years ago

simongeilfus commented 7 years ago

I'll put that also in a PR but in the meantime here's my version of the left/right hand conversion. I believe that it is correct:

# rescale the position and negate the z component
self.translation = [ trans.x * _c4d.UNIT_SCALE,  trans.y * _c4d.UNIT_SCALE, -trans.z * _c4d.UNIT_SCALE ]
# extract the HPB angles, invert x and y and negate the z component
hpb = self.obj.GetRelRot()
xyz = c4d.Vector( hpb.y, hpb.x, -hpb.z )
# transform each component into rotation matrices
rotX = c4d.utils.RotAxisToMatrix( c4d.Vector( 1, 0, 0 ), xyz.x )
rotY = c4d.utils.RotAxisToMatrix( c4d.Vector( 0, 1, 0 ), xyz.y )
rotZ = c4d.utils.RotAxisToMatrix( c4d.Vector( 0, 0, 1 ), xyz.z )
# apply the transform in reversed YXZ order
rh_mat = rotZ * rotX * rotY
# transform the resulting matrix to a quaternion
quat = c4d.Quaternion()
quat.SetHPB( c4d.utils.MatrixToHPB( rh_mat ) )
self.rotation = [quat.v.x, quat.v.y, quat.v.z, quat.w]
ryanbartley commented 7 years ago

And does this cover camera and light, or is that a further calculation?

simongeilfus commented 7 years ago

No this only covers the rotation of objects. I can look into camera and lights as well.