How do you draw an ISceneNode without Z information ?

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
eye776
Posts: 94
Joined: Sun Dec 28, 2008 11:07 pm

How do you draw an ISceneNode without Z information ?

Post by eye776 »

I have made a custom SceneNode (a 3 axis gizmo), and it's pretty much functional, however it's currently obscurred by the selected node that it's supposed to affect.

So, quick stupid question: How do you force a single node to be drawn on top of the whole scene (regardless of Z ordering)?
CuteAlien
Admin
Posts: 9720
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Putting it into an own scenemanager (ISceneManager::createNewSceneManager) and resetting the z-buffer before drawing (IVideoDriver::clearZBuffer) that scenemanager could work.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
eye776
Posts: 94
Joined: Sun Dec 28, 2008 11:07 pm

Post by eye776 »

Thanks for the idea. I didn't need a separate SceneManager, did this instead:

Code: Select all

__AT_DRIVER->clearZBuffer();
for(u32 i = 0; i < 3; i++)
{
    __AT_DRIVER->setMaterial(__AT_GIZMO->getAxis(i)->getMaterial(0));
    __AT_GIZMO->getAxis(i)->render();
}
Works as intended.
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Post by Lonesome Ducky »

Couldn't you just do:

Code: Select all

node->setMaterialFlag(EMF_ZBUFFER,false)
CuteAlien
Admin
Posts: 9720
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Lonesome Ducky wrote:Couldn't you just do:

Code: Select all

node->setMaterialFlag(EMF_ZBUFFER,false)
No, this would cause other objects no longer knowing about the node's depth, so every object rendered afterward would overwrite it. EMF_ZBUFFER is about writing in the z-buffer - so you rather want the opposite and fill the z-Buffer with information that this object is really in front. Could be there is also some other way to do this (using some projection matrix which puts the object closer to the camera but scales it smaller so it looks still the same might also work maybe), but I used so far always a second scenemanager for objects drawn in front of the usual scene.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Post by Lonesome Ducky »

It seemed like he was calling render manually, so he could just render it with EMF_ZBUFFER as false after the normal rendering so it will always be drawn over everything. I think it should be faster than clearing the entire zbuffer as well.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Yes, with zbuffer and zwrite set to off it should be definitely faster than clearing z-buffer twice per scene.
CuteAlien
Admin
Posts: 9720
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

I guess it depends if object you draw needs the z-information itself. If you can render it without z-buffer it's probably fine. But if it's the same kind of 3-axis-gizmo as in irrEdit then it might look messed up.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Okay, right. The object is usually seen non-overlapping in examples, but of course the axes might overlap when seen from other angles.
Post Reply