Performer C++ API - callback as member function

New Message Reply Date view Thread view Subject view Author view

From: Daniel F Johnston (dan.johnston++at++nrc.ca)
Date: 04/19/2000 04:31:14


We have defined some 'graphics object' class in C++ to allow us to
easily build
up a scene graph from a readable text description.

One of these classes is a ViewPoint - implemented as a traverser
callback on
an offset DCS (DCS makes it easer to read the matrix) so that the
forward
value of the matrix can be used to define the viewing
position/orientation
and the displays 'follow' a moving object.

I would like to implement the pfTravFuncs call inside one method of the
class. The function name is of type 'pdNodeTravFuncType'. I would
like to encapsulate the callback function also as a method of the class,
so
each viewpoint has its own callback defined within it. The type of this

callback function is int - so it can pass back the 'PFTRAV_CONT" flag.

How do I declare/cast these methods so that the compiler will pass them
and so they work as I wish. I looked at this for a hour os so yesterday

but my brain wasn't working too well - then or today. So, lets ask
the experts out in Performer land.

Thanks for any help!

PS Here is a code snippet - the stuff that doesn't work
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
...
    viewPointDCS = new pfDCS();
    root->addChild(viewPointDCS);
    viewPointDCS->setTravFuncs( PFTRAV_APP, NULL, altViewSave);
    setGraphRoot(root);

    // Remember that we have been initialized...
    setGraphInitialized(true);
    if( shared->verbosity > 0 )
        pfNotify(PFNFY_NOTICE, PFNFY_PRINT, "GFXViewPoint::init -
Done\n");
    return true;
}

int
GFXViewPoint::altViewSave( pfTraverser *trav, void *data)
{
    // store the current DCS value (in world coordinates) as our
viewpoint
    pfDCS *node;

    node = (pfDCS *)trav->getNode();
    node->getMat( shared->cabViewPoint );
    return PFTRAV_CONT;
}

++++++++++++++++++++++++++++++++++++++++++++++++++++++++

--
      ___|__    |
      /  |  \   ||\      Daniel (Dan) Johnston
     /___|___\  || \     Dan.Johnston++at++nrc.ca
    _____|____  ||  \    National Research Council of Canada, London, ON
    |    |    | ||   \   Integrated Manufacturing Technologies Institute
\___|    |    | ||____\  Tel: (519) 430-7081   Fax: (519) 430-7090
 \_o_\___|____|_|______\_    Inst: http://www.nrc.ca/imti
  \                o /    These opinions are my own! Not those of NRC.
   \________________/    Virtual Reality:
                        http://www.nrc.ca/imti/vetc/home.html
 More Tall Ships - Fewer Computers!


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Wed Apr 19 2000 - 05:32:07 PDT

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