[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38152] branches/soc-2011-pepper/release/ scripts/modules/mocap_tools.py: Added a small useful operator: Fix Armature Rotate.
Benjy Cook
benjycook at hotmail.com
Wed Jul 6 15:27:41 CEST 2011
Revision: 38152
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38152
Author: benjycook
Date: 2011-07-06 13:27:40 +0000 (Wed, 06 Jul 2011)
Log Message:
-----------
Added a small useful operator: Fix Armature Rotate. It fixes the common issue with mocap files that sometimes are rotated around the wrong axis
Modified Paths:
--------------
branches/soc-2011-pepper/release/scripts/modules/mocap_tools.py
Modified: branches/soc-2011-pepper/release/scripts/modules/mocap_tools.py
===================================================================
--- branches/soc-2011-pepper/release/scripts/modules/mocap_tools.py 2011-07-06 13:15:22 UTC (rev 38151)
+++ branches/soc-2011-pepper/release/scripts/modules/mocap_tools.py 2011-07-06 13:27:40 UTC (rev 38152)
@@ -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 @@
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
More information about the Bf-blender-cvs
mailing list