02/05/2002
15-462 Graphics I
27
Generic Traversal
•
Recursive definition
•
•
•
•
•
•
•
•
•
C is really not the right language for this
void traverse (treenode *root)
{
if (root == NULL) return;
glPushMatrix();
glMultMatrixf(root->m);
root->f();
if (root->child != NULL) traverse(root->child);
glPopMatrix();
if (root->sibling != NULL) traverse(root->sibling);
}