Re: [info-performer] DCS to World Coordinates

Date view Thread view Subject view Author view

From: Dan Johnston (dan.johnston++at++nrc.gc.ca)
Date: 06/16/2005 11:31:41


"Larry E. Ramey" wrote:

> OK.......
>
>
> I understand the idea. Where is the global matrix value then?
>
> So I put a traverser on some DCS that may or may not have many SCS/DCS
> above it.
>
> What function do I call to get the complete transform?
> At this point in the Traverser (and what traverser should it be? APP,
> CULL, DRAW?) all I have is the (pfTraverser* trav, void* data)
>
> So with trav I have get the pfDCS. I don't see a whole lot of
> functions on pfDCS that might be helpful......
>
>
> Larry
>
>
>
>
>
>
>
Start by setting the pfTraverser in your application code.
I have a library function which does this. Notice you must
set the callback function to be invoked when the node is
traversed. I also pass data to pfTraverser so that the
callback can reference the same shared memory structure
(e.g. arena) because I store my viewpoint in this shared
data structure.

I also set a flag in the shared memory block to indicate
that the library has just defined a tethered viewpoint (i.e.
the view mode is added to my list). And, I reset
a tethered view 'offset'. The offset allows me to
"look around" from the tethered view.

/**
    \ingroup mod_UserViewpoint
    A internal library function to set a scene graph node to be a source

    of viewpoint position and orientation. The viewpoint will be
    'tracked' to this node when the correct viewing mode is selected.
    The application can define an offset (position and orientation) for
    this viewpoint, but this offset is initially set at 'identity'.
    The library code will define a traverser callback function which
will
    grab the Performer calculated position and orientation of the node
    and use this value to set the tethered viewpoint.

    \see apTravViewpoint

    \param pointer a pointer to the pfAPC setup structure which will
make
    use of the new tracked viewpoint
    \param node the scene graph node to be tracked
*/
PFAPCDLLEXPORT void
apSetupTetherViewpoint( APCsetup pointer, pfNode *node )
{
    APsetup *setup = (APsetup *)pointer;
    setup->shared->tetherView = PF_ON;
    /* use the traverser callback on the supplied node to set viewpoint
*/
    pfNodeTravFuncs( node, PFTRAV_APP, apTravViewpoint, NULL );
    pfNodeTravData( node, PFTRAV_APP, (void *)setup->shared );
    /* create an offset matrix and set to no offset (default) */
    setup->shared->tetherOffset.xyz[0] = 0.0f;
    setup->shared->tetherOffset.xyz[1] = 0.0f;
    setup->shared->tetherOffset.xyz[2] = 0.0f;
    setup->shared->tetherOffset.hpr[0] = 0.0f;
    setup->shared->tetherOffset.hpr[1] = 0.0f;
    setup->shared->tetherOffset.hpr[2] = 0.0f;
}

Once the node is traversed, the following short function
is called. I sinply use the traverser data to re-connect
to my shared data, and then extract the node's matrix-
in-world-coordinates directly into the shared structure.
When my view mode is "tethered" then this matrix
value, post-multiplied by any user-defined view offset,
will be used as the viewpoint.

/*
 *---------------------------------------------------------------------------

 * apTravViewpoint
 *---------------------------------------------------------------------------

 */
/**
    \ingroup mod_library_setup
    The traverser callback function that obtains a copy of the
    node's position and orientation after performer has completed the
    forward calculations for the nodes matrix. In other words, the
    position and orientation will be in world coordinates, not in
    local node coordinates.
    \param trav a pointer to the pfTraverser that is a standard
    parameter of this type of callback
    \param data the void pointer to the data passed to the traverser
    when the callback function was defined, in our case it is a
    pointer to the display setup description
    \return the PFTRAV_CONT value must be returned or the traversing
    will be stopped by Performer.

    \see apSetupTetherViewpoint
*/
PFAPCDLLEXPORT int
apTravViewpoint( pfTraverser *trav, void *data )
{
    APshared *share;

    /* extract the current value of the matrix */
    share = (APshared *)data;
    pfGetTravMat( trav, share->tetherViewPoint );
    return PFTRAV_CONT;
}

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


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Thu Jun 16 2005 - 11:34:05 PDT