Expanding upon the picking example…

I’m a bit of a noob when it comes to programming and especially to jme3.

I’m following along with the tutorials and have attempted to expand the picking example to work with and stay attached to translated/rotated geometries. If I’m not mistaken the original example uses mark.setLocalTranslation to move the mark that is attached to the rootNode. That’s all fine and dandy, but I have a little different situation. And my solution isn’t producing the desired results.

I am attempting to pick a moving box (geometry) and attach the mark to that box’s parentNode (boxNode) I think my problem lies with the following two lines. (altered from the original ‘picking’ example)



The original picking example expects coordinates with regard to the rootNode. However, if I am attaching the mark to a node that has been translated, the returned coordinates aren’t relevant. (?)

Is my assumption correct? Or am I missing something else. I don’t believe I have changed the original example enough to warrant copying the rest of it. Though, if you would like to see the rest of the code, I would be happy to put it up.

Edit: Thanks in advance to anyone who has any suggestions. I appreciate communities such as this. :smiley:

1 Like

You can use getWorldLocation() and the worldToLocal / localToWorld methods on Spatials for these kinds of problems.

1 Like

Thanks normen! I used worldToLocal.


mark.setLocalTranslation(geo.getParent().worldToLocal(closest.getContactPoint(), null));