Skip to content

Instantly share code, notes, and snippets.

@Talon1024
Last active April 9, 2022 01:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Talon1024/ad7d48c160e0d89ff74b0bec49e8eb03 to your computer and use it in GitHub Desktop.
Save Talon1024/ad7d48c160e0d89ff74b0bec49e8eb03 to your computer and use it in GitHub Desktop.
Get uvec/fvec from a Blender Euler or Blender object
from mathutils import Matrix
def obori_to_vecs(ob):
return euler_to_vecs(ob.rotation_euler)
def euler_to_vecs(eu, fix=Matrix([[-1,0,0],[0,0,1],[0,1,0]])):
mtx_euler = eu.to_matrix()
mtx_fixed = mtx_euler * fix
# mtx_fixed = mtx_euler @ fix # Blender 2.8 and newer
# print("mtx_euler", mtx_euler, "mtx_fixed", mtx_fixed, sep="\n\n")
return (
"$uvec:{:.7f},{:.7f},{:.7f}\n"
"$fvec:{:.7f},{:.7f},{:.7f}").format(
*mtx_fixed[2], *mtx_fixed[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment