Page 1 of 1

I need a sort of top-most 3d layer

Posted: Sun Jun 21, 2015 3:35 pm
by MyGrandmaWheels
Hello to everyone.
Maybe I'm about to ask a silly question; in this case, excuse me, I'm just a Irrlicht newbie.

I'm implementing a simple CAM utility, something to generate CNC toolpath from 3d meshes.
I'm using some custom scene node and a mesh node, they all are children of the root scene node, and so far so good.

Now I need to render another scene node that must always totally be visible, I mean even if is totally or partially occluded by my other nodes that could be ahead.
This node would be a sort of wireframe placed somehow in a top-most layer; I hope to have explained quite clearly.

Have you suggestions?

Re: I need a sort of top-most 3d layer

Posted: Sun Jun 21, 2015 5:17 pm
by Seven
if you keep your own pointer to the node in question, you can just draw it last.

begin frame

specialnode->setVisible(false);
smgr->drawAll();
specialnode->setVisible(true);
specialnode->draw();

end frame

Re: I need a sort of top-most 3d layer

Posted: Mon Jun 22, 2015 7:08 am
by MyGrandmaWheels
A piece of cake, it seems!
Many thanks!

Re: I need a sort of top-most 3d layer

Posted: Mon Jun 22, 2015 8:28 am
by MyGrandmaWheels
Maybe I'm doing something wrong, but it doesn't work, it seems..
the special node is as usual occluded by eventual nodes ahead.
A little note: I used the render() method, because draw() doesn't exist. I don't know if it's an outstanding topic..

Re: I need a sort of top-most 3d layer

Posted: Mon Jun 22, 2015 9:48 am
by CuteAlien
The render function is correct. You have to clear the zbuffer (IVideoDriver::clearZBuffer) before drawing that node. If you have more than one node you can also put them in an own scenemanger (ISceneManager::createNewSceneManager) which you render later. That also needs a clear of the zbuffer in between.

Re: I need a sort of top-most 3d layer

Posted: Mon Jun 22, 2015 1:09 pm
by hendu
Depending on the type of node, before render() you need to set the scene manager's pass.

Re: I need a sort of top-most 3d layer

Posted: Tue Jun 23, 2015 7:15 am
by MyGrandmaWheels
CuteAlien wrote:The render function is correct. You have to clear the zbuffer (IVideoDriver::clearZBuffer) before drawing that node. If you have more than one node you can also put them in an own scenemanger (ISceneManager::createNewSceneManager) which you render later. That also needs a clear of the zbuffer in between.
this is the outstanding element: it works perfectly!
There's no need to make the special node invisible and, after rendered, visible.

Code: Select all

 
device->getVideoDriver()->beginScene(true, true, SColor(255, 50, 50, 50));
 
device->getSceneManager()->drawAll(); // "normal" rendered nodes
 
device->getVideoDriver()->clearZBuffer();
wrkTP->render();  // top-most node
 
device->getVideoDriver()->endScene();
The only smear is that the clearBuffer method is marked as deprecated, rising a compiler warning; not a problem at all, anyway!

Many many thanks to everyone!

Re: I need a sort of top-most 3d layer

Posted: Tue Jun 23, 2015 8:34 am
by CuteAlien
Ah yes, if you are using newest svn trunk it's deprecated. But will still work for a long time. And the function replacing it might get another change shortly (enum instead of bools).