Using Scene 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
TunaBreeze
Posts: 8
Joined: Fri Apr 27, 2007 1:20 am

Using Scene Nodes

Post by TunaBreeze »

Okay, the scene system uses nodes.

IAnimatedMeshSceneNode

My game is first person. Should each entity in the game have its own node, or can/should I be putting them under the same node? How are they best used?
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

You typically create scene nodes that are children of the root scene node. This happens automatically if you specify a NULL parent pointer when you call add*SceneNode*.

If you make a node a child of some other scene node it will move and rotate with its parent. The nodes are attached, similar to the way wheels are attached to a car. If you pick up the car and move it around, the wheels and tires stay in the same position relative to the car itself. This does not happen for nodes that are not in an ancestor/child relationship.

Travis
TunaBreeze
Posts: 8
Joined: Fri Apr 27, 2007 1:20 am

Post by TunaBreeze »

Sorry, didn't word my question the way I want to.

I understand the ancestor/child relationship, but when I have several instances of the same type of object do I create a node for each instance of the object or can I use the same node for each instance?
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Well the new question seems even more confusing than the first... You would create a new node for each instance. How would you use the same scene node for every instance of the same object?

Say you had a dozen zombies walking around a level. If you have 12 zombie nodes, the position and orientation of each of them is kept seperate, and they would each be rendered automatically by the scene manager.

If you use the same scene node for all 12 zombies, you would have to move the scene node and render it 12 times. You would have to do this manually, and you would have to store the position and orientation of each zombie seperate from the scene node.

Travis
TunaBreeze
Posts: 8
Joined: Fri Apr 27, 2007 1:20 am

Post by TunaBreeze »

Sorry for confusing you, but you managed to answer my question, thanks.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

As you can see IAnimatedMeshSceneNode is created from IAnimatedMesh using ISceneManager::addAnimatedMeshSceneNode (...).
IAnimatedMesh is created from your model file (x, 3ds, ...) using ISceneManager::getMesh(...).

So say you want dozen zombies walking your lewel and you have one zombie.x file. You create one mesh from your zombie.x and then use that one mesh to create dozen zombie nodes. All your zombie nodes will share the same mesh however they can be placed, animated, scaled, rotated individualy.
TunaBreeze
Posts: 8
Joined: Fri Apr 27, 2007 1:20 am

Post by TunaBreeze »

Thank you again, both very helpful.
Post Reply