[I have been trying many solutions posted here and there, yet I cannot make this work]
I have a python script on blender side exporting object rotations like this
m = obj.matrix_world.to_euler('XYZ')
rot = mathutils.Vector((math.degrees(m.x),math.degrees(m.y),math.degrees(m.z)))
on unreal side, still in python, setting up rotators for imported objects :
def createRotator(actor_rotation):
rotatorX = unreal.MathLibrary.rotator_from_axis_and_angle(unreal.Vector(0.1,0.0,0.0),actor_rotation.x)
rotatorY = unreal.MathLibrary.rotator_from_axis_and_angle(unreal.Vector(0.0,0.1,0.0),actor_rotation.y)
rotatorZ = unreal.MathLibrary.rotator_from_axis_and_angle(unreal.Vector(0.0,0.0,0.1),actor_rotation.z)
temp = unreal.MathLibrary.compose_rotators(rotatorX,rotatorY)
rotator = unreal.MathLibrary.compose_rotators(temp,rotatorZ)
return rotator
yet the objects are not placed correctly (in term of rotation) in unreal
I tried:
- adding - in front of different rotation members in blender
- flipping the order of the unreal rotators are combined in unreal
- tried y=z and z=-y
- tried z = -z or y=-y
- (I could go on since I been busting my head on this for a whole week)
I been through so many posts, every answer is different, and none of them is working
can someone more clever than I am end my misery and tell me how to solve this ?
thanks
[edit:]
I spawn the actor like this
pos = unreal.Vector(float(row["posx"]),float(row["posy"]),float(row["posz"]))
rot = unreal.Vector(float(row["rotx"]),float(row["roty"]),float(row["rotz"]))
rotator = createRotator(rot)
staticMeshActor = unreal.EditorLevelLibrary.spawn_actor_from_object(staticMesh, pos, rotator)