Relative coordinates

Hi everyone!!

I’m new to jME anf I have a question about ‘world-coordinates’ and ‘relative coordinates’.

I’d like to program a rts game with space ships like homeworld. So, if a flying ship rotates around an axis, it has to rotate around its realtive axis, not around the world-axis. Is there a method in jME to rotate (and translate) a node around its relative axis, or must I calculate the relative rotation for the node myself(translating it to 0,0,0 rotate and translating back??)? 8-O :?

Everything in jme is relative. There is no absolute (only if you cheat).

So by doing "setLocalTranslation" and "setLocalRotation" on a Spatial, you are effectively rotation and translating in the local/relative space.

Now the world coordinates/rotation is propogated upwards through the tree to find it. Meaning that it adds up all the rotations/translations till it gets to the top node and that would be its world/absolute rotation/translation.

World translations/rotations can only be gotten via the approperiate getters and they cannot be set. To do that, modify the local transation instead.

Earlier, i mention that you can cheat by having everything in world coordination. And that would be to have only 1 parent, and that parent would be the rootNode. So effectively, its a linear tree, thus they are all relative to the absolute

Hope that helps

Thank you very much. I’ll try it.

ok, i tried some things with translations and rotations.

i stored the rotation of my object in a vector3f (rotation around thx x-axis, rotation around thx y-axis, rotation around thx z-axis). then i rotate my object with a quaternion:

```if(KeyBindingManager.getKeyBindingManager().isValidCommand("rotLeft", true))       {          rotation[2] += 0.001;          testq.fromAngles(rotation);          ship.setLocalRotation(testq);       }       if(KeyBindingManager.getKeyBindingManager().isValidCommand("rotRight", true))       {          rotation[2] -= 0.001;          testq.fromAngles(rotation);          ship.setLocalRotation(testq);       }       if(KeyBindingManager.getKeyBindingManager().isValidCommand("rotUp", true))       {          rotation[0] += 0.001;          testq.fromAngles(rotation);          ship.setLocalRotation(testq);       }       if(KeyBindingManager.getKeyBindingManager().isValidCommand("rotDown", true))       {          rotation[0] -= 0.001;          testq.fromAngles(rotation);          ship.setLocalRotation(testq);       }```

but i still have a problem:
i dont know how to move my object along its own z-axis.
how can i get the direction my node is looking to, after having it rotated?
can i get a 'direction-vector' to add this vector to the local translation of the node?

update:
i managed to translate my ship along its z-axis. with the multiplication of my rotation quarternion and a vector(0,0,1). then i add the result to the local vector of my ship. XD 8)

By the way:

i have a ship, attached to a second node(as child), which is attached to my rootnode.

ship–>secondnode–>rootnode

my second node is translated 3 up. my ship is translated 2 along the z-axis.

so you can find my ship at (0,3,2) in the scene. when i call getLocalTranslation, i get (0,0,2).

but when i call getWorldTranslation, i get (0,0,2), too.

shouldnt i get (0,3,2). where is the mistake in my thinking?? :? :?