I am trying to export a camera position and orientation from Unreal into Maya. The position part I’ve figure out, but I am having trouble with the rotation conversion.
I can’t seem to find a definitive document on UE4 stating the rotation order used for euler angles? I do know that Unreal is z up, and I see from the FBX static mesh import code that Unreal is left-handed, correct? But I need to know that rotation order in order to have the full picture for a correct conversion.
My maya coordinate system is right handed, y up, and I can use whichever rotation order I want. I believe I’ve figured out the manipulations I need to do to get an euler rotation from Unreal into this maya coordinate system, but I am still getting a little bit of error, which I believe is due to difference in rotation order?
For anyone interested, here is a python snippet of what I ended up with for converting Unreal Position and Unreal Euler angles to Maya Position and Maya Euler angles.
from maya.api import OpenMaya as om
unreal_pos = [ <x>, <y>, <z>]
unreal_rot = {
roll: <x rot>,
pitch: <y rot>,
yaw: <z rot>
}
if cmds.upAxis(q=True, axis=True) == 'y':
maya_pos[0] = unreal_pos[0]
# swap z and y position
maya_pos[2] = unreal_pos[1]
maya_pos[1] = unreal_pos[2]
maya_rot = om.MEulerRotation(math.radians(unreal_rot['pitch']), -math.radians(unreal_rot['yaw'] + 90.0), -math.radians(unreal_rot['roll']))
else:
# still need to mirror position on y axis
maya_pos[1] = -maya_pos[1]
maya_rot = om.MEulerRotation(math.radians(unreal_rot['pitch'] + 90.0), -math.radians(unreal_rot['roll']), -math.radians(unreal_rot['yaw'] + 90.0))
Note that you also need to convert from cm to whatever units your maya workspace is using.
With this snippet were you able to match the orientation of objects from unreal inside of maya? Ive been trying to do the same thing and cant quiet say that i’ve been successful. Partly because i dont really understand Euler Angles and such. When i run the snippet above all i get very small numbers, definitely not the same orientation from maya.
In my example below the object’s orientation are defined by “unreal_rot” and after converting the numbers the orientations does not match in maya. Any help or tips are welcome!
from maya.api import OpenMaya as om
unreal_rot = [ 90, 55, -125.0 ]
# swap z and y position
maya_rot = om.MEulerRotation(math.radians(unreal_rot[0]), math.radians(unreal_rot[1] + 90.0), math.radians(unreal_rot[2]))
print maya_rot[0], maya_rot[1], maya_rot[2]