Librocket over node [Solved]


I wish to display information on a target on the screen.
For that, I wish to have a reticule, and some basic information (lifebar, name), around the target.

I am using librocket, and I was wondering how to have the position of the node displayed(or not) on the screen (and not the position in the world given by getPos).

Is there a way to have the position in the screen?

Thank you

There is no built-in way to do this. You will need to map world coordinates into screen coordinates yourself, and then map those to pixel coordinates. There are methods in Panda to help you with this, just search the forums.

If i’m not mistaken, you need something like this :

# pos is the 3D position of the target
# frame is the GUI widget
# the screen position is given by a2d

p3 =, Point3(pos))
p2 = Point2()

if base.camLens.project(p3, p2):
	r2d = Point3(p2[0], 0, p2[1])
	a2d = aspect2d.getRelativePoint(render2d, r2d) 

Thank you, I grab the same code.
And it works.

For information, I was needing pixel position to set my librocket window.

The position from this operation is between -1,1 for the lower size of the window (most often the height), and -X,x for the width, where X=width in pixel / height in pixel.

Thanks anyway