Game Development Community

Idea: rendering GuiControls with ZBuffer enabled

by Orion Elenzil · in Torque Game Engine · 01/09/2007 (2:28 pm) · 3 replies

Hey All -

i'm hoping some folks familiar w/ the low-level 3D stuff can advise me here.

i'm considering replacing the GuiShapeNameHud with a more flexible system where instead of one control rendering a bunch of names, it would be a bunch of container GuiControls which would automatically render above the player they're attached to. - Then they could contain GuiMLText, bitmaps, whatever.

this seems pretty straight forward and i can definitely do it.

but then i started considering the issue of how player names in the ShapeNameHud show through walls, etc.
in The Music Lounge, we've gotten around this by doing several raycasts for each player to decide if they're actually visible. this is working pretty well.

- so i thought to myself, now wait a second. why am i doing these raycasts when i've got a perfectly good zBuffer sitting here ?

so what do you think of rendering GuiControls with the ZBuffer turned on ?

seems simple, but maybe i'm missing something.

thoughts ?

tia,
orion

#1
01/09/2007 (3:05 pm)
It's a good thought, (and good to do for any of the VR displays, so the hud appears at the right place in 3D)

the only problem you may run into is if the zbuffer is ever used in interesting ways by things in front of names.
or if depth buffer is cleared before gui is rendered or anything like that.

probably have to make transparent render images out of your Hud pieces and insert them into the scenegraph so they get sorted and rendered right with the rest of the world.

in the end the ray cast might not be so bad, hard to tell.

perhaps they aren't gui at all, but some new object type that just uses the same text rendering routines as the guimltext?
#2
01/09/2007 (4:10 pm)
My intial tests with this are proving somewhat fruitless,
but i'll keep trying!

the nice thing about using a GuiControl is that we're not limited to the functionality of GuiMLText or any one control. we could have a GuiMLText and a button and um... a bitmap and.. uh.. a GuiObjectView (haha) etc.

.. aha! since typing i had some success! i've got a 2D rectangle nicely doing the ZBuffer thing with some DIFs and avatars. hmm it's in weird coordinates tho. maybe i'm manipulating the wrong matrix.
#3
01/09/2007 (5:29 pm)
Just for completeness sake,
it looks like rendering GuiControls w/ zbuffer should work, but i've given up due to not knowing what i'm doing with projection matrices. my particular application is already using the raycast approach so we'll continue doing that, but the zBuffer would be nicer so i may revisit it at some point.

thanks for helping out clint !