Bone.absolutePosition take into account the root meshes position and transform?

So I am working on a foot snapping IK thingy and I noticed when resizing the parent/root mesh of the skeleton makes the composed positions based off of a bones absolute position go into the wrong place.

Here is no scaling or position applied:

And here is with scaling and position applied:

What would be the best way to have this transformation come into account when I calculate my position vectors?

This is going to be important because it will be the authoritative position for a raycasting system.

cc @bghgary

I probably need to do bone.calculateWorldMatrix() or something huh?

From the deep end, could you not do whatever you are doing with the mesh’s matrix to the root bone’s? I do not really grasp the extra complications of GLB on skeletons. So ignore, if I am way off.


BTW, I have a a very small subclass of BABYLON.BoneIKController (only 5 meaningful new lines), which has a switch to allow the rotation of the target mesh to be used, in addition, to control the rotation of the third bone at the end of the chain. A controller on a upper / lower arm pair could also control the rotation of their wrist.

If you search, somewhere I posted that. It only had the changes for GLB to make a PR.

1 Like

I might wanna take a look at that, because Im doing a fk/ik blending foot snap thingy to match walking animations to the terrain. Im really close just off of doing simple stuff, but I was going to dive in here and do an extension of the BoneIKController as well so taking a look at yours might be nice.

This was in a topic not completely related, so I tracked it for you.

1 Like

By default, the data returned by Bone.getPosition / Bone.getRotation / … is relative to the skeleton, not to the mesh (TransformNode) to which the skeleton is attached to.

If you want data relative to a mesh, you can pass it as the tNode parameter of these functions. Doing so, the mesh world matrix will be factored in the calculation:

Note that I’m using props.root as the parent mesh of the bone, and because the parent mesh of skeleton.bones[57] is the mesh named / 2, I changed the value assigned to root.

3 Likes

Thank you sir