Acessing Children - A simpler question

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
Evil Mr Sock
Posts: 37
Joined: Fri Jul 02, 2004 5:36 pm
Location: Albany, NY
Contact:

Acessing Children - A simpler question

Post by Evil Mr Sock »

Okay, I'll take the gravity problem out of the equation -

getChildren () returns a constant reference to a list of all children. How do I navigate this list, access individual nodes in it?
------------------------------------------
A monkey poured coffee in my boots.
------------------------------------------
cinek
Posts: 13
Joined: Sat Aug 07, 2004 3:00 pm
Location: Poland

With an iterator

Post by cinek »

Check API documentation for irr::core::list<T> and irr::core::list<T>::iterator.

Basicly it would look like this (I'm assuming you have a list of ISceneNodes, same rule applies to other classes):

Code: Select all

irr::core::list<ISceneNode>::iterator i;

i = MyRootNode->getChildren().begin();

while(i != MyRootNode->getChildren().end()) {
    // do something (*i is the list element)
    i++;      // advance the iterator to next item
}
I'm not 100% sure about this (I've only seen a friend of mine do this :) but that's how it should generally by done.[/quote]
Cinek
Post Reply