diff --git a/add_curve_aceous_galore.py b/add_curve_aceous_galore.py index be8bbc6e0545a0ea60efce23c8e4619e9d00a6d8..fcc2750260c3d4a8de5a32c47b872d3c344aaf54 100644 --- a/add_curve_aceous_galore.py +++ b/add_curve_aceous_galore.py @@ -603,7 +603,7 @@ def align_matrix(context): obj_align = context.user_preferences.edit.object_align if (context.space_data.type == 'VIEW_3D' and obj_align == 'VIEW'): - rot = context.space_data.region_3d.view_matrix.rotation_part().invert().resize4x4() + rot = context.space_data.region_3d.view_matrix.to_3x3().inverted().to_4x4() else: rot = Matrix() align_matrix = loc * rot diff --git a/add_mesh_BoltFactory/Boltfactory.py b/add_mesh_BoltFactory/Boltfactory.py index aa6e470e12cc35796b8c6a3c1d7d54fb897fd22f..97a489b037e6098af0f8820c81dcf949d86a7c8c 100644 --- a/add_mesh_BoltFactory/Boltfactory.py +++ b/add_mesh_BoltFactory/Boltfactory.py @@ -33,7 +33,7 @@ def align_matrix(context): obj_align = context.user_preferences.edit.object_align if (context.space_data.type == 'VIEW_3D' and obj_align == 'VIEW'): - rot = context.space_data.region_3d.view_matrix.rotation_part().invert().resize4x4() + rot = context.space_data.region_3d.view_matrix.to_3x3().inverted().to_4x4() else: rot = mathutils.Matrix() align_matrix = loc * rot diff --git a/add_mesh_BoltFactory/createMesh.py b/add_mesh_BoltFactory/createMesh.py index cb972f401b55fadf7bceeabb48288ef3f23c2b5b..4cec092d5e1e54e315a1c0a89187c057c27c1c6b 100644 --- a/add_mesh_BoltFactory/createMesh.py +++ b/add_mesh_BoltFactory/createMesh.py @@ -2064,7 +2064,7 @@ def align_matrix(context): obj_align = context.user_preferences.edit.object_align if (context.space_data.type == 'VIEW_3D' and obj_align == 'VIEW'): - rot = context.space_data.region_3d.view_matrix.rotation_part().invert().resize4x4() + rot = context.space_data.region_3d.view_matrix.to_3x3().inverted().to_4x4() else: rot = Matrix() align_matrix = loc * rot diff --git a/curve_simplify.py b/curve_simplify.py index 8b1fc0ade5bf4ea09483cb77f2031863a994669d..8533769dd159d26a5e163bb9a74fae39ade4d8f5 100644 --- a/curve_simplify.py +++ b/curve_simplify.py @@ -254,7 +254,7 @@ def main(context, obj, options): for splineVert in spline.bezier_points.values()] else: # verts from all other types of curves - splineVerts = [splineVert.co.copy().resize3D() + splineVerts = [splineVert.co.to_3d() for splineVert in spline.points.values()] # simplify spline according to mode @@ -304,7 +304,7 @@ def getFcurveData(obj): fcurves = [] for fc in obj.animation_data.action.fcurves: if fc.select: - fcVerts = [vcVert.co.copy().resize3D() + fcVerts = [vcVert.co.to_3d() for vcVert in fc.keyframe_points.values()] fcurves.append(fcVerts) return fcurves diff --git a/io_anim_bvh/export_bvh.py b/io_anim_bvh/export_bvh.py index 25694fa45abec165598a511fde5fc4876c6606fd..2a49f083191edbaef06bf9ae01e386a5bdbe0bb9 100644 --- a/io_anim_bvh/export_bvh.py +++ b/io_anim_bvh/export_bvh.py @@ -151,9 +151,9 @@ def write_armature(context, filepath, frame_start, frame_end, global_scale=1.0): self.rest_local_mat = self.rest_bone.matrix # inverted mats - self.pose_imat = self.pose_mat.copy().invert() - self.rest_arm_imat = self.rest_arm_mat.copy().invert() - self.rest_local_imat = self.rest_local_mat.copy().invert() + self.pose_imat = self.pose_mat.inverted() + self.rest_arm_imat = self.rest_arm_mat.inverted() + self.rest_local_imat = self.rest_local_mat.inverted() self.parent = None self.prev_euler = Euler((0.0, 0.0, 0.0)) @@ -161,7 +161,7 @@ def write_armature(context, filepath, frame_start, frame_end, global_scale=1.0): def update_posedata(self): self.pose_mat = self.pose_bone.matrix - self.pose_imat = self.pose_mat.copy().invert() + self.pose_imat = self.pose_mat.inverted() def __repr__(self): if self.parent: @@ -202,14 +202,14 @@ def write_armature(context, filepath, frame_start, frame_end, global_scale=1.0): if dbone.parent: mat_final = dbone.parent.rest_arm_mat * dbone.parent.pose_imat * dbone.pose_mat * dbone.rest_arm_imat mat_final = itrans * mat_final * trans - loc = mat_final.translation_part() + (dbone.rest_bone.head_local - dbone.parent.rest_bone.head_local) + loc = mat_final.to_translation() + (dbone.rest_bone.head_local - dbone.parent.rest_bone.head_local) else: mat_final = dbone.pose_mat * dbone.rest_arm_imat mat_final = itrans * mat_final * trans - loc = mat_final.translation_part() + dbone.rest_bone.head + loc = mat_final.to_translation() + dbone.rest_bone.head # keep eulers compatible, no jumping on interpolation. - rot = mat_final.rotation_part().invert().to_euler('XYZ', dbone.prev_euler) + rot = mat_final.to_3x3().inverted().to_euler('XYZ', dbone.prev_euler) if not dbone.connected: file.write("%.6f %.6f %.6f " % (loc * global_scale)[:]) diff --git a/io_anim_bvh/import_bvh.py b/io_anim_bvh/import_bvh.py index 464b76bf21992d0a020cb642d6aa0628a47a02b4..9a0126b33cf3d29f5f21570ddb55f3451f0ff738 100644 --- a/io_anim_bvh/import_bvh.py +++ b/io_anim_bvh/import_bvh.py @@ -446,13 +446,13 @@ def bvh_node_dict2armature(context, bvh_name, bvh_nodes, rotate_mode='XYZ', fram bone_name = bvh_node.temp # may not be the same name as the bvh_node, could have been shortened. pose_bone = pose_bones[bone_name] rest_bone = arm_data.bones[bone_name] - bone_rest_matrix = rest_bone.matrix_local.rotation_part() + bone_rest_matrix = rest_bone.matrix_local.to_3x3() bone_rest_matrix_inv = Matrix(bone_rest_matrix) bone_rest_matrix_inv.invert() - bone_rest_matrix_inv.resize4x4() - bone_rest_matrix.resize4x4() + bone_rest_matrix_inv.resize_4x4() + bone_rest_matrix.resize_4x4() bvh_node.temp = (pose_bone, bone, bone_rest_matrix, bone_rest_matrix_inv) # Make a dict for fast access without rebuilding a list all the time. @@ -479,18 +479,18 @@ def bvh_node_dict2armature(context, bvh_name, bvh_nodes, rotate_mode='XYZ', fram if bvh_node.has_rot: # apply rotation order and convert to XYZ # note that the rot_order_str is reversed. - bone_rotation_matrix = Euler((rx, ry, rz), bvh_node.rot_order_str[::-1]).to_matrix().resize4x4() + bone_rotation_matrix = Euler((rx, ry, rz), bvh_node.rot_order_str[::-1]).to_matrix().to_4x4() bone_rotation_matrix = bone_rest_matrix_inv * bone_rotation_matrix * bone_rest_matrix if rotate_mode == 'QUATERNION': - pose_bone.rotation_quaternion = bone_rotation_matrix.to_quat() + pose_bone.rotation_quaternion = bone_rotation_matrix.to_quaternion() else: euler = bone_rotation_matrix.to_euler(bvh_node.rot_order_str, prev_euler[i]) pose_bone.rotation_euler = euler prev_euler[i] = euler if bvh_node.has_loc: - pose_bone.location = (bone_rest_matrix_inv * Matrix.Translation(Vector((lx, ly, lz)) - bvh_node.rest_head_local)).translation_part() + pose_bone.location = (bone_rest_matrix_inv * Matrix.Translation(Vector((lx, ly, lz)) - bvh_node.rest_head_local)).to_translation() if bvh_node.has_loc: pose_bone.keyframe_insert("location") diff --git a/io_anim_camera.py b/io_anim_camera.py index bd0e884e9d491c741fb12577474611e778ed43a2..1a34fdc27b68a8d756f22866cd0051fdcb028107 100644 --- a/io_anim_camera.py +++ b/io_anim_camera.py @@ -87,9 +87,9 @@ def writeCameras(context, filepath, frame_start, frame_end, only_selected=False) fw("obj = cameras['%s']\n" % obj.name) matrix = obj.matrix_world.copy() - fw("obj.location = %s\n" % repr(tuple(matrix.translation_part()))) - fw("obj.scale = %s\n" % repr(tuple(matrix.scale_part()))) - fw("obj.rotation_euler = %s\n" % repr(tuple(matrix.to_euler()))) + fw("obj.location = %r\n" % matrix.to_translation()[:]) + fw("obj.scale = %r\n" % matrix.to_scale()[:]) + fw("obj.rotation_euler = %r\n" % matrix.to_euler()[:]) fw("obj.keyframe_insert('location')\n") fw("obj.keyframe_insert('scale')\n") diff --git a/io_export_directx_x.py b/io_export_directx_x.py index 20739fa5243274c49f82acd9ecc99940d84cbf1c..bb6550643391c3f5fbf4fabc3e213a2d80f2bea6 100644 --- a/io_export_directx_x.py +++ b/io_export_directx_x.py @@ -312,7 +312,7 @@ def WriteArmatureBones(Config, Object, ChildList): PoseBone = PoseBones[Bone.name] if Bone.parent: - BoneMatrix = PoseBone.parent.matrix.copy().invert() + BoneMatrix = PoseBone.parent.matrix.inverted() else: BoneMatrix = Matrix() @@ -625,8 +625,8 @@ def WriteMeshSkinWeights(Config, Object, Mesh): # - Armature Space to Bone Space (The bone matrix needs to be rotated 90 degrees to align with Blender's world axes) #This way, when BoneMatrix is transformed by the bone's Frame matrix, the vertices will be in their final world position. - BoneMatrix = RestBone.matrix_local.copy().invert() - BoneMatrix *= ArmatureObject.matrix_world.copy().invert() + BoneMatrix = RestBone.matrix_local.inverted() + BoneMatrix *= ArmatureObject.matrix_world.inverted() BoneMatrix *= Object.matrix_world Config.File.write("{}{:9f},{:9f},{:9f},{:9f},\n".format(" " * Config.Whitespace, BoneMatrix[0][0], BoneMatrix[0][1], BoneMatrix[0][2], BoneMatrix[0][3])) @@ -697,7 +697,7 @@ def WriteKeyedAnimationSet(Config): else: Config.File.write("{}2;\n{}1;\n".format(" " * Config.Whitespace, " " * Config.Whitespace)) bpy.context.scene.frame_set(bpy.context.scene.frame_start) - Position = Object.matrix_local.translation_part() + Position = Object.matrix_local.to_translation() Config.File.write("{}{}{:9f},{:9f},{:9f};;;\n".format(" " * Config.Whitespace, ("0;3;").ljust(8), Position[0], Position[1], Position[2])) Config.Whitespace -= 1 Config.File.write("{}}}\n".format(" " * Config.Whitespace)) @@ -732,7 +732,7 @@ def WriteKeyedAnimationSet(Config): Rotation[0] = ((RotationFCurves[0][Keyframe] if Keyframe in RotationFCurves[0] else Object.rotation_euler[0]) if RotationFCurves[0] else Object.rotation_euler[0]) Rotation[1] = ((RotationFCurves[1][Keyframe] if Keyframe in RotationFCurves[1] else Object.rotation_euler[1]) if RotationFCurves[1] else Object.rotation_euler[1]) Rotation[2] = ((RotationFCurves[2][Keyframe] if Keyframe in RotationFCurves[2] else Object.rotation_euler[2]) if RotationFCurves[2] else Object.rotation_euler[2]) - Rotation = Rotation.to_quat() + Rotation = Rotation.to_quaternion() Config.File.write("{}{}{:9f},{:9f},{:9f},{:9f};;".format(" " * Config.Whitespace, (str(Keyframe - bpy.context.scene.frame_start) + ";4;").ljust(8), - Rotation[0], Rotation[1], Rotation[2], Rotation[3])) if Keyframe == AllKeyframes[-1]: Config.File.write(";\n") @@ -741,7 +741,7 @@ def WriteKeyedAnimationSet(Config): else: Config.File.write("{}0;\n{}1;\n".format(" " * Config.Whitespace, " " * Config.Whitespace)) bpy.context.scene.frame_set(bpy.context.scene.frame_start) - Rotation = Object.rotation_euler.to_quat() + Rotation = Object.rotation_euler.to_quaternion() Config.File.write("{}{}{:9f},{:9f},{:9f},{:9f};;;\n".format(" " * Config.Whitespace, ("0;4;").ljust(8), -Rotation[0], Rotation[1], Rotation[2], Rotation[3])) Config.Whitespace -= 1 Config.File.write("{}}}\n".format(" " * Config.Whitespace)) @@ -784,7 +784,7 @@ def WriteKeyedAnimationSet(Config): else: Config.File.write("{}1;\n{}1;\n".format(" " * Config.Whitespace, " " * Config.Whitespace)) bpy.context.scene.frame_set(bpy.context.scene.frame_start) - Scale = Object.matrix_local.scale_part() + Scale = Object.matrix_local.to_scale() Config.File.write("{}{}{:9f},{:9f},{:9f};;;\n".format(" " * Config.Whitespace, ("0;3;").ljust(8), Scale[0], Scale[1], Scale[2])) Config.Whitespace -= 1 Config.File.write("{}}}\n".format(" " * Config.Whitespace)) @@ -850,12 +850,12 @@ def WriteKeyedAnimationSet(Config): bpy.context.scene.frame_set(Keyframe) if Bone.parent: - PoseMatrix = Bone.parent.matrix.copy().invert() + PoseMatrix = Bone.parent.matrix.inverted() else: PoseMatrix = Matrix() PoseMatrix *= Bone.matrix - Position = PoseMatrix.translation_part() + Position = PoseMatrix.to_translation() Config.File.write("{}{}{:9f},{:9f},{:9f};;".format(" " * Config.Whitespace, (str(Keyframe - bpy.context.scene.frame_start) + ";3;").ljust(8), Position[0], Position[1], Position[2])) if Keyframe == AllKeyframes[-1]: Config.File.write(";\n") @@ -893,12 +893,12 @@ def WriteKeyedAnimationSet(Config): bpy.context.scene.frame_set(Keyframe) if Bone.parent: - PoseMatrix = Bone.parent.matrix.copy().invert() + PoseMatrix = Bone.parent.matrix.inverted() else: PoseMatrix = Matrix() PoseMatrix *= Bone.matrix - Rotation = PoseMatrix.rotation_part().to_quat() + Rotation = PoseMatrix.to_3x3().to_quaternion() Config.File.write("{}{}{:9f},{:9f},{:9f},{:9f};;".format(" " * Config.Whitespace, (str(Keyframe - bpy.context.scene.frame_start) + ";4;").ljust(8), -Rotation[0], Rotation[1], Rotation[2], Rotation[3])) if Keyframe == AllKeyframes[-1]: Config.File.write(";\n") @@ -936,12 +936,12 @@ def WriteKeyedAnimationSet(Config): bpy.context.scene.frame_set(Keyframe) if Bone.parent: - PoseMatrix = Bone.parent.matrix.copy().invert() + PoseMatrix = Bone.parent.matrix.inverted() else: PoseMatrix = Matrix() PoseMatrix *= Bone.matrix - Scale = PoseMatrix.scale_part() + Scale = PoseMatrix.to_scale() Config.File.write("{}{}{:9f},{:9f},{:9f};;".format(" " * Config.Whitespace, (str(Keyframe - bpy.context.scene.frame_start) + ";3;").ljust(8), Scale[0], Scale[1], Scale[2])) if Keyframe == AllKeyframes[-1]: Config.File.write(";\n") @@ -986,7 +986,7 @@ def WriteFullAnimationSet(Config): Config.File.write("{}2;\n{}{};\n".format(" " * Config.Whitespace, " " * Config.Whitespace, KeyframeCount)) for Frame in range(0, KeyframeCount): bpy.context.scene.frame_set(Frame + bpy.context.scene.frame_start) - Position = Object.matrix_local.translation_part() + Position = Object.matrix_local.to_translation() Config.File.write("{}{}{:9f},{:9f},{:9f};;".format(" " * Config.Whitespace, (str(Frame) + ";3;").ljust(8), Position[0], Position[1], Position[2])) if Frame == KeyframeCount-1: Config.File.write(";\n") @@ -1005,7 +1005,7 @@ def WriteFullAnimationSet(Config): Config.File.write("{}0;\n{}{};\n".format(" " * Config.Whitespace, " " * Config.Whitespace, KeyframeCount)) for Frame in range(0, KeyframeCount): bpy.context.scene.frame_set(Frame + bpy.context.scene.frame_start) - Rotation = Object.rotation_euler.to_quat() + Rotation = Object.rotation_euler.to_quaternion() Config.File.write("{}{}{:9f},{:9f},{:9f},{:9f};;".format(" " * Config.Whitespace, (str(Frame) + ";4;").ljust(8), -Rotation[0], Rotation[1], Rotation[2], Rotation[3])) if Frame == KeyframeCount-1: Config.File.write(";\n") @@ -1024,7 +1024,7 @@ def WriteFullAnimationSet(Config): Config.File.write("{}1;\n{}{};\n".format(" " * Config.Whitespace, " " * Config.Whitespace, KeyframeCount)) for Frame in range(0, KeyframeCount): bpy.context.scene.frame_set(Frame + bpy.context.scene.frame_start) - Scale = Object.matrix_local.scale_part() + Scale = Object.matrix_local.to_scale() Config.File.write("{}{}{:9f},{:9f},{:9f};;".format(" " * Config.Whitespace, (str(Frame) + ";3;").ljust(8), Scale[0], Scale[1], Scale[2])) if Frame == KeyframeCount-1: Config.File.write(";\n") @@ -1061,12 +1061,12 @@ def WriteFullAnimationSet(Config): bpy.context.scene.frame_set(Frame + bpy.context.scene.frame_start) if Bone.parent: - PoseMatrix = Bone.parent.matrix.copy().invert() + PoseMatrix = Bone.parent.matrix.inverted() else: PoseMatrix = Matrix() PoseMatrix *= Bone.matrix - Position = PoseMatrix.translation_part() + Position = PoseMatrix.to_translation() Config.File.write("{}{}{:9f},{:9f},{:9f};;".format(" " * Config.Whitespace, (str(Frame) + ";3;").ljust(8), Position[0], Position[1], Position[2])) if Frame == KeyframeCount-1: Config.File.write(";\n") @@ -1086,7 +1086,7 @@ def WriteFullAnimationSet(Config): for Frame in range(0, KeyframeCount): bpy.context.scene.frame_set(Frame + bpy.context.scene.frame_start) - Rotation = Bones[Bone.name].matrix.to_quat() * Bone.rotation_quaternion + Rotation = Bones[Bone.name].matrix.to_quaternion() * Bone.rotation_quaternion Config.File.write("{}{}{:9f},{:9f},{:9f},{:9f};;".format(" " * Config.Whitespace, (str(Frame) + ";4;").ljust(8), -Rotation[0], Rotation[1], Rotation[2], Rotation[3])) if Frame == KeyframeCount-1: @@ -1108,12 +1108,12 @@ def WriteFullAnimationSet(Config): bpy.context.scene.frame_set(Frame + bpy.context.scene.frame_start) if Bone.parent: - PoseMatrix = Bone.parent.matrix.copy().invert() + PoseMatrix = Bone.parent.matrix.inverted() else: PoseMatrix = Matrix() PoseMatrix *= Bone.matrix - Scale = PoseMatrix.scale_part() + Scale = PoseMatrix.to_scale() Config.File.write("{}{}{:9f},{:9f},{:9f};;".format(" " * Config.Whitespace, (str(Frame) + ";3;").ljust(8), Scale[0], Scale[1], Scale[2])) if Frame == KeyframeCount-1: Config.File.write(";\n") diff --git a/io_export_unreal_psk_psa.py b/io_export_unreal_psk_psa.py index 738e12057f8792cc44813aaad330abc42d34365a..dd5e29ed9685156fc3071868c83531fd1778fe47 100644 --- a/io_export_unreal_psk_psa.py +++ b/io_export_unreal_psk_psa.py @@ -969,9 +969,9 @@ def parse_bone(blender_bone, psk_file, psa_file, parent_id, is_root_bone, parent if child_parent != None: quat_root = blender_bone.matrix - quat = make_fquat(quat_root.to_quat()) + quat = make_fquat(quat_root.to_quaternion()) - quat_parent = child_parent.matrix.to_quat().inverse() + quat_parent = child_parent.matrix.to_quaternion().inverse() parent_head = child_parent.head * quat_parent parent_tail = child_parent.tail * quat_parent @@ -980,10 +980,10 @@ def parse_bone(blender_bone, psk_file, psa_file, parent_id, is_root_bone, parent # ROOT BONE #This for root set_position = blender_bone.head * parent_matrix #ARMATURE OBJECT Locction - rot_mat = blender_bone.matrix * parent_matrix.rotation_part() #ARMATURE OBJECT Rotation + rot_mat = blender_bone.matrix * parent_matrix.to_3x3() #ARMATURE OBJECT Rotation #print(dir(rot_mat)) - quat = make_fquat_default(rot_mat.to_quat()) + quat = make_fquat_default(rot_mat.to_quaternion()) #print ("[[======= FINAL POSITION:", set_position) final_parent_id = parent_id @@ -1266,8 +1266,8 @@ def parse_animation(blender_scene, blender_armatures, psa_file): parentposemat = mathutils.Matrix(parent_pose.matrix) #blender 2.4X it been flip around with new 2.50 (mat1 * mat2) should now be (mat2 * mat1) posebonemat = parentposemat.invert() * posebonemat - head = posebonemat.translation_part() - quat = posebonemat.to_quat().normalize() + head = posebonemat.to_translation() + quat = posebonemat.to_quaternion().normalize() vkey = VQuatAnimKey() vkey.Position.X = head.x vkey.Position.Y = head.y @@ -1411,8 +1411,8 @@ def parse_animation(blender_scene, blender_armatures, psa_file): parentposemat = mathutils.Matrix(parent_pose.matrix) #blender 2.4X it been flip around with new 2.50 (mat1 * mat2) should now be (mat2 * mat1) posebonemat = parentposemat.invert() * posebonemat - head = posebonemat.translation_part() - quat = posebonemat.to_quat().normalize() + head = posebonemat.to_translation() + quat = posebonemat.to_quaternion().normalize() vkey = VQuatAnimKey() vkey.Position.X = head.x vkey.Position.Y = head.y diff --git a/io_import_images_as_planes.py b/io_import_images_as_planes.py index 0180e474320a60884766c07ad0da4a4b2e50354a..3156d29394b76af9ace0671de98aa72bb7b98970 100644 --- a/io_import_images_as_planes.py +++ b/io_import_images_as_planes.py @@ -185,7 +185,7 @@ def align_planes(self, planes): offset += (plane.dimensions.x / 2) + gap if i == 0: continue move_local = mathutils.Vector((offset, 0, 0)) - move_world = plane.location + move_local * plane.matrix_world.copy().invert() + move_world = plane.location + move_local * plane.matrix_world.inverted() plane.location += move_world offset += (plane.dimensions.x / 2) diff --git a/io_import_scene_dxf.py b/io_import_scene_dxf.py index bb776a8224209721383c0a258f1e0e7b0df801cb..5ab94d541fa44685a30f9178d83f2c2175a933b9 100644 --- a/io_import_scene_dxf.py +++ b/io_import_scene_dxf.py @@ -1414,15 +1414,15 @@ def transform(normal, rotation, obj): #---------------------------------------- """ ma = Matrix(((1,0,0,0),(0,1,0,0),(0,0,1,0),(0,0,0,1))) o = Vector(obj.location) - ma_new = getOCS(normal) - if ma_new: - ma = ma_new.resize4x4() - o = o * ma #.copy().invert() + ma = getOCS(normal) + if ma: + ma.resize_4x4() + o = o * ma #.inverted() if rotation != 0: g = radians(-rotation) rmat = Matrix(((cos(g), -sin(g), 0), (sin(g), cos(g), 0), (0, 0, 1))) - ma = ma * rmat.resize4x4() + ma = ma * rmat.to_4x4() obj.matrix_world = ma #must be matrix4x4 obj.location = o diff --git a/io_import_scene_unreal_psk.py b/io_import_scene_unreal_psk.py index 2fcb70d149427cf7e49dfb9a36ff327e18d85594..4fe9733327dbeab00d7aad168910932a851122d1 100644 --- a/io_import_scene_unreal_psk.py +++ b/io_import_scene_unreal_psk.py @@ -389,10 +389,10 @@ def pskimport(infile): #print( "LINKING:" , bone.parent ,"j") parentbone = ob_new.data.edit_bones[bone.parent] newbone.parent = parentbone - rotmatrix = bone.bindmat.to_matrix().resize4x4().rotation_part() + rotmatrix = bone.bindmat.to_matrix().to_4x4().to_3x3() # XXX, redundant matrix conversion? - #parent_head = parentbone.head * parentbone.matrix.to_quat().inverse() - #parent_tail = parentbone.tail * parentbone.matrix.to_quat().inverse() + #parent_head = parentbone.head * parentbone.matrix.to_quaternion().inverse() + #parent_tail = parentbone.tail * parentbone.matrix.to_quaternion().inverse() #location=Vector(pos_x,pos_y,pos_z) #set_position = (parent_tail - parent_head) + location #print("tmp head:",set_position) @@ -409,7 +409,7 @@ def pskimport(infile): newbone.tail.y = parentbone.head.y + (pos_y + bonesize * rotmatrix[1][1]) newbone.tail.z = parentbone.head.z + (pos_z + bonesize * rotmatrix[1][2]) else: - rotmatrix = bone.bindmat.to_matrix().resize4x4().rotation_part() + rotmatrix = bone.bindmat.to_matrix().resize_4x4().to_3x3() # XXX, redundant matrix conversion? newbone.head.x = bone.bindpos[0] newbone.head.y = bone.bindpos[1] newbone.head.z = bone.bindpos[2] diff --git a/io_scene_3ds/export_3ds.py b/io_scene_3ds/export_3ds.py index 5a4672971c54f937efd9847dc7e544d661b352dd..1a85c5e2557571439f5881649f505a3246d3da88 100644 --- a/io_scene_3ds/export_3ds.py +++ b/io_scene_3ds/export_3ds.py @@ -777,7 +777,7 @@ def make_track_chunk(ID, obj): track_chunk.add_variable("position", _3ds_point_3d(obj.getLocation())) elif ID==ROT_TRACK_TAG: # rotation (quaternion, angle first, followed by axis): - q = obj.getEuler().to_quat() + q = obj.getEuler().to_quaternion() # XXX, todo! track_chunk.add_variable("rotation", _3ds_point_4d((q.angle, q.axis[0], q.axis[1], q.axis[2]))) elif ID==SCL_TRACK_TAG: # scale vector: diff --git a/io_scene_3ds/import_3ds.py b/io_scene_3ds/import_3ds.py index 26093078335b0a08bfb6f5a0f1e43671d48b1988..33abcd4de5f6f6020d68915b6ec5fd9e8aae0f9f 100644 --- a/io_scene_3ds/import_3ds.py +++ b/io_scene_3ds/import_3ds.py @@ -822,7 +822,7 @@ def load_3ds(filepath, context, IMPORT_CONSTRAIN_BOUNDS=10.0, IMAGE_SEARCH=True, for ob in importedObjects: if ob.type == 'MESH': me = ob.data - me.transform(ob.matrix_local.copy().invert()) + me.transform(ob.matrix_local.inverted()) # Done DUMMYVERT """ diff --git a/io_scene_fbx/export_fbx.py b/io_scene_fbx/export_fbx.py index f1eabc67726dd07dc7f4f03dfcc9f70aab559135..a5d173c5fae8d9d0de071d591ad992dc2c168816 100644 --- a/io_scene_fbx/export_fbx.py +++ b/io_scene_fbx/export_fbx.py @@ -413,7 +413,7 @@ def save(operator, context, filepath="", # self.restMatrix = blenBone.matrix['ARMATURESPACE'] # not used yet - # self.restMatrixInv = self.restMatrix.copy().invert() + # self.restMatrixInv = self.restMatrix.inverted() # self.restMatrixLocal = None # set later, need parent matrix self.parent = None @@ -429,7 +429,7 @@ def save(operator, context, filepath="", ''' def calcRestMatrixLocal(self): if self.parent: - self.restMatrixLocal = self.restMatrix * self.parent.restMatrix.copy().invert() + self.restMatrixLocal = self.restMatrix * self.parent.restMatrix.inverted() else: self.restMatrixLocal = self.restMatrix.copy() ''' @@ -513,20 +513,20 @@ def save(operator, context, filepath="", def parRelMatrix(self): if self.fbxParent: - return self.fbxParent.matrixWorld.copy().invert() * self.matrixWorld + return self.fbxParent.matrixWorld.inverted() * self.matrixWorld else: return self.matrixWorld def setPoseFrame(self, f, fake=False): if fake: # annoying, have to clear GLOBAL_MATRIX - self.__anim_poselist[f] = self.matrixWorld * GLOBAL_MATRIX.copy().invert() + self.__anim_poselist[f] = self.matrixWorld * GLOBAL_MATRIX.inverted() else: self.__anim_poselist[f] = self.blenObject.matrix_world.copy() def getAnimParRelMatrix(self, frame): if self.fbxParent: - #return (self.__anim_poselist[frame] * self.fbxParent.__anim_poselist[frame].copy().invert() ) * GLOBAL_MATRIX + #return (self.__anim_poselist[frame] * self.fbxParent.__anim_poselist[frame].inverted() ) * GLOBAL_MATRIX return (GLOBAL_MATRIX * self.fbxParent.__anim_poselist[frame]).invert() * (GLOBAL_MATRIX * self.__anim_poselist[frame]) else: return GLOBAL_MATRIX * self.__anim_poselist[frame] @@ -534,9 +534,9 @@ def save(operator, context, filepath="", def getAnimParRelMatrixRot(self, frame): obj_type = self.blenObject.type if self.fbxParent: - matrix_rot = ((GLOBAL_MATRIX * self.fbxParent.__anim_poselist[frame]).invert() * (GLOBAL_MATRIX * self.__anim_poselist[frame])).rotation_part() + matrix_rot = ((GLOBAL_MATRIX * self.fbxParent.__anim_poselist[frame]).invert() * (GLOBAL_MATRIX * self.__anim_poselist[frame])).to_3x3() else: - matrix_rot = (GLOBAL_MATRIX * self.__anim_poselist[frame]).rotation_part() + matrix_rot = (GLOBAL_MATRIX * self.__anim_poselist[frame]).to_3x3() # Lamps need to be rotated if obj_type == 'LAMP': @@ -609,7 +609,7 @@ def save(operator, context, filepath="", #par_matrix = mtx4_z90 * (parent.matrix['ARMATURESPACE'] * matrix_mod) par_matrix = parent.matrix_local * mtx4_z90 # dont apply armature matrix anymore # par_matrix = mtx4_z90 * parent.matrix['ARMATURESPACE'] # dont apply armature matrix anymore - matrix = par_matrix.copy().invert() * matrix + matrix = par_matrix.inverted() * matrix loc, rot, scale = matrix.decompose() matrix_rot = rot.to_matrix() @@ -1091,7 +1091,7 @@ def save(operator, context, filepath="", do_light = not (light.use_only_shadow or (not light.use_diffuse and not light.use_specular)) do_shadow = (light.shadow_method in ('RAY_SHADOW', 'BUFFER_SHADOW')) - scale = abs(GLOBAL_MATRIX.scale_part()[0]) # scale is always uniform in this case + scale = abs(GLOBAL_MATRIX.to_scale()[0]) # scale is always uniform in this case file.write('\n\t\t\tProperty: "LightType", "enum", "",%i' % light_type) file.write('\n\t\t\tProperty: "CastLightOnObject", "bool", "",1') @@ -1434,10 +1434,10 @@ def save(operator, context, filepath="", if my_mesh.fbxParent: # TODO FIXME, this case is broken in some cases. skinned meshes just shouldnt have parents where possible! - m = (my_mesh.matrixWorld.copy().invert() * my_bone.fbxArm.matrixWorld.copy() * my_bone.restMatrix) * mtx4_z90 + m = (my_mesh.matrixWorld.inverted() * my_bone.fbxArm.matrixWorld.copy() * my_bone.restMatrix) * mtx4_z90 else: # Yes! this is it... - but dosnt work when the mesh is a. - m = (my_mesh.matrixWorld.copy().invert() * my_bone.fbxArm.matrixWorld.copy() * my_bone.restMatrix) * mtx4_z90 + m = (my_mesh.matrixWorld.inverted() * my_bone.fbxArm.matrixWorld.copy() * my_bone.restMatrix) * mtx4_z90 #m = mtx4_z90 * my_bone.restMatrix matstr = mat4x4str(m) @@ -2728,9 +2728,9 @@ Takes: {''') for TX_LAYER, TX_CHAN in enumerate('TRS'): # transform, rotate, scale if TX_CHAN == 'T': - context_bone_anim_vecs = [mtx[0].translation_part() for mtx in context_bone_anim_mats] + context_bone_anim_vecs = [mtx[0].to_translation() for mtx in context_bone_anim_mats] elif TX_CHAN == 'S': - context_bone_anim_vecs = [mtx[0].scale_part() for mtx in context_bone_anim_mats] + context_bone_anim_vecs = [mtx[0].to_scale() for mtx in context_bone_anim_mats] elif TX_CHAN == 'R': # Was.... # elif TX_CHAN=='R': context_bone_anim_vecs = [mtx[1].to_euler() for mtx in context_bone_anim_mats] diff --git a/io_scene_obj/export_obj.py b/io_scene_obj/export_obj.py index 7fdff18368bd8264e30f6fab756a2aee42f88859..d3fd917eb093f799b6788f778e0f5b3994977a6d 100644 --- a/io_scene_obj/export_obj.py +++ b/io_scene_obj/export_obj.py @@ -218,7 +218,7 @@ def write_nurb(file, ob, ob_mat): do_endpoints = (do_closed == 0) and nu.use_endpoint_u for pt in nu.points: - pt = pt.co.copy().resize3D() * ob_mat + pt = pt.co.to_3d() * ob_mat file.write('v %.6f %.6f %.6f\n' % (pt[0], pt[1], pt[2])) pt_num += 1 tot_verts += pt_num diff --git a/io_scene_x3d/export_x3d.py b/io_scene_x3d/export_x3d.py index 822065b2883cfa3768efdd6d1150828eca071c2d..a3e37648a11b4df76136749a7ed1552f7cb07682 100644 --- a/io_scene_x3d/export_x3d.py +++ b/io_scene_x3d/export_x3d.py @@ -47,7 +47,7 @@ def round_color(col, cp): def matrix_direction(mtx): - return (mathutils.Vector((0.0, 0.0, -1.0)) * mtx.rotation_part()).normalize()[:] + return (mathutils.Vector((0.0, 0.0, -1.0)) * mtx.to_3x3()).normalize()[:] ########################################################## @@ -204,7 +204,7 @@ class x3d_class: dx, dy, dz = matrix_direction(mtx) - location = mtx.translation_part()[:] + location = mtx.to_translation()[:] radius = lamp.distance * math.cos(beamWidth) # radius = lamp.dist*math.cos(beamWidth) @@ -247,7 +247,7 @@ class x3d_class: amb_intensity = 0.0 intensity = min(lamp.energy / 1.75, 1.0) - location = mtx.translation_part()[:] + location = mtx.to_translation()[:] self.file.write("<PointLight DEF=\"%s\" " % safeName) self.file.write("ambientIntensity=\"%.4f\" " % amb_intensity) diff --git a/io_scene_x3d/import_x3d.py b/io_scene_x3d/import_x3d.py index 78a1460504e6c98ccdc86203610732b41e3523cf..307f6670d1a2597015c40f4a1316fe013a664c11 100644 --- a/io_scene_x3d/import_x3d.py +++ b/io_scene_x3d/import_x3d.py @@ -1465,8 +1465,8 @@ def translateTransform(node, ancestry): tx = node.getFieldAsFloatTuple('translation', None, ancestry) # (0.0, 0.0, 0.0) if cent: - cent_mat = Matrix.Translation(Vector(cent)).resize4x4() - cent_imat = cent_mat.copy().invert() + cent_mat = Matrix.Translation(cent) + cent_imat = cent_mat.inverted() else: cent_mat = cent_imat = None @@ -1482,12 +1482,12 @@ def translateTransform(node, ancestry): if scaori: scaori_mat = translateRotation(scaori) - scaori_imat = scaori_mat.copy().invert() + scaori_imat = scaori_mat.inverted() else: scaori_mat = scaori_imat = None if tx: - tx_mat = Matrix.Translation(Vector(tx)).resize4x4() + tx_mat = Matrix.Translation(tx) else: tx_mat = None @@ -1509,8 +1509,8 @@ def translateTexTransform(node, ancestry): if cent: # cent is at a corner by default - cent_mat = Matrix.Translation(Vector(cent).resize3D()).resize4x4() - cent_imat = cent_mat.copy().invert() + cent_mat = Matrix.Translation(Vector(cent).resize_3d()) + cent_imat = cent_mat.inverted() else: cent_mat = cent_imat = None @@ -1525,7 +1525,7 @@ def translateTexTransform(node, ancestry): sca_mat = None if tx: - tx_mat = Matrix.Translation(Vector(tx).resize3D()).resize4x4() + tx_mat = Matrix.Translation(Vector(tx).resize_3d()) else: tx_mat = None @@ -2042,7 +2042,7 @@ def importMesh_Box(geom, ancestry): # Scale the box to the size set scale_mat = Matrix(((size[0], 0, 0), (0, size[1], 0), (0, 0, size[2]))) * 0.5 - bpymesh.transform(scale_mat.resize4x4()) + bpymesh.transform(scale_mat.to_4x4()) return bpymesh @@ -2266,7 +2266,7 @@ def importLamp_DirectionalLight(node, ancestry): bpylamp.color = color # lamps have their direction as -z, yup - mtx = Vector(direction).to_track_quat('-Z', 'Y').to_matrix().resize4x4() + mtx = Vector(direction).to_track_quat('-Z', 'Y').to_matrix().to_4x4() return bpylamp, mtx @@ -2305,7 +2305,7 @@ def importLamp_SpotLight(node, ancestry): # Convert # lamps have their direction as -z, y==up - mtx = Matrix.Translation(Vector(location)) * Vector(direction).to_track_quat('-Z', 'Y').to_matrix().resize4x4() + mtx = Matrix.Translation(location) * Vector(direction).to_track_quat('-Z', 'Y').to_matrix().to_4x4() return bpylamp, mtx diff --git a/modules/add_utils.py b/modules/add_utils.py index 62bd5f78304a59859556a1aa7036662db5d377c1..bc54abc6cee5b40e624b890f88a075169846f6a8 100644 --- a/modules/add_utils.py +++ b/modules/add_utils.py @@ -47,19 +47,19 @@ def add_object_align_init(context, operator): and operator.properties.is_property_set("location") and operator.properties.is_property_set("rotation")): location = mathutils.Matrix.Translation(mathutils.Vector(operator.properties.location)) - rotation = mathutils.Euler(operator.properties.rotation).to_matrix().resize4x4() + rotation = mathutils.Euler(operator.properties.rotation).to_matrix().to_4x4() else: # TODO, local view cursor! location = mathutils.Matrix.Translation(context.scene.cursor_location) if context.user_preferences.edit.object_align == 'VIEW' and context.space_data.type == 'VIEW_3D': - rotation = context.space_data.region_3d.view_matrix.rotation_part().invert().resize4x4() + rotation = context.space_data.region_3d.view_matrix.to_3x3().inverted().to_4x4() else: rotation = mathutils.Matrix() # set the operator properties if operator: - operator.properties.location = location.translation_part() + operator.properties.location = location.to_translation() operator.properties.rotation = rotation.to_euler() return location * rotation diff --git a/render_povray/render.py b/render_povray/render.py index 85b425c0f0b9e8b009fb04db0eb461d7bb8ad316..cd1c80a5d6cffcbb33dded99a3b0f3e0a862b85a 100644 --- a/render_povray/render.py +++ b/render_povray/render.py @@ -516,7 +516,7 @@ def write_pov(filename, scene=None, info_callback=None): # compute resolution Qsize = float(render.resolution_x) / float(render.resolution_y) tabWrite("#declare camLocation = <%.6f, %.6f, %.6f>;\n" % (matrix[3][0], matrix[3][1], matrix[3][2])) - tabWrite("#declare camLookAt = <%.6f, %.6f, %.6f>;\n" % tuple([degrees(e) for e in matrix.rotation_part().to_euler()])) + tabWrite("#declare camLookAt = <%.6f, %.6f, %.6f>;\n" % tuple([degrees(e) for e in matrix.to_3x3().to_euler()])) tabWrite("camera {\n") if scene.pov_baking_enable and active_object and active_object.type == 'MESH': @@ -533,7 +533,7 @@ def write_pov(filename, scene=None, info_callback=None): tabWrite("up <0, 1, 0>\n") tabWrite("angle %f\n" % (360.0 * atan(16.0 / camera.data.lens) / pi)) - tabWrite("rotate <%.6f, %.6f, %.6f>\n" % tuple([degrees(e) for e in matrix.rotation_part().to_euler()])) + tabWrite("rotate <%.6f, %.6f, %.6f>\n" % tuple([degrees(e) for e in matrix.to_3x3().to_euler()])) tabWrite("translate <%.6f, %.6f, %.6f>\n" % (matrix[3][0], matrix[3][1], matrix[3][2])) if camera.data.pov_dof_enable and focal_point != 0: tabWrite("aperture %.3g\n" % camera.data.pov_dof_aperture) diff --git a/rigify/rigs/misc/delta.py b/rigify/rigs/misc/delta.py index 2157970a75af634caff2db0d13a0a7f0936f34d8..bc5f7eba999cbdc79e351707be650367f0ccc497 100644 --- a/rigify/rigs/misc/delta.py +++ b/rigify/rigs/misc/delta.py @@ -144,15 +144,15 @@ def set_mat(obj, bone_name, matrix): a.transform(matrix) - d = acos(a.matrix.to_quat().dot(matrix.to_quat())) * 2 + d = acos(a.matrix.to_quaternion().dot(matrix.to_quaternion())) * 2.0 roll_1 = a.roll + d roll_2 = a.roll - d a.roll = roll_1 - d1 = a.matrix.to_quat().dot(matrix.to_quat()) + d1 = a.matrix.to_quaternion().dot(matrix.to_quaternion()) a.roll = roll_2 - d2 = a.matrix.to_quat().dot(matrix.to_quat()) + d2 = a.matrix.to_quaternion().dot(matrix.to_quaternion()) if d1 > d2: a.roll = roll_1 diff --git a/rigify/utils.py b/rigify/utils.py index 84d4c4f1a76b8fc9deeba46fea141d8747c85e6c..f0a19aac67f652bb4d81f7f70b2ad6fd8f176275 100644 --- a/rigify/utils.py +++ b/rigify/utils.py @@ -237,12 +237,12 @@ def obj_to_bone(obj, rig, bone_name): mat = rig.matrix_world * bone.matrix_local - obj.location = mat.translation_part() + obj.location = mat.to_translation() obj.rotation_mode = 'XYZ' obj.rotation_euler = mat.to_euler() - scl = mat.scale_part() + scl = mat.to_scale() scl_avg = (scl[0] + scl[1] + scl[2]) / 3 obj.scale = (bone.length * scl_avg), (bone.length * scl_avg), (bone.length * scl_avg) diff --git a/space_view3d_copy_attributes.py b/space_view3d_copy_attributes.py index b31a66c25d22415030c43fea4f9ea8cae7dcd2e7..2b1ccebe7ac834922e7759f6f746afbe52aae9d1 100644 --- a/space_view3d_copy_attributes.py +++ b/space_view3d_copy_attributes.py @@ -121,13 +121,13 @@ def getmat(bone, active, context, ignoreparent): def rotcopy(item, mat): '''copy rotation to item from matrix mat depending on item.rotation_mode''' if item.rotation_mode == 'QUATERNION': - item.rotation_quaternion = mat.rotation_part().to_quat() + item.rotation_quaternion = mat.to_3x3().to_quaternion() elif item.rotation_mode == 'AXIS_ANGLE': - quat = mat.rotation_part().to_quat() + quat = mat.to_3x3().to_quaternion() item.rotation_axis_angle = Vector([quat.axis[0], quat.axis[1], quat.axis[2], quat.angle]) else: - item.rotation_euler = mat.rotation_part().to_euler(item.rotation_mode) + item.rotation_euler = mat.to_3x3().to_euler(item.rotation_mode) def pLoopExec(self, context, funk): @@ -146,7 +146,7 @@ def pLocLocExec(bone, active, context): def pLocRotExec(bone, active, context): - rotcopy(bone, active.matrix_basis.rotation_part()) + rotcopy(bone, active.matrix_basis.to_3x3()) def pLocScaExec(bone, active, context): @@ -154,7 +154,7 @@ def pLocScaExec(bone, active, context): def pVisLocExec(bone, active, context): - bone.location = getmat(bone, active, context, False).translation_part() + bone.location = getmat(bone, active, context, False).to_translation() def pVisRotExec(bone, active, context): @@ -165,7 +165,7 @@ def pVisRotExec(bone, active, context): def pVisScaExec(bone, active, context): bone.scale = getmat(bone, active, context, not context.active_object.data.bones[bone.name].use_inherit_scale)\ - .scale_part() + .to_scale() def pDrwExec(bone, active, context): @@ -289,7 +289,7 @@ def obLoc(ob, active, context): def obRot(ob, active, context): - rotcopy(ob, active.matrix_world.rotation_part()) + rotcopy(ob, active.matrix_world.to_3x3()) def obSca(ob, active, context): diff --git a/space_view3d_math_vis/draw.py b/space_view3d_math_vis/draw.py index a7f25d37da0c9bc27626892b4305391c74a231a1..5f2593b54f37f3b087b2df71d8ab8b195f00a5f0 100644 --- a/space_view3d_math_vis/draw.py +++ b/space_view3d_math_vis/draw.py @@ -193,7 +193,7 @@ def draw_callback_view(self, context): glBegin(GL_POINTS) glColor3f(0.5, 0.5, 1) for key, vec in data_vector.items(): - glVertex3f(*vec.copy().resize3D()) + glVertex3f(*vec.to_3d()) glEnd(); glPointSize(1.0) @@ -219,13 +219,13 @@ def draw_callback_view(self, context): if data_quat: loc = context.scene.cursor_location.copy() for quat in data_quat.values(): - mat = quat.to_matrix().resize4x4() + mat = quat.to_matrix().to_4x4() mat[3][0:3] = loc draw_matrix(mat) if data_euler: loc = context.scene.cursor_location.copy() for eul in data_euler.values(): - mat = eul.to_matrix().resize4x4() + mat = eul.to_matrix().to_4x4() mat[3][0:3] = loc draw_matrix(mat) diff --git a/space_view3d_math_vis/utils.py b/space_view3d_math_vis/utils.py index 5511cf3066471e964f84ec03b139929b29d75750..b0a7757dbfadac87da411d36dedf993da0b939ad 100644 --- a/space_view3d_math_vis/utils.py +++ b/space_view3d_math_vis/utils.py @@ -44,11 +44,11 @@ def console_math_data(): if var_type is Matrix: if var.col_size != 4 or var.row_size != 4: - var = var.copy().resize4x4() + var = var.to_4x4() data_matrix[key] = var elif var_type is Vector: if len(var) < 3: - var = var.copy().resize3D() + var = var.to_3d() data_vector[key] = var elif var_type is Quaternion: data_quat[key] = var diff --git a/space_view3d_panel_measure.py b/space_view3d_panel_measure.py index e137840ff0f1022059cce226724fb8a3a66c6ce0..8fd007125c05ed3fa75973f9978558b45061ec01 100644 --- a/space_view3d_panel_measure.py +++ b/space_view3d_panel_measure.py @@ -237,7 +237,7 @@ def getMeasurePoints(context): # local ... the object center to the 3D cursor. # global ... the origin to the 3D cursor. cur_loc = sce.cursor_location - obj_loc = obj.matrix_world.translation_part() + obj_loc = obj.matrix_world.to_translation() # Convert to local space, if needed. if measureLocal(sce): @@ -272,7 +272,7 @@ def getMeasurePoints(context): # Two vertices selected. # We measure the distance between the # two selected vertices. - obj_loc = obj.matrix_world.translation_part() + obj_loc = obj.matrix_world.to_translation() vert1_loc = verts_selected[0].co.copy() vert2_loc = verts_selected[1].co.copy() @@ -299,15 +299,15 @@ def getMeasurePoints(context): # 2 objects selected. # We measure the distance between the 2 selected objects. obj1, obj2 = context.selected_objects - obj1_loc = obj1.matrix_world.translation_part() - obj2_loc = obj2.matrix_world.translation_part() + obj1_loc = obj1.matrix_world.to_translation() + obj2_loc = obj2.matrix_world.to_translation() return (obj1_loc, obj2_loc, COLOR_GLOBAL) elif (obj): # One object selected. # We measure the distance from the object to the 3D cursor. cur_loc = sce.cursor_location - obj_loc = obj.matrix_world.translation_part() + obj_loc = obj.matrix_world.to_translation() return (obj_loc, cur_loc, COLOR_GLOBAL) elif not context.selected_objects: