Selective Object Rendering

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
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Selective Object Rendering

Post by Vectrotek »

I can control whether an object is rendered or not with" setVisible(true/false)"..
Now I want to render only the nodes that was "added" to a Render Pass..

Code: Select all

 
 // PassedIrrDevice->getSceneManager()->drawAll();  // O.K. this works, but I want to..
 
 // Pointers to these are stored in an array inside a given pass.. (they were "add()'ed")
 for (u32 I = 0; I < AnimatedMeshNodeCount ; I++)
  {
   AnimatedMeshesPTRArray[I]->render();
  // What must happen AFTER "render()" to actually see it in the frame buffer?
  }
 
  // I know it renders, but how do I finalise. i.e swop buffers AFTER all of this..
 
  // Something should happen here after all "render()"s, but what?
 
 



Is it a good idea to render selected objects this way?
(considering other overhead inside "draw all" I'm not aware of)
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Selective Object Rendering

Post by Vectrotek »

..
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Selective Object Rendering

Post by CuteAlien »

Answer is ... depends. Basically you can do that. Or you can also use additional scenemangers and render them in any order.
But maybe check the code of SceneManager::drawAll to be aware of what it's doing.
What you are missing now are some things, but you can do them yourself as well probably.
First is that you need to call OnAnimate for animated nodes.
Next is - you need some sorting for transparent nodes (stuff further away has to be drawn first).
And if you run into any problems - it's probably related to zbuffer in some way, so be aware what is written in there.
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
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Selective Object Rendering

Post by Mel »

I used a list of empty -dummy- scene nodes that acted as "root" for their children to be rendered, and were the first attached to the scene manager, as they were the first processed, they acted as "render-Passes" or "layers" as I named them,

pros: lighting manager may tell you which render pass is being rendered in each moment, and act accordingly

cons: If you aren't careful you might be calling "drawAll" more than once, which calculates all the frames and the animations of the the nodes all the times, with the probable overhead
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Selective Object Rendering

Post by Vectrotek »

Thanks! :)
Post Reply