Irrlicht Parent and Child nodes

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
Sfortza
Posts: 39
Joined: Thu Mar 17, 2011 12:40 pm
Location: 184

Irrlicht Parent and Child nodes

Post by Sfortza »

Is it important for Irrlicht that every node have a parent?
Does it affect rendering speed?

For example:
Have ITerrainSceneNode, IMeshSceneNodes (4 different types: house, tree, bush, fence), IAnimatedMeshSceneNodes(6 characters).

What is optimal scene graph to perform rendering effectively?

Thank you!
CuteAlien
Admin
Posts: 9716
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Irrlicht Parent and Child nodes

Post by CuteAlien »

It's simple - the scenegraph is a tree which starts at the rootscenenode (scenemanager itself). And everything in that tree is rendered. So if a node has no parent it can't be in that tree and therefore will not be rendered. So the answer is - if you want to render it then it needs to have a parent. Note - if you set none when adding a node to the scenemanager, then it will automatically set the rootscenenode as parent, so you always have one unless you remove it explicitely.

What helps for speed is to have less nodes. If you have for example lots of static meshes then you can combine them together, for example with one of those nodes: http://irrext.svn.sourceforge.net/viewv ... ene/IMesh/
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
Sfortza
Posts: 39
Joined: Thu Mar 17, 2011 12:40 pm
Location: 184

Re: Irrlicht Parent and Child nodes

Post by Sfortza »

CuteAlien, thank you very much!

Does it matter for Irrlicht, that for each scene node, I assign -1 as a parent?
Would it be more efficient for example for terrain set -1 as a parent and terrain itself as a parent for
other static scene nodes?
CuteAlien
Admin
Posts: 9716
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Irrlicht Parent and Child nodes

Post by CuteAlien »

Assigning -1 is a very, very(!) bad idea! We're talking here about setting pointers, -1 would simply set invalid memory and as it's not 0 it wouldn't even know it's invalid - never do that.

But I think you still have not understood what those pointers are used for, otherwise you could answer those questions yourself. The only reason they exist is to form the scenegraph. This works as follow - in rendering Irrlicht starts with the rootscenenode (the scenemanager itself) and then renders all children (which are all scenenodes which have the root as parent - which is the default). And recursively the same happens for childrens (they check which children they have and render those - and those do the same again, etc...).

So as soon as the connection to the root is broken a node is no longer in the scenegraph and can no longer be rendered.

And you usually want to keep the hierarchy flat - so simple don't set any parent/child relationships until you need them. And you only need them if you have objects which you want to move together - for example you add smoke to a steam train - then you would make the particlescenenode a child of the train so the particles would always start at the same place relative to the train.
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
Sfortza
Posts: 39
Joined: Thu Mar 17, 2011 12:40 pm
Location: 184

Re: Irrlicht Parent and Child nodes

Post by Sfortza »

CuteAlien, thank you once again for very useful response!
Sfortza
Posts: 39
Joined: Thu Mar 17, 2011 12:40 pm
Location: 184

Re: Irrlicht Parent and Child nodes

Post by Sfortza »

Are the Irrlicht extensions like CBatchingMesh or CMeshCombiner suitable for animated meshes?

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

Re: Irrlicht Parent and Child nodes

Post by CuteAlien »

I think that will work only for static meshes.
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
Sfortza
Posts: 39
Joined: Thu Mar 17, 2011 12:40 pm
Location: 184

Re: Irrlicht Parent and Child nodes

Post by Sfortza »

CuteAlien, how do you think can I combine terrain and static meshes with extensions
and create Octree node after that from combined mesh to get more effective
rendering by reducing draw calls this way?

Thank you!
CuteAlien
Admin
Posts: 9716
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Irrlicht Parent and Child nodes

Post by CuteAlien »

Sorry, didn't try that - just experiment.
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
Sfortza
Posts: 39
Joined: Thu Mar 17, 2011 12:40 pm
Location: 184

Re: Irrlicht Parent and Child nodes

Post by Sfortza »

Ok, thank you!
I'll try!
Post Reply