(noob question) Getting world coordinates

Sorry guys, i’m a bit confused.
I’ve tried to google but my confusion has increased

I’ve this situation: a node, called SUN, with a spatial child with a mesh of a star. The node has a another child, another node called EARTH, it has two sons: a mesh and another node called MOON. The moon has only a mesh as child.

Well… i’ve translated (local) the earth of 10, and the moon of 4 from the earth.
So the moon has an absolute position of (14,0,0), the earth (10,0,0), the sun (0,0,0).

Now, in the update method, i rotate the moon around the earth, and earth around the sun.

Everything work fine.

Last step i need is to know, after a while, the world coordinates of the moon.

I’ve tried to use something like


but i obtains totally wrong results, like

(671.9854, 150.89433, 0.9995527)

So, obviously this is the wrong way to obtain the moon coords.

How can i do it?

getWorldTranslation() gives you the “world coordinates” of a node in the scene graph, ie: the position including all transformations of its parents, etc…

If it is not giving you the right answer then your expectations of the answer are wrong or you are calling it on the wrong node.

1 Like

I’m an idiot.
I don’t know why, but i’ve used this to debug


the getScreenCoordinates transform the absolute position into 2d coords depending on cam position and rotation.



works perfectly.

Thank you very much, and apologize me for my silliness…