Last active
April 9, 2022 01:22
-
-
Save Talon1024/ad7d48c160e0d89ff74b0bec49e8eb03 to your computer and use it in GitHub Desktop.
Get uvec/fvec from a Blender Euler or Blender object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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