Skip to content

Instantly share code, notes, and snippets.

@opparco
Last active August 1, 2017 09:48
Show Gist options
  • Save opparco/ff73c1455331f60d6c3acb07abfae4c2 to your computer and use it in GitHub Desktop.
Save opparco/ff73c1455331f60d6c3acb07abfae4c2 to your computer and use it in GitHub Desktop.
Fix armature exporter. Not consider rotation.
--- armaturesys\armature_export.py.orig 2015-01-27 08:38:31.732200600 +0900
+++ armaturesys\armature_export.py 2017-08-01 18:33:26.455402600 +0900
@@ -275,19 +275,22 @@ class Armature():
return correction_matrix * matrix
elif (space == 'BONESPACE'):
if bone.parent:
- # not sure why extra = True is required here
- # but if extra = extra then transforms are messed up, so keep
- # for now
- parinv = self.get_bone_rest_matrix(bone.parent, 'ARMATURESPACE',
- extra = True, tail = False)
- parinv.invert()
- return self.get_bone_rest_matrix(bone,
- 'ARMATURESPACE',
- extra = extra,
- tail = tail) * parinv
+ matrix = mathutils.Matrix()
+ matrix.identity()
+
+ head_local = bone.head_local
+ parent_head_local = bone.parent.head_local
+
+ #
+ # translation
+ #
+ matrix[0][3] = head_local[0] - parent_head_local[0]
+ matrix[1][3] = head_local[1] - parent_head_local[1]
+ matrix[2][3] = head_local[2] - parent_head_local[2]
+
+ return matrix
else:
- return self.get_bone_rest_matrix(bone, 'ARMATURESPACE',
- extra = extra, tail = tail)
+ return self.get_bone_rest_matrix(bone, 'ARMATURESPACE', extra = extra, tail = tail)
else:
assert(False) # bug!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment