traversal

New Message Reply Date view Thread view Subject view Author view

From: Dirk Scheffter (scheff++at++iff.fhg.de)
Date: 05/22/2001 02:52:36


Hi Eric,

two alternatives:

1st: Use a traverser.
     -> man pfNode (setTravFuncs, setTravData)
     -> man pfTraverser
     Note: pfNode::setTravData seems to apply data per traversal, not per
           node as you would may be expect.

(Does anybody have an explanation for this?)

2nd: write your own traversal:

void TravPfNode(
  pfNode *pPfNode) // node which should be traversed
{
  if (pPfNode->isOfType(pfGroup::getClassType())) {
    int n = ((pfGroup*)pPfNode)->getNumChildren();
    for (int i = 0; i < n; ++i) {
      TravPfNode(((pfGroup*)pPfNode)->getChild(i));
    }
  } else if (pPfNode->isOfType(pfGeode::getClassType())) {
    int n = ((pfGeode*)pPfNode)->getNumGSets();
    for (int i = 0; i < n; ++i) {
      ((pfGeode*)pPfNode)->getGSet(i);
      // do your stuff with geosets here
    }
  }
}

You can add specific handling of nodes like switches, LODs and so on.
Don't forget to check first derived classes and then super classes (for
example pfDCS before pfSCS etc.) because isOfType() matches for all super
classes of a class, also.

It is not as difficult as you may expect because the number of different
scenegraph nodes is quite limited in Performer which makes this rather
easy.

Regards,
Dirk.

-----------------------------------------------------------
Dipl.-Inf. Dirk Scheffter scheff++at++iff.fhg.de
Fraunhofer IFF fon: +49 (0) 391/40 90-854
Sandtorstr. 22 fax: +49 (0) 391/40 90-870
D-39106 Magdeburg http://www2.iff.fhg.de/~scheff
Germany
-----------------------------------------------------------


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Tue May 22 2001 - 02:52:23 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.