Librocket over node [Solved]

Return to General Discussion

Librocket over node [Solved]

Postby shimrod » Fri May 18, 2012 4:38 am


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
Last edited by shimrod on Fri May 18, 2012 8:58 am, edited 1 time in total.
Posts: 340
Joined: Mon Dec 28, 2009 11:39 am
Location: France

Postby rdb » Fri May 18, 2012 8:43 am

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.
Posts: 11228
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands

Postby arikel » Fri May 18, 2012 8:46 am

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

Code: Select all
# 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)
User avatar
Posts: 35
Joined: Thu Jun 12, 2008 5:27 am
Location: Paris, France

Postby shimrod » Fri May 18, 2012 8:58 am

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
Posts: 340
Joined: Mon Dec 28, 2009 11:39 am
Location: France

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 3 guests