worldToLocal - how does it work in a multiple Node hierarchy?

Following hierarchy of Nodes:



rootNode -> secondNode-> thirdNode-> fourthNode



I had to move fourthNode along the y-axis of thirdNode. Worked.



But it doesn't work correct anymore if I do a KeyNodeRotateLeftAction or KeyNodeRotateRightAction on secondNode and then try this mentioned moving of fourthNode. The translation along y-axis is done correctly, but from now on the x- and z-translation has an demonic influence: fourthNode now races through the scene, because out has now x- and z-values not equal to zero.



// y is wished translation along y-axis
Vector3f in = new Vector3f(thirdNode.getLocalTranslation().x, y, thirdNode.getLocalTranslation().z);
      
Vector3f out = new Vector3f();
fourthNode.getParent.worldToLocal(in, out);

fourthNode.getLocalTranslation().set(fourthNode.getLocalTranslation().add(out));
fourthNode.updateGeometricState(tpf, true);

hm, is my problem too simple or too difficult???

Are you using rotation and translation properly??



They are NOT communative.



rotation --> translation != translation --> rotation





(in other words rotating then translating is NOT the same as translating then rotating)

i know. has anyone another idea?

I think the problem is that your problem is not completely clear to address… If you could create a little test case, we could have a look at it.

I solved the problem by changing the rotation of the upper nodes from KeyNodeRotateActions to KeyStrafe…Actions. For my situation it worked, the visual effect was the one I wanted.