I'm extending the joint class from JME Physics 2, and in there I have a method that I want to always return the anchor point, but in world space, as getAnchor() just gives the anchor in relation to the first object in the joint. Here is my code:
anchorLocale is set to be the leftNode when two nodes are attached. The problem with this code is that the point it returns is close, but not quite right. It starts off below the leftNode, instead of horizontally next to it, where it should be. Then, as the leftNode moves (force is exerted on it), the point moves along, so when the leftNode has been moves around by about 90 degrees, the point is actually in the correct position! However, the point keeps moving upwards and across. I'm pretty sure this is because I have to do something with the the Vector3f I get from getAnchor(), but I'm not totally sure what. Does anyone have any ideas?
The red cross is the point the code gives me, the green cross is the point I want (which is where I have set the anchor to be). In #1, the whole thing is horizontal, as there is a joint before the one shown that rotates the whole thing. As that (unshown) joint moves round, the point moves back and down till we come to #2, when the unshown first joint is at 90 degrees.
Any other ideas? I’ve been playing around with this for a while, and I can’t seem to get anywhere. And yet it seem so simple!