Panda Overlays - 2D Pixel-Based Cards

About
p3doverlays, or Panda Overlays, allows you to use familiar screen-space coordinates and pixel-perfect rendering to create GUI/HUD elements in Panda 3D. The aim of this project is to create a generic ‘base layer’ for GUI/HUD libraries to build atop. Support for ‘slicing’ textures is also included, in order to create resizable elements (such as scrollbars and rounded-corner windows).

I find that one of the reasons OGRE 3D has so many GUI libraries to choose from, and Panda 3D has so few, is because of the lack of support for pixel-based rendering in Panda. Hopefully this project will at least inspire some change.

Creating crisp, pixel-positioned text and geometries takes only a few lines of code:

...

pixel2d = PixelNode('g2d')

box1 = Overlay(color=Vec4(.9, .7, .7, 1))
box1.reparentTo(pixel2d)
box1.setZIndex(-1)
box1.setPos(50, 50)

myFont = TextOverlay.loadFont('res/Aller_Rg.ttf', size=12) 
text = TextOverlay(msg="Lorem ipsum...", font=myFont, 
                            color=Vec4(0.2,0.2,0.2,1))
text.reparentTo(pixel2d)

pad = 5
x, y = box1.getPos()
text.setPos(x+pad, y+pad)

w, h = text.getSize()
box1.setSize(w+pad*2, h+pad*2)

...

Code Samples & Tutorials
p3doverlays.googlecode.com/svn/t … mples.html

Class Documentation
p3doverlays.googlecode.com/svn/t … asses.html

Downloads

code.google.com/p/p3doverlays/downloads/list

Project Home

code.google.com/p/p3doverlays/

Looks nice! Very clean and uniform. Nothing but compliments!

EDIT: Oops. Read the tutorial, question revoked.

That’s what I want ! Any plan to put a GUI on top ?

Yep, but don’t expect anything too complex! And it will be separate from p3doverlays.

Uh, is that still correct?

That refers only to ‘overlaytool’, a tool/demo using the main module.

The actual module (called overlays) was not at all rushed, and it should work cross-platform.

Sorry for the confusion. I’ll be sure to rewrite that to make it more clear. :slight_smile:

EDIT: Now all samples use the open source DejaVu font. Other platforms can disable the win32clipboard on overlaytool with the -noclip option.

A few major changes…

- TextOverlays no longer use generate(). They now act a little more like OnscreenText; Use the setText/setFont/etc methods and they will be changed without destroying/generating text nodes.
- Reparenting has been fixed; you can add Overlays to Overlays, and their depth is based on the order they were reparented. Z-Index is now only needed for special cases (e.g. always-on-top).
- Line borders can be added to Overlays, see the border test
- GeomGen/GeomEdit has been merged into GeomMaker, and now you can edit the texture and texcoords for an overlay with setTexture and setTexcoords, respectively. The latter will re-write the texture data.
- Text alignment works with TextOverlays
- Many smaller bugfixes

I’ve been working on the GUI toolkit, and its going well. It will support themes, relative positioning, and a basic set of widgets. I might include it with p3doverlays after all.

That’ll be the last update for a while, though – I’m going to be working in Europe till the end of the summer. :slight_smile: Ciao!