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

Date view Thread view Subject view Author view

From: Juergen Wind (juergen.wind++at++vertigo-systems.de)
Date: 11/08/2004 02:46:35


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,

 Juergen


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Mon Nov 08 2004 - 02:47:23 PST