There are issues with switching the blend model to the rest state

I exported the GLB model from blend, and in blend, the rest is Tpose. I tried to restore it to rest by loading it with babylon, but it has always been pose. You can check it https://playground.babylonjs.com/#92Y727#458


Hello :slight_smile:

In your loop across skeletons and bones, if you log, there is nothing :

scene.skeletons.forEach((skel) => {
    console.log("skel", skel);
    skel.bones.forEach((bone) => {
        console.log("bone", bone);
        var localMatrix = bone.getLocalMatrix();
        bone.setBindMatrix(localMatrix);
        bone.returnToRest();
    });
});

Because there is no skeleton in the scene.
I can see a comment // There is a problem with cloning but you don’t speak about this in your post. Is your problem about cloning ? Because indeed, it appears that the way you are cloning is not adding any skeleton to the scene, while container.addAllToScene() would do :

Sorry, I added the issue from the project here. There was a problem copying the playground code. In the project, various models need to be processed, including calculating bounding boxes, selecting around the center, and initial camera position data. I need to combine the pose of the model with the animation on mixamo before playing it. However, if the initial pose of the model is different from rest, even if it is corrected and combined with mixamo for playback, there will still be problems. Please take a look https://playground.babylonjs.com/#8LFTCH#2553 Play status after cloning the current model animation

cc @Evgeni_Popov

Sorry, I don’t understand what’s the problem is in the PG? Everything looks fine to me.

Note that the “rest” matrix in Babylon.js is nothing special, it’s just a convenient method for the user to register a matrix with a bone (through Bone.setRestMatrix), and to restore them all at once for a skeleton by doing Skeleton.returnToRest (you can also do it for a single bone through Bone.returnToRest). At construction time, the rest matrix of a bone == local matrix.

1 Like

@Evgeni_Popov
Sorry, I made a mistake when loading the model. If I replace it with this one, I can see the problem https://playground.babylonjs.com/#8LFTCH#2554

It could be a problem with incompatible skeleton. See this answer from @PatrickRyan, and also his other answers in the thread:

@songjinlin123, the orientation of the affected joints seems to match if you look at the two images below.


But when I stop the animation groups, the bind poses look very different:

On closer inspection, you can see the legs of the cloned character are closer together in the dance meaning that all bones are being affected, but the arms are the most obvious. I agree with you that the issue is coming from the mismatched initial pose. It appears that the glb you imported into Blender has this pose as the first frame of animation, which is why you are seeing it. You can export the skeleton in a different pose by choosing an animation frame and making that the first frame of the export, which will confer a different basis for your animation. If the pose switch in Blender is not considered by the exporter, you won’t be able to export in the bind pose. I’m not super familiar with the Blender glTF exporter, so look through the options to see if there is a parameter that allows exporting in rest pose. Otherwise, you will need to zero out the rotations on the skeleton to export the glb in a matching T-pose so that you can retarget animations.

This is one of the downfalls of glb as a transfer format within a pipeline. The file format is streamlined for transmission to be as small as possible, so you don’t get a lot of the data you would expect to be in your blend files. Simple things like unwelding vertices along UV seams for example. If you only have a glb as your source file to make changes to in Blender, you may need to remake some things like T-pose. This is why it’s nice to have one animation (even just a couple frames) in whatever bind pose you use for your skeleton so you can always export the file with that animation active (the first animation and what frame you export on). This makes retargeting easier since your initial pose will be your bind pose.

3 Likes

It is possible to export the first frame animation through blend. Currently, this is how we handle it. If there are no other effective solutions, we can only do it this way

1 Like