Game Development Community

How to render a 3D object in front of all other 3D objects?

by Tom Giant · in Torque 3D Professional · 03/07/2011 (7:42 am) · 3 replies

I want to draw a certain 3D object in front of all other 3D objects. I suppose I may need to clean Z buffer before drawing the certain 3D object(topmost 3D object), of course, I also need beforehand control the render order, or may just directly modify its Z value.

But I don't really know how to make the effect by Torque. Does anybody know that?
Thanks for any help in advance.

#1
03/08/2011 (9:31 am)
I would be interested in this as well. My guess is that it will require changing the source code for the type of item to render but I hope I'm wrong about that.
#2
03/08/2011 (11:06 am)
You have to provide a bin that will render the object to a buffer (Render to texture).
Currently the glow bin does exactly the same.
Of course you will have to apply some changes.

Locate this:
for( U32 j=0; j<binSize; )
   { ...

Add this above it:
GFXStateBlockDesc desc;
desc.setZReadWrite( false, false );
GFXStateBlockRef mStateblock = GFX->createStateBlock( desc );

Then go to the draw call and set the stateblock :
GFX->setStateBlock(mStateblock);

if ( passRI->prim )
     GFX->drawPrimitive( *passRI->prim );
 else
     GFX->drawPrimitive( passRI->primBuffIndex );

Then make sure that you process the bin after the rest ones.
After that you create a post effect,where you fetch the texture from the buffer and output the color.
#3
03/15/2011 (4:30 am)
Sorry, I'm late. Thank Ivan very much. I suppose what you said is how to implement own additional RTT. I knew there were two GUI controls "GameTSCtrl" and "GuiObjectView" with RTT, but I more hope to control 3D object directly, because I need to pick up and drag the 3D object.

Anyway, I've got some clues from your codes. Thanks.