There are imports in the original script that cannot be imported or I would just the same ones, eg. Vector() / Matrix() etc. but they won’t import;
this imports just fine.
import mathutils
this does not
#from mathutils import Vector, Matrix
Error: ImportError: cannot import name ‘Vector’ from ‘mathutils’ (unknown location)
Raw data from the .json file.
"model_look": { "x": -0.7071068286895752, "y": 0.0, "z": -0.7071068286895752 }, "model_right": { "x": -0.7071068286895752, "y": -0.0, "z": 0.7071068286895752 }, "model_up": { "x": -0.0, "y": 1.0, "z": -0.0 },
This is the python code [that someone else wrote, to convert data to blender] I’m trying to translate so that I can properly correct the rotation of an actor in unreal engine instead;
d # Function to create a rotation matrix from two vectors
def rotation_from_vectors(right_vec, forward_vec, up_vec):
# Creating a 4x4 rotation matrix from right, up and forward vectors
rot_mat = Matrix([right_vec, forward_vec, up_vec]).to_4x4()
return rot_mat
#Calculate rotation matrix only once for all objects in the collection
right_vector = Vector((model_right[‘x’], model_right[‘z’], model_right[‘y’]))
look_vector = Vector((model_look[‘x’], model_look[‘z’], model_look[‘y’]))
up_vector = Vector((model_up[‘x’], model_up[‘z’], model_up[‘y’]))
rotation_matrix = rotation_from_vectors(right_vector, look_vector, up_vector)