Re: [info-performer] how to get pfDCS absolute coordinate

Date view Thread view Subject view Author view

From: Dan Johnston (dan.johnston++at++nrc.ca)
Date: 11/09/2004 13:00:26


Since nobody else has replied to this...

The 'traditional' way to get the absolute value of a node's transform
is to set a pfTraverser on that node. You set the traverser to 'trigger'
on the draw process. The traverser callback function will then be
used to save the current value of the node's matrix into shared
memory. Since this matrix is taken from the draw process, and
since Performer will have already done all the forward transforms
to get to this node, then you have the absolute value without any
additional calculations - just one frame of latency which is usually
not a serious problem.

I (and many others) use this to attach a viewpoint to a moving
node. Just grab the absolute value from the node's traverser
and use that matrix to set the current viewpoint, and you are
done. No matrix calculation required.

If you would like to see code examples for this, look at the
'tethered' objects in the 'perfly' source, or contact me
directly for some of my examples.

Dan Johnston

Juergen Wind wrote:

> Am Montag, 8. November 2004 10:15 schrieb Andrea Martini:
> > *This message was transferred with a trial version of CommuniGate(tm) Pro*
> > Hi to all,
> > i would like to get absolute coordinate of a node,(ie pfDCS), after some
> > transformations. In example, i suppose to have a pfDCS node, and starting
> > from P0(0.0,0.0,0.0) i move this node first in P1(X1,Y1,Z1) with HPR1
> > rotation, then in
> > P2(X2,Y2,Z2) with HPR2 rotation, ... and last, at in Pn(Xn,Yn,Zn) with
> HPRn
> > rotation. If i use pfDCS::getMat(), performer returns me only the last
> > transformation as translate. But, i want the absolute position (in the
> > World Coordinate), of this node inside the scene.
> > Could someone help me?
> > thank you
> >
> >
> > PS: I use Opengl Performer 3.1, on Windows 2000, and Visual c++ 6.0
> >
>
> Hi Andrea,
>
> the following code does it in Avango (tm):
>
> void
> fpPerformerNode::getAbsoluteTransform(fpMatrix& xform)
> {
> // walk up to the root node and accumulate transformation matrices
>
> xform.makeIdent();
>
> pfMemory* pfmem = castToPerformer();
>
> if (pfmem && pfmem->isOfType(pfNode::getClassType())) {
> pfNode* walk = (pfNode*) pfmem;
> fpMatrix scsmat;
> pfSCS* scs;
>
> if (walk->isOfType(pfSCS::getClassType())) {
> scs = (pfSCS*) walk;
>
> scs->getMat(scsmat);
> xform.postMult(scsmat);
> }
>
> while (walk->getNumParents()) {
> pfGroup* parent = walk->getParent(0);
>
> if (parent->isOfType(pfSCS::getClassType())) {
> pfSCS* scs = (pfSCS*) parent;
>
> scs->getMat(scsmat);
> xform.postMult(scsmat);
> }
>
> walk = parent;
> }
> }
> }
>
> This code computes the absolute transformation of its node in the
> scenegraph.
> fpMatrix is a wrapper for pfMatrix. fpPerformerNode is a wrapper for pfNode.
>
> BTW: Avango is LGPL and a project on Sourceforge.
>
> Greetings,
>

--
      ___|__    |
      /  |  \   ||\      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-7090
 \_o_\___|____|_|______\_    Inst: http://www.nrc.gc.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!


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Tue Nov 09 2004 - 13:02:39 PST