|
@@ -779,13 +779,13 @@ class Export_babylon(bpy.types.Operator, ExportHelper):
|
|
file_handler.write("]")
|
|
file_handler.write("]")
|
|
file_handler.write("}")
|
|
file_handler.write("}")
|
|
|
|
|
|
- def export_bone_matrix(armature, bone, label, file_handler):
|
|
|
|
|
|
+ def get_bone_matrix(armature, bone):
|
|
SystemMatrix = Matrix.Scale(-1, 4, Vector((0, 0, 1))) * Matrix.Rotation(radians(-90), 4, 'X')
|
|
SystemMatrix = Matrix.Scale(-1, 4, Vector((0, 0, 1))) * Matrix.Rotation(radians(-90), 4, 'X')
|
|
|
|
|
|
if (bone.parent):
|
|
if (bone.parent):
|
|
- Export_babylon.write_matrix4(file_handler, label, (SystemMatrix * armature.matrix_world * bone.parent.matrix).inverted() * (SystemMatrix * armature.matrix_world * bone.matrix))
|
|
|
|
|
|
+ return (SystemMatrix * armature.matrix_world * bone.parent.matrix).inverted() * (SystemMatrix * armature.matrix_world * bone.matrix)
|
|
else:
|
|
else:
|
|
- Export_babylon.write_matrix4(file_handler, label, SystemMatrix * armature.matrix_world * bone.matrix)
|
|
|
|
|
|
+ return SystemMatrix * armature.matrix_world * bone.matrix
|
|
|
|
|
|
|
|
|
|
def export_bones(armature, scene, file_handler, id):
|
|
def export_bones(armature, scene, file_handler, id):
|
|
@@ -807,7 +807,7 @@ class Export_babylon(bpy.types.Operator, ExportHelper):
|
|
Export_babylon.write_string(file_handler, "name", bone.name, True)
|
|
Export_babylon.write_string(file_handler, "name", bone.name, True)
|
|
Export_babylon.write_int(file_handler, "index", j)
|
|
Export_babylon.write_int(file_handler, "index", j)
|
|
|
|
|
|
- Export_babylon.export_bone_matrix(armature, bone, "matrix", file_handler)
|
|
|
|
|
|
+ Export_babylon.write_matrix4(file_handler, "matrix", Export_babylon.get_bone_matrix(armature, bone))
|
|
|
|
|
|
if (bone.parent):
|
|
if (bone.parent):
|
|
parentId = 0
|
|
parentId = 0
|
|
@@ -844,15 +844,22 @@ class Export_babylon(bpy.types.Operator, ExportHelper):
|
|
|
|
|
|
#keys
|
|
#keys
|
|
file_handler.write(",\"keys\":[")
|
|
file_handler.write(",\"keys\":[")
|
|
|
|
+
|
|
|
|
+ previousBoneMatrix = None
|
|
|
|
|
|
for Frame in range(start_frame, end_frame + 1):
|
|
for Frame in range(start_frame, end_frame + 1):
|
|
|
|
|
|
|
|
+ bpy.context.scene.frame_set(Frame)
|
|
|
|
+ currentBoneMatrix = Export_babylon.get_bone_matrix(armature, bone)
|
|
|
|
+
|
|
|
|
+ if (Frame != end_frame and currentBoneMatrix == previousBoneMatrix):
|
|
|
|
+ continue
|
|
|
|
+
|
|
file_handler.write("{")
|
|
file_handler.write("{")
|
|
|
|
|
|
Export_babylon.write_int(file_handler, "frame", Frame, True)
|
|
Export_babylon.write_int(file_handler, "frame", Frame, True)
|
|
- bpy.context.scene.frame_set(Frame)
|
|
|
|
-
|
|
|
|
- Export_babylon.export_bone_matrix(armature, bone, "values", file_handler)
|
|
|
|
|
|
+ Export_babylon.write_matrix4(file_handler, "values", currentBoneMatrix)
|
|
|
|
+ previousBoneMatrix = currentBoneMatrix
|
|
|
|
|
|
if Frame == end_frame:
|
|
if Frame == end_frame:
|
|
file_handler.write("}")
|
|
file_handler.write("}")
|