Unexpected Skeleton/Bones from exported Blender file

Hi there.
Today i bit the bullet and learned how to rig. Rigged up a very simple skeleton and thought i did a decent job in Blender. But when imported into Babylon as GLB, got unexpected results.

  1. Can’t move the mesh via the bones (as i can on the Dude model). Can only move the mesh via transform nodes. Assume that this is not the right way?

  2. There is an extra bone at the feet

Any tips on how to best rig for Babylon? Am I missing some technique?

1 Like

Sorry, uploaded wrong file. Here it is:
testrig.zip (291.2 KB)

Noting that when i move the bones, the mesh moves and then it snaps right back into place to original position/rotation.

Can’t move the mesh via the bones (as i can on the Dude model). Can only move the mesh via transform nodes. Assume that this is not the right way?

The way glTF skeletons work in Babylon.js is a bit different. glTF uses nodes for bones. To mimic this behavior in Babylon.js, the bones are linked to transform nodes in the scene. If you move the bone, it will immediately be overridden by the transform of the linked node. I know this is confusing, but we haven’t found a better way to do this yet.

There is an extra bone at the feet

I think you are talking about the debug skeleton viewer showing the connection from the root of the skeleton to the first level bones. In the glTF skeleton, there are two bones shin.L.001 and shin.R.001 which have no children.

2 Likes

Thanks! That all makes sense.
Does the IK setup come over to Babylon in either glTF or Babylon formats? Doesn’t seem like the control bones work (that’s what shin.L.001 and shin.R.001 are)

There is no IK in glTF that I’m aware of. Babylon has support for IK: Use Bones and Skeletons - Babylon.js Documentation, but I don’t know about exporting it from Blender.

1 Like

The yellow calf bone tells you they are IK bones and they are set to “not deform” the mesh. (Click on the bone tab in the properties panel - the “deform” box has no check. Now for .babylon export you have an option to NOT export them. With that IK bone selected click on the pink globe tab and look at the “animation” panel and check “ignore IK bones” box. there will be no export then. Now in versions earlier than Blender 2.8 the name of those Ik bones had to include “IK”, so I would name them ShinL.IK and ShinR.IK to ensure they are not exported.

If you are going to use Ik for the legs - I would add a KneeL.IK and KneeR.IK. But that is all for .babylon export - I don’t use the GLB stuff.

Hope that helps.

cheers, gryff :slight_smile:

1 Like

Thanks @gryff. Yes, I added the IK bones in there myself (took a rigging class).

From what i gather from that link above and from your comment, are the following two statements true:

  1. There is no format that I can use to import a rig with IK into babylon
    and
  2. Babylon does support IK, but it must be coded explicitly using BABYLON.BoneIKController.

both true?

As far as I know @bigrig both are true. But to be honest, I have never tried to use the Babylon.BoneIKController. I just want to create my animations in Blender and then export them (without the IK bones).

It seems you are looking to do/create animations in Babylon itself. I try to work with a minimum number of bones and even use animations that I can get from .bvh files that I import into Blender.

You are going beyond my paygrade :laughing:

cheers, gryff :slight_smile:

1 Like

Getting a little deeper into animating these skeletons. Again running into some walls. Will none of the copyAnimationRange+beginAnimation functions work since animating skeleton movements are being overidden by transform nodes? Is there a way to tell a function like copyAnimationRange to copy to the transform nodes instead?

1 Like

Hey Bigrig! I agree this could be complicate. Unfortunately babylon.js has to accomodate with a lot of different ways to animate things (gltf, blender, 3dsmax, etc…)

None of the copyAnimationRange will work as there is NO animation range defined on your skeleton,
Skeletons can be animated (like any other entity in babylonjs actually):

  • directly by adding animations onto each bones
  • using AnimationGroups (which is the case of gltf)

Here because we are using gltf (which specs mimic what Unity does), we are animating nodes that will control bones so the skeleton animations are empty.

Does it make sense?

1 Like

Thanks, I think that make sense.
Are there any good playgrounds where an animation is added directly to a bone - on a loaded GLTF?

What kind of animations do you want to add? Maybe you can create a simple playground that we will use to see how we can help you?

That would be so awesome. Have been banging my head for a few days on this. In sum, I want to be able to load a character with skeleton. And then load, separately, animation data and to be able to animate the character with that data.

https://www.babylonjs-playground.com/#D9U0UW#9

1 Like

Ok this is an interesting use case.

So technically, you should be able to only change the skeleton property of your mesh. If the new scene loads correctly, you should get a new skeleton, then it should be enough to do something like myMesh.skeleton = newSkeleton

Ok. Gave that a try:
https://www.babylonjs-playground.com/#D9U0UW#12

Don’t think it did anything. In playground above, if it worked, I’d assume that both characters would be doing the “Jab” animation.

Btw, if we can get this working, I will make and share a shiton of animation data files… so that anyone should be able to load any character with a mixamo rig - and use these animations with a minimum of fuss. Think it’ll really be useful/fun for BJS makers.

Are you sure about myMesh? not sure if myMesh should be set to newMeshes[0]

You should look for the one having a skeleton already

Something like that:
https://www.babylonjs-playground.com/#D9U0UW#15

Now you also need to clone the animationGroup that was targeting the previous skeleton :frowning:

Other option:
https://www.babylonjs-playground.com/#D9U0UW#16

It is not working now because the armature object on first mesh is not the same as of the second mesh (one has a scale of 0.01). If you make them identical it should work flawlessly

Have made scale identical.
https://www.babylonjs-playground.com/#D9U0UW#17

But not sure what I’m looking at here. Seems like two separate models with separate animations? (and one party disembodied, poor guy). Rather than loading the animation from one model onto the other. Am I misunderstanding?

Oh, or is that all actually the same mesh, but 1/2 of the mesh (hair/shirt/shorts) is playing one animation and 1/2 of the mesh is playing the other animation (head/torso/legs) ?? Woa.