Hi guys! First of all, I’m new to Panda3D and sorry for any typos.
Well, I’ve been reading the manual for a couple days and in the Scene Graph Manipulations section, it is stated that there is a child of render2d called pixel2d. The thing is I just can’t see a way to access it.
Tried to look for any WindowFramework::get_pixel2d() method, with no success. I also tried to search for “pixel2d” in the contents of Panda3D’s source code files, and still no results.
Is pixel2d really there? How can I retrieve it, so that I can put a NodePath to be drawn using it?
The code that creates pixel2d is only in Python. However, it’s trivially simple, and you can create your own pixel2d in C++. The Python code looks like this (in ShowBase.py):
# This special root, pixel2d, uses units in pixels that are relative
# to the window. The upperleft corner of the window is (0, 0),
# the lowerleft corner is (xsize, -ysize), in this coordinate system.
xsize, ysize = self.getSize()
self.pixel2d = self.render2d.attachNewNode(PGTop("pixel2d"))
self.pixel2d.setPos(-1, 0, 1)
if xsize > 0 and ysize > 0:
self.pixel2d.setScale(2.0 / xsize, 1.0, 2.0 / ysize)