Combining location, rotation and scale channels into a matrix is a standard task, so while it is easily accomplished by constructing and multiplying 3 matrices, having a standard utility allows for more clear code. The new constructor builds a 4x4 matrix from separate location, rotation and scale values. Rotation can be represented as a 3x3 Matrix, Quaternion or Euler value, while the other two inputs are vectors. Unneeded inputs can be replaced with None. Differential Revision: https://developer.blender.org/D11264
6 lines
269 B
Python
6 lines
269 B
Python
# Compute local object transformation matrix:
|
|
if obj.rotation_mode == 'QUATERNION':
|
|
matrix = mathutils.Matrix.LocRotScale(obj.location, obj.rotation_quaternion, obj.scale)
|
|
else:
|
|
matrix = mathutils.Matrix.LocRotScale(obj.location, obj.rotation_euler, obj.scale)
|