Pivot node at a given position. Rotate spatial around it


I need in my app to be able to rotate a spatial (Box), around an arbitrary point in the scene, and I cannot accomplish this.

I tried to create a pivot node at position (x,y,z), and attach to it a box, that is at position (a,b,c). I thought this would do the trick, but I can’t create the pivot at (x,y,z), it always it is created at (0,0,0).

I tried to apply translation to the rootNode, and to move it, but nothing works. I’m sure that I don’t understand something.

Normally I tried to do the same thing as in OpenGL to rotate around an arbitrary point:

glTranslate2f( -x, -y );

glRotate*( whatever );

glTranslate2f( x, y );

How can I do this in jme3?

I suggest you read through all of this. https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:scenegraph_for_dummies

It will explain why your getting the (0,0,0) and also don’t apply translation to the root node directly.

1 Like