Archived

This topic is now archived and is closed to further replies.

Iterating through the nodes in a scenegraph???

This topic is 4946 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello all, I''ve just implemented a scene graph and I''m able to render the children. I''m have some trouble though because I want to start at the root and iterate through the whole scene. Since each node (including the root) can have as many nodes as they want how would I go about iterating through the whole tree?? I hope my question is clear. The way I have it now I have to set a pointer to a certain child and from there I''m able to do transformations on it and its children.

Share this post


Link to post
Share on other sites
call the function recursively (can''t spell it :/..)

procedure update(node: tnode);
begin
for i := 0 to high(nodes) do
update(nodes);
the rest of the update code here..
end;

sorta delphi code but that''s the way i do it!

Share this post


Link to post
Share on other sites
Here''s some pseudocode that should,
hopefully, give you the basic idea.

void SceneNode::doSomething() {
// Perform some operation like rendering
// updating

// Now process all child nodes
processChildren();
}

void SceneNode:rocessChildren() {
// Process all chldren, if any
for all children begin
current_child->doSomething();
end loop;
}

Share this post


Link to post
Share on other sites