Transforming relative to current transformation?

I’d like to be able to move and object where the reference frame is it’s current transformation and rotation.

Say, you have an object at location 0,0,0 with a rotation of 0,0,0. Doing this:

rotate(0, 180, 0);//180 degrees
translate(0, 0, 1f);

would make it’s new position 0, 0, -1f, since it’s moving “forward” relative to itself but backwards (-1f in the z axis) relative to the world.

Is this kind of functionality available?

Simple 3D math. (Please search for the “Math for Dummies” tutorial for more information as it’s a really great resource.)

Vectr3f toMove = new Vector3f(0, 0, 1);
toMove = mySpatial.getWorldRotation().mult(toMove);

1 Like