Draw scenenode "Always on top"

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
Qps
Posts: 18
Joined: Thu Jan 27, 2011 2:02 pm

Draw scenenode "Always on top"

Post by Qps »

Hi all,

i was wondering how i could ensure that a scenenode is drawn in front of everything else. im using directx not opengl.

I tried playing about with:

Code: Select all

m_material.ZBuffer = irr::video::ECFN_ALWAYS;
And:

Code: Select all

m_material.ZWriteEnable = false;
Unfortunately every thing i tried resulted in the node being drawn on the background or the usual 3d effect. But not infront as i would like it to be.

This is what i have in the render function of the node:

Code: Select all

pDriver->setMaterial(m_material);
pDriver->setTransform(irr::video::ETS_WORLD, irr::core::IdentityMatrix);
pDriver->drawIndexedTriangleList(&lineVertices[0], 4, &indices[0], 2);
i could render it in a different draw call on the scene but is that the only way or is there an easier way.

thanks in advance
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Draw scenenode "Always on top"

Post by hendu »

Besides turning off Z testing and writing, you also need to draw it after everything else.
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Draw scenenode "Always on top"

Post by Mel »

No, don't turn off Ztesting and writting, or else the node won't draw properly. Instead, draw all the objects of the scene but the one you want on top, then clear the ZBuffer, and after, draw your node manually.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Qps
Posts: 18
Joined: Thu Jan 27, 2011 2:02 pm

Re: Draw scenenode "Always on top"

Post by Qps »

thanks for your reply, Ill try that today.
Abraxas)
Posts: 227
Joined: Sun Oct 18, 2009 7:24 am

Re: Draw scenenode "Always on top"

Post by Abraxas) »

Is there a bool field to stop a node from automatically rendering?

When making nodes "invisible" you run into problems with anims and children, so instead of that, is there a way to differ rendering to a manual call?

looking for something like node->updatebutdontdraw(true);
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Draw scenenode "Always on top"

Post by Mel »

call onAnimate(time);

time is the current time; ex. device->getTimer()->getTime();

this updates the animations of the animators and calls all the childs onAnimate();
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Draw scenenode "Always on top"

Post by hendu »

@Mel

The code quoted has two tris, made from four verts. It's pretty hard to make those overlap to produce Z errors ;)
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Draw scenenode "Always on top"

Post by Mel »

Well, i solved the general case,Even for 2 overlapping triangles, that would always work ;)
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Post Reply