[SOLVED] Putting a Spatial In The Position of A Given Joint

Hello Guys,
I’m have this code for getting a given joint:

SkinningControl skinningControl = this.skinningControlNode.getControl(SkinningControl.class);
if (skinningControl != null) {
    myJointNode= skinningControl.getAttachmentsNode(jointName);

Then I want to place another node in the position (world position) of that joint:

Vector3f pos = rootNode.worldToLocal(myJointNode.getWorldTranslation(),null);

But I’m not getting the joint’s world position but rather it’s parent’s position…
I found a workaround to place my other node in the joint’s position - I attach it to the joint’s node then detach it (attach it to the root node) but I don’t like this approach.

So, how can I position my other node in the world position of the joint?

What is myOtherNode attached to?

Its going to be added to the rootNode

1 Like

I’m also going in this direction:

Joint j = (Joint)n.getUserData("AttachedBone");
Vector3f pos2 = j.getModelTransform().clone().combineWithParent(am2.getSkinningControl().getSpatial().getLocalTransform()).getTranslation();

But still doesn’t give me the joint’s position to place the other spatial. I’m not sure it’s the right direction…

The parent of the attachment node (myJointNode) will be the Spatial to which skinningControl is added. So the local translation of myJointNode will be in the coordinate system of that Spatial.

When myOtherNode is attached to rootNode, its local translation will be in world coordinates. So I think you need to convert from the coordinate system of the controlled spatial to world coordinates. Probably the safest solution would be to use myJointNode.getWorldTransform() and apply that Transform to myOtherNode using myOtherNode.setLocalTransform()

PS: By applying the Transform, you are copying the translation, rotation, and scale (if any), not just the translation.


it makes perfect sense but doesn’t work in my case. I’ll do some more tests and update

1 Like

This position calculation is working fine:

Joint j = (Joint)n.getUserData("AttachedBone");
Vector3f pos = j.getModelTransform().clone().combineWithParent(am2.getSkinningControl().getSpatial().getWorldTransform()).getTranslation();

Solved, then?

Yes, Thanks a lot!

1 Like