Iterating over World Nodes
From C4 Engine Wiki
The following code snippet iterates over the nodes in a world.
Node *root = TheWorldMgr->GetWorld()->GetRootNode(); // start at the root Node *node = root; do { if (node->GetNodeType() == kNodeGeometry) { // do something with a geometry node. } node = root->GetNextNode(node); } while (node);
GetNextNode() performs a depth-first traversal of the tree. Since the root node of a world won't be a geometry, you could also start with the root's first subnode to save one iteration of the loop:
Node *node = root->GetFirstSubnode();
The above example looks for geometry nodes, but you could also search for any of the other node types.
