Changing the Skeleton Override Mesh

Yo @bghgary … What do i need to do to change the overrideMesh for a skeleton ???

Here is my problem… I use GLTF to load a scene that will have many models. All these models get parented to a root transform node by Babylon GLTF Loader. Also the GLTF Loader sets ALL skeletons overrideMesh to the GLTF Root Mesh.

Now if i have 2 or more robot skinned meshes (For example… Bot1 and Bot2)… the hierarchy
wound end up something like this:

  • root gltf transform node
    • Bot 1 (Parent Node)
      • Bot 1 Skin (Skinned Mesh)
      • Bot 1 Bones (Bone Transforms)
    • Bot 2 (Parent Node)
      • Bot 2 Skin (Skinned Mesh)
      • Bot 2 Bones (Bone Transforms)

Now the babylon skeletons that get created will have its skeleton.overrideMesh = root

Becuase. of this i cant move Bot 1 and Bot 2 transforms around in the scene (If i do the bound box for the Bot Skins does not update and the skin disappears)… Having to call bot skin updateBoundingBox KILLS performance.

Now if i move the root gltf transform around then the boundingbox goes with each skin… But both skins move, since both are children of root

If i change the skeleton.overrideMesh to Bot 1 (Parent Node For Bot 1 Skin) then the bounding box moves, but the bounding box is off when i move Bot 1… I would expect the bounding box to be at same position as skin, but its off and and more i move Bot 1 the more its off

So my question is… How can i set the override mesh to the Parent of the Skin and NOT the root gtlf transform node of the GLTF scene. ???

Can you share an example on PG?

I tried… but i seem to be having problems just loading a model from my github site:

BABYLON.SceneLoader.Load(“https://MackeyK24.github.io/temp/”, “RightHandBot.glb”, engine);

is not working for now…

But you take any Skinned mesh and from gltf and change the skeleton.overrideMesh and then move that mesh (not the root) you should see what im talking about

here is sample bot gltf

RightHandBot.glb.zip (1.3 MB)

Yo @bghgary … If you can put thise right handed xbot gltf somewhere and then load on playground… I can show you :slight_smile:

Try one of these? Using External Assets - Babylon.js Documentation

Dude… I must be having a really bad day… I cant even get the playground to load a simple model.

BABYLON.SceneLoader.ImportMesh("", "https://raw.githubusercontent.com/MackeyK24/MackeyK24.github.io/master/temp/", "RightHandBot.glb", scene, () => {
            alert("Meshes Should be loaded !!!");
        });

PI used the raw github url… it seems to have loaded… but i dont see the model:

https://playground.babylonjs.com/#IKT8TL

Add something like:

scene.createDefaultCameraOrLight(true, true);

to see your model.

That’s weird … it shows the sphere and ground … so it must already have a light and camera … right ?

Yes, but if the imported meshes are not in front of the default camera, you won’t see them.

scene.createDefaultCameraOrLight(true, true); will create a camera so that all meshes are visible.

Also, you should remove the sphere and the plane.

Yo @bghgary and @Evgeni_Popov

Can you try this scene: https://playground.babylonjs.com/#IKT8TL#3

// Note: root gltf added mesh… Cannot move this root node
var root = scene.getTransformNodeByName(“root”);

// NOTE: Is Showing bounding box for the two Beta_Skin primitive meshes under Xbot

// Uncomment to set the override mesh to Xbot parent node (the one that needs to move)
// scene.skeletons[0].overrideMesh = xbot;

// Try and move the xbot 1 unit…You will notice the bounding box does not move at all if the override mesh is root

BUT … If you set a new overridemesh and move the Xbot… You will notice its off… Like the Beta_Skin meshes move 2 units and the bounding box only move 1 unit

This is somewhat hacky to change the overrideMesh, but you can accomplish what you want by unlinking the transform node.

https://playground.babylonjs.com/#IKT8TL#5

1 Like

This might be a good use case for the skeleton property in the glTF? We’ve had many discussions on this in the 3d formats working group in the past, but we’ve never came up with a reason to use it.

For history/context, see here: https://github.com/KhronosGroup/glTF/issues/1270#issuecomment-369696105

I always wondered why we had extra bone in the skeleton for the parent node of the skin and bones …

Technically mixamohips should be the root bone but our GLTF seems to make a bone out of the mixamohips parent… which in this case is XBot transform.

Thanks for looking this Gary

I tried setting override mesh to null and main root bone of XBot to null and that seems to work ok as well … what problems do you see for setting override mesh to null instead of the skin parent node ???

https://playground.babylonjs.com/#IKT8TL#6

what problems do you see for setting override mesh to null instead of the skin parent node ???

It doesn’t have much effect for your scenario. It will only have an effect if the nodes between the root node and the skeleton root have non-identity transforms. Follow the this thread for more context. This one that I posted might be useful to understand more as well.

So really, even though it’s not a problem in this specific use case… it would be better to have the skin parent as the skeleton override mesh… just to be safe ?

Probably.