Bone not rotating with parent

Hi,

Using quad meshes to represent sprites, I’m attaching different pieces to the actor body to compose it.

When attaching a quad mesh to the parent body, the bone is not following the rotation of the parent.

Am I doing something wrong here?

https://playground.babylonjs.com/#YM8MSS#3 You forgot to link bone - mesh. Not sure if it should rotate like that?

N.B. I could have sworn that you can set it up in a way where you can transform the bones directly.

N.B.2: Keep in mind that there is “vertex weights” which you are not dealingh with here at all. So there probably is some more work to do.

2 Likes

Now it rotates, but… the rotation is not according to the parent.

Hello :slight_smile:

I think your problem comes from the fact that you have no root bone.

Try this :

const boneROOT = new BABYLON.Bone('bone', quadMesh1.skeleton, null, BABYLON.Matrix.Identity());
const bone = new BABYLON.Bone('bone', quadMesh1.skeleton, boneROOT, BABYLON.Matrix.Identity());
2 Likes

That is!! Thanks so much!

1 Like

Why? The original PG does have a root bone (see Inspector).

Might there be a bug if the skeleton only has a single bone? attachToBone looks innocent though :thinking:

Maybe here: if attachToBone was called, this path is taken in computeWorldMatrix. But then I get lost because bone._finalMatrix is never updated :face_with_spiral_eyes:

Yes, but here @Khanon wants to move a bone and attach a mesh to it, and in that case it should not be the root bone, I guess. I don’t have the exact answer to the “why ?” but I just notice that either BabylonJS or Blender, it’s always like so : root bone, and then you attach some transform bones to it :slight_smile: . I guess it’s a matter of hierarchy organisation / convention or something like that

1 Like

For some reason this is not working in my engine :expressionless:
I’m investigating but the structure seems to be the same than the PG.

robot-rotation-ezgif.com-optimize

PS: Ok, I found it, the problem is using billboardMode in the hat mesh, which is attached to the bone.

@Evgeni_Popov some idea if this is the desired behaviour or a bug?

1 Like

I think it’s the expected behavior, but you can try to set TransformNode.BillboardUseParentOrientation = true and see if it fixes it.

1 Like

Yes, that works, anyway I’m unsetting the billboardMode for the child.