Hello everybody, I’m working on a custom mesh and animation exporter.
Vertices positions, normals and triangle indices are relatively easy to handle. However, I still can’t find the right way to export sufficient animation information.
Bone transform exporter:
obj = context.object
pose = obj.pose
bones = {}
def traverseBone(bone):
bones[bone.name] = bones.get(bone.name) or []
bones[bone.name].append(
[a for row in bone.matrix.transposed() for a in row])
for child in bone.children:
traverseBone(child)
for frame in range(scene.frame_start, scene.frame_end + 1):
scene.frame_set(frame)
traverseBone(pose.bones[0])
Assume the armature has only 1 root bone.
The problem is, the skinned vertices are stretch so hard from it original position.
https://nohaygang.web.app/test-man.html
This is original mesh and the armatured weighted:
This is how I skinning:
outV = sum(weights[i] / totalWeights * boneTransforms[i] * v)
Is there something missing in my equation? I had tried invertedBindPose but the result is same. I don’t know how to find Bind Shape Matrix, too.
Original blend file: man.blend - Google Drive
Please reply if you need more information. I’m new user thus I can’t embed more items or links.