P3D Widgets

Just wondering -

Can button widgets be defined in a 3D space (x,y,z coord) or are they pisitioned on screen in 2D only?

DirectButtons (and other Direct widgets) can only by default be used in 2d, otherwise certain features of them will stop working (the ability to interact with them).

There are ways (that you would have to code yourself) that you could place them in 3D space, this would include using a picking ray and possible using render-to-texture depending on how you implimented it.

to answer your question very directly: Widgets can only be displayed on the 2D screen.


Are picking rays the way to go for selecting 3D objects on screen with the mouse?

I will need a mouse based interface for this game I’m working on and have not come across any APIs that deal with converting 3D POS to a screen region 2D POS. I would rather avoid anything that deals with rendering to an off-screen buffer.

I just came across a section in the manual for clicking 3D objects.

Before I try that, I’m on to something…

I think I see a dirt simple way to do it. If I’m wrong, I’ll try the example in the manual.

Picking rays would be almost one of the (only) ways to have a user interface in 3D space, (ie non-attached to the screen).

You have two options for this:

Display a 3D object (button etc) and pick it using a ray, then change it’s appearance by swapping it out with a different looking 3D object (button etc)


Use the DirectGui widgets, parent them to the 3D space (eg “button.reparentTo(render)”), and then manually change their state based off the ray, using something like “myDirectItem[‘state’] = newState” where newState would be one of the DGG.NORMAL, DGG.DISABLED, etc defined in direct/gui/DirectGuiGlobals.py (see there for a list of possible states)

Hope this helps,