Parenting NodePaths in render2d with display order

Hi there,
i’m trying to parent a NodePath to the render2d that contains a fullscreen card with a texture on it. I would like to have this displayed on top of everything that is already on render2d. I noticed that using DirectGUI if i declare something later in the game it gets “on top” of what’s already on screen, but the NodePath of the card doesn’t.

Code:

overlay_texture = base.loader.loadTexture("A_CLIENT/ASSETS/GAME/2DIMAGES/menu/menu_overlay.png")
cm = CardMaker("T")
cm.setFrameFullscreenQuad()

cm.setUvRange(overlay_texture)

self.overlay = NodePath(cm.generate())
self.overlay.setTexture(overlay_texture)

self.overlay.reparentTo(base.render2d)
self.overlay.setTransparency(TransparencyAttrib.MAlpha)
1 Like

You can customize the rendering order that you need.
https://docs.panda3d.org/1.10/python/programming/rendering-process/controlling-render-order

Thanks for that, it was very useful and might come handy even later in development. But unfortunately, it doesn’t fix the issue. Apparently, all DirectGui widgets are still on top, even when specifying .setBin("fixed", 0) on the overlay image. Now to handle this i could every time hide the gui and then show it again later, but that feels like a pain in the butt to deal with. Is there another way?

It might still work if you place the object in another bin–you could try “unsorted” (which has a higher priority than does “fixed”), or perhaps make one yourself with a very high priority. (I’m not sure of what bin DirectGUI objects are placed in, and thus what priority would be required, offhand.)

[edit]
Yup, “unsorted” does the trick, at least in a quick test-program on my end!
[/edit]

As to hiding the GUI, if you give all of your GUI-widgets a single common parent-node, then you should be able to hide the GUI simply by hiding that one node.

yes, thanks. “unsorted” does the trick. Also, i didn’t realize that i could reparent the gui to a node and just hide that. Thanks.

1 Like

There is something else, one day I learned from rdb that sorting is possible by the third Y coordinate, but for this you need to set the desired variable in the configuration file. Then it will be possible to control the layer using Y. But then for some reason I did not specify the details, I think that such a method exists.

1 Like

My impression is that “gui-popup” is used only for select GUI elements–things that are intended to appear over all others, like dialogue boxes.

(I thought about suggesting it here, I believe, but I’m not sure that it’s a good choice: should things like dialogue boxes not still appear on top?)

I don’t see any connection with dialog boxes, what difference does it make what appears on top, the map is also a window…

I also found out that some sorting bin are based on camera distance. It is possible to reassign a node to such a basket, which allows sorting by the Y coordinate.

From a UI perspective, certain things should be I think “always on top”–things like (certain) dialogue boxes.

And, well, dialogue boxes are, if I recall correctly, by default placed in “gui-popup” (at least when given a fade-screen; I’m not sure about under other circumstances), while most DirectGUI objects are not. This causes them to appear on top of standard DirectGUI widgets.

True, but that would only really work if those culling bins have a higher priority than the GUI widgets–or if the widgets are also all placed into that bin.