Essentially, I want to use an empty PandaNode in the SceneGraph as unity-like “scenes”. So that I can view a group of objects, then “change scene”, and render another group of objects instead. So I have a “Start Menu”-scene, “Ingame-scene”, ect.
But when a append objects to children of the render-node, they are no longer rendered.
For example, using a flat structure like:
render/-TextNode
Renders the text node fine.
But using using the empty PandaNode “start_menu” as a node in the SceneGraph tree.
render/start_menu/-TextNode
Renders nothing. All I do is change the node’s parent from the root node “render”, to my empty node “start_menu”.
So, how do I make my game render the children of nodes that is not the root node.
Are there any render state applied to your scene node (the empty pandaNode) ?
If not, maybe you can try with something like “render.attachNewNode(‘myScene’)” and try again to attach your textNode to this one, see if it shows on screen
render itself is scaled to work well with 3D models. For UI elements like buttons, texts etc, you’d usually use the base nodepath (NP) render2d or pixel2d (dependent on whether you want pixel scales or aspect ratio -1 - 1 scales).
You can of course have anything in the render tree, but then your start_menu NP should be scaled accordingly and you may also want to have it always face the camera, if you don’t want to place your UI in the actual 3D space.
But usually, if you put UI elements in the render graph, they are either to large, to small or not facing the camera. I also guess you put an actual text in your TextNode, otherwise there won’t be text to render anyways.
Hmm… This implies to my mind–as FRPS_Archy says–that there’s some state applied to “start_menu” that is preventing “-TextNode” from being rendered.
Is “start_menu” perhaps hidden? Or placed at some location that puts it outside of the camera’s view? Or even rotated such that you’re seeing the back of “-TextNode”…?
I ended up adding an additional PandaNode to the scene class that is appended to render2d branch, instead of the normal render branch. So that I have a node specifically for UI, in scenes that require custom UI. like the start menu. This solved my issue, and the buttons are now visible.
Edit:
UI won’t work when appended directly to render2d. You can’t click on it. The location will also be slightly different from what you would aspect if you created the UI without a “parent”.
It has to be appended to aspect2d, which is a child of render2d. So the final location for UI in the SceneGraph ended up being: