Doom3-alike GUI (embedded in 3D scene)

Return to Code Snippets

Doom3-alike GUI (embedded in 3D scene)

Postby coppertop » Sat Jan 15, 2011 4:18 pm

For a while now I've been trying to figure out a way to display functional DirectGUI in 3D. Or, more precisely, wondering if that's possible. My intent was making something like Doom3's GUI -- a "virtual screen" embedded in the 3D world, with a cursor, buttons and so on.

Recently this idea came back to me, and after some experiments I managed to make it work. In fact, it was easier then I thought -- all it requires is cloning the aspect2d. But I thought I'll post it here anyway, in case someone is/was/will be trying to do the same.

To make it clear how it works -- it doesn't make DirectGUI objects directly "pickable". It only renders the GUI to a texture and uses the standard MouseWatcher to make it functional. Still, that doesn't make much difference. Combined with mouse look it can be configured to behave similarly to the Doom3's screens (but not identically). On the other hand, this approach made it extremely flexible. Since it's just a texture, you can do whatever you want with it -- setups with multiple virtual monitors, the same GUI displayed in many places, projection or even wrapping it around complex objects. In all these cases it'll still work and allow you to operate the GUI using the mouse and keyboard.

Additionally, using this code with any GUI you already have should only require reparenting.

http://dl.dropbox.com/u/196274/InteractiveTexture.zip

Note, that MRelative mouse mode is currently not supported on Windows, so by default the demo starts in fullscreen there. Otherwise the mouse would escape the window and the virtual screen would stop working. This is possible to work around, but it would require the VirtualMouse, which would make the code twice it's current length...

Anyway, hope someone will find it useful.
User avatar
coppertop
 
Posts: 527
Joined: Sat Apr 18, 2009 5:48 am

Postby Derek » Wed Jan 19, 2011 8:01 am

Nice work, I was inspired.

I just started working on a pygame project and to test out the pgu gui framework I decided to make something simmilar to what you did.

Image

And with transparency enabled.

Image
User avatar
Derek
 
Posts: 19
Joined: Tue Mar 18, 2008 3:22 pm
Location: Ontario, Canada


Return to Code Snippets

Who is online

Users browsing this forum: No registered users and 0 guests

cron