Custom animation export via Python

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[] = bones.get( or []
                [a for row in bone.matrix.transposed() for a in row])
            for child in bone.children:

for frame in range(scene.frame_start, scene.frame_end + 1):

Assume the armature has only 1 root bone.

The problem is, the skinned vertices are stretch so hard from it original position.

This is original mesh and the armatured weighted:
Screen Shot 2021-10-27 at 10.00.59 PM copy

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.