How to make a mesh drawn in front of everything?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Tihtinen
Posts: 76
Joined: Fri Jan 08, 2010 3:12 pm
Location: Finland

How to make a mesh drawn in front of everything?

Post by Tihtinen »

I guess this has something to do with ZBuffer, but only disabling it won't get me the result I want (because it will then draw the mesh to the back of everything).

So how to have an animated mesh scenenode drawn in front of everything, ignoring possible zbuffer culling?
Bate
Posts: 364
Joined: Sun Nov 01, 2009 11:39 pm
Location: Germany

Post by Bate »

you could render the mesh in a new viewport on top of the main viewport.
just make sure you call driver->clearZBuffer() before the 2nd draw call.
Never take advice from someone who likes to give advice, so take my advice and don't take it.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

It should be possible by disabling depth buffer for that node. I never did it in Irrlicht however so somebody else might know more.

There is flag somewhere for depth buffer.
Bate
Posts: 364
Joined: Sun Nov 01, 2009 11:39 pm
Location: Germany

Post by Bate »

There are 2 material flags...

EMF_ZBUFFER
EMF_ZWRITE_ENABLE

maybe that works as well.
Never take advice from someone who likes to give advice, so take my advice and don't take it.
Tihtinen
Posts: 76
Joined: Fri Jan 08, 2010 3:12 pm
Location: Finland

Post by Tihtinen »

Bate wrote:There are 2 material flags...

EMF_ZBUFFER
EMF_ZWRITE_ENABLE

maybe that works as well.
As I said in my post, these don't work because they both only make sure the node is drawn behind everything, as opposite to what I want :/
arras wrote: It should be possible by disabling depth buffer for that node. I never did it in Irrlicht however so somebody else might know more.

There is flag somewhere for depth buffer.
I'd be happy to try this out, but I can't find this flag in the API, so if someone knows where it is, it would be great :)
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

No, ZWRITE means that you toggle whether the zbuffer is updated with the geometry you render. This is on by default, because this is the usual depth effect where things in front will be rendered over things in the back. If you toggle the ZBUFFER flag off it means that you don't care for the depth value, so the geometry will be always rendered. However, if something else is rendered later on, it would still be rendered over the other geometry. So you need to render the geometry on top last, after the drawAll() call. Either use a second scene manager, or render the object manually.
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Post by Lonesome Ducky »

Also, I'd try to avoid rendering without zbuffer. Sometimes, triangles of the node you're drawing will be drawn over others they shouldn't be, because it's not checking depth. Clearing the zbuffer is, in my opinion, the most practical option.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

So you need to render the geometry on top last, after the drawAll() call. Either use a second scene manager, or render the object manually.
That is probably best way (drawing it manually after everything else).

Sorry for that flag, there is none. I mus have been confusing some other engine.[/code]
Tihtinen
Posts: 76
Joined: Fri Jan 08, 2010 3:12 pm
Location: Finland

Post by Tihtinen »

Ok, I think I understand now what I need to do. Thanks for your help : )
Post Reply