Add skeleton and animationgroup to existing mesh

Hi,

I have issue adding BABYLON.Skeleton to an existing mesh. Can someone explain how to solve the placement issue ? See image for source code and results.

Thanks!

//Olav

hello and welcome! there are a lot of reasons why this could happen :slight_smile:
Can you share a repro in the playground?

Hi,

Thanks for the followup, I have added the issue for the playground:

Look here: https://playground.babylonjs.com/#A3KXI8#3

I would like the left cow to behave like the right cow :slight_smile:

Thanks for a great 3d-engine, I enjoy working with it!

//Olav

Pinging @Evgeni_Popov

It seems “Cow2” is rotated around X by -90° whereas “Cow” is not: it means the inverse bind matrices for “Cow” won’t work with “Cow2”. The easiest fix would be to rotate “Cow2” by 90° around X in your DCC tool.

I believe both glb files have same orientation, I viewed them both in sandbox.babylonjs.com

The rotation seems happens when we set the “.skeleton” property and I don’t understand why.

//Olav

The two cows are not modelized in the same way: if you remove the skeleton from the first cow, you will see that the mesh is very small and rotated from the position it has when the skeleton is enabled:

With skeleton:


Without:

I had to zoom a lot to take this one.

It means you can’t reuse the same skeleton for the 2nd cow.

Hi,

This explains the issue, thanks for helping me. By your help I can now add animations for my game :slight_smile:

Have a great day!

//Olav

Hi,

Some of my models are rotated or scaled differently from the source of the skeleton.

Is it possible to adjust for this on the skeleton/animations ?

You can see the issue here: https://playground.babylonjs.com/#TFZPJ0#10

I have issues with the super-large cow :slight_smile: that is rotated and scaled incorrectly.

Many thanks!

//Olav

You can change the rotation/scaling on the root mesh of the model:

Hi,

Thanks for the feedback, changing the rotation/scaling on the root mesh applies the same changes on the skeleton.

And it is not ok? The model has its own version of the skeleton, so it should do what you are after?

Hi,

I’m trying to retarget the skeleton to the model and run the animation and this is the result:
https://playground.babylonjs.com/#TFZPJ0#11

I have tried also baking the transformation into the vertices, with similar result.

I’m unsure how to solve this. Do we need to bake a new set of MatricesIndicesKind and MatricesWeightsKind for the mesh to target the animation ?

Any suggestion how to proceed ?

//Olav

Sorry I can’t help more, it’s too low level in the skeleton/animation sub-system, it would require to spend a bit of time to understand what’s going on. I do think you should simply create a skeleton for your mesh in Blender (or any other tool) and use that instead of trying to create the skeleton (or trying to update an existing skeleton) by code.

2 Likes

Hi again,

I have now managed to clone skeleton and animations to existing (static) mesh, however it requires same scale to work, and i’m unable to rescale the skeleton.

I have tried scaling the bone, and linked transformation node without success.

How can i scale/transform the skeleton to fit the larger mesh (black cow) ?

image

//Olav

You can apply the scaling on the root node of the mesh hierarchy or to the transform nodes corresponding to the skeleton bones (and not directly to the bones of the skeleton):
image

1 Like

Hi,

I have tried that and it also scales the mesh itself. I have gone for the secondary solution which is baking the scaling into the vertices and then scaling it back.

That way it scales the skeleton with the mesh, and the animation runs correctly, see here:

I will post the code when i’m finished, and hopefully it can be useful for others.

Many thanks for the feedback!

//Olav

2 Likes