Translation along world coordinates y-axis

This situation: blue node is attached to rootNode, and yellow node is attached to blue node. Not rotation or translation. Look at this illustrating picture:

Then I translate yellow node:

Then I rotate blue node:

And now I want to translate yellow node along y-axis of world coordinate system. How? I tried with sinus, cosinus and pythagoras. But I’m too foolish!

I want this result:

You can use Spatial.worldToLocal to convert a global vector to a vector relative to that spatial.

btw: nice diagrams :slight_smile:

First: thank you irrisor, this was what i wanted!

But: very strange things happen. When I use worldToLocal-method and set spatials local translation to the out-vector, the spatial "bounces" along the translation axis. Seems, the translation will be done twice with different values?

Did I forgot updating anything?

You need to convert the movement vector (e.g. [0, 1.5f, 0] to move 1.5 in y direction) to local coordinate space and add it to the local translation of the inner node. Did you try that?

like this? :?

Vector3f in = new Vector3f(0,heave,0);
Vector3f out = new Vector3f();
out = yellowNode.worldToLocal(in, out);
yellowNode.updateGeometricState(tpf, true);

with this code it doesn't bounce anymore, but then happens following (according to the beautiful pictures above):


out = yellowNode.worldToLocal(in, out);


out = yellowNode.getParent().worldToLocal(in, out);

  • you need to convert into the local coordinate system of the blue node

Sorry for long time i did no reaction, there was no time.

Next problem (now there are two problems):

yellowNode.getParent is null, still rootNode isn't parent of yellowNode.

Hardcoding with

out = blueNode.worldToLocal(in, out);

the translation is done correctly (great! thank you irrisor!),

but the bigger the translation value is, the translation seems to be exponential. I think it's because of the adding of out to the current local translation?

problem completely solved.

last post of me happened in result of twittering with friends instead of paying attention to teachers speaking about vector math… sorry!