I am writing an importer in Blender that appends a object and then moves and rotates that object by some stored values I have created in Unity and saved to a Json file.
I found that in order to achieve the desired rotation I must first set my object to
rotation_mode='YXZ' then I can create a new Vector with the order (X,Z,-Y) and my object will be rotated correctly:
degToRad = math.pi / 180 myobj.rotation_mode = 'YXZ' jRot = json['rotation'] myobj.rotation_euler = Vector((jRot['x']*degToRad, jRot['z']*degToRad, -jRot['y']*degToRad )) #Do something here to convert rotation back to XYZ... myobj.rotation_mode = 'XYZ' #this causes the object to rotate unexpectedly
But when I attempt to revert the
rotation_mode back to XYZ the object then rotates to some other orientation and I don't know how to prevent.
I am not sure if I am correctly changing handedness and up/forward with my above example but it seems to work ok.
I am curious if it is possible to change the rotation_mode from
XYZ without the orientation of my object changing?
Or is it possible to somehow apply a "converted" rotation so I can just keep the rotation_mode as
Thanks for help!