Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjy Cook <benjycook@hotmail.com>2011-07-06 17:27:40 +0400
committerBenjy Cook <benjycook@hotmail.com>2011-07-06 17:27:40 +0400
commit89d7b9a0a6cdd0a2183a8e0f931f38c52303f848 (patch)
tree0c1b34805b800a5e2d5aee660e6029d0198bd7c1 /release/scripts
parenteaa63eadf2be52551ea72538b5b9a76fdf42c6d7 (diff)
Added a small useful operator: Fix Armature Rotate. It fixes the common issue with mocap files that sometimes are rotated around the wrong axis
Diffstat (limited to 'release/scripts')
-rw-r--r--release/scripts/modules/mocap_tools.py26
1 files changed, 24 insertions, 2 deletions
diff --git a/release/scripts/modules/mocap_tools.py b/release/scripts/modules/mocap_tools.py
index e9891bbf498..fb48bac60c7 100644
--- a/release/scripts/modules/mocap_tools.py
+++ b/release/scripts/modules/mocap_tools.py
@@ -18,10 +18,10 @@
# <pep8 compliant>
-from math import hypot, sqrt, isfinite
+from math import hypot, sqrt, isfinite, radians
import bpy
import time
-from mathutils import Vector
+from mathutils import Vector, Matrix
#Vector utility functions
@@ -547,3 +547,25 @@ def denoise_median():
newValue = sum(neighborhood) / len(neighborhood)
pt.co[1] = newValue
return
+
+
+def rotate_fix_armature(arm_data):
+ global_matrix = Matrix.Rotation(radians(90),4,"X")
+ bpy.ops.object.mode_set(mode='EDIT', toggle=False)
+ if global_matrix!=Matrix(): #optimization: this might not be needed.
+ #disconnect all bones for ease of global rotation
+ connectedBones = []
+ for bone in arm_data.edit_bones:
+ if bone.use_connect:
+ connectedBones.append(bone.name)
+ bone.use_connect=False
+
+ #rotate all the bones around their center
+ for bone in arm_data.edit_bones:
+ bone.transform(global_matrix)
+
+ #reconnect the bones
+ for bone in connectedBones:
+ arm_data.edit_bones[bone].use_connect=True
+
+ bpy.ops.object.mode_set(mode='OBJECT', toggle=False) \ No newline at end of file