[info-performer] DCS to World Coordinates

Date view Thread view Subject view Author view

From: Larry E. Ramey (ramey++at++simcreator.com)
Date: 06/15/2005 06:18:18


You are in luck. I happen to be coding exactly that....

Couple Quirks in this code....

1) The pfList "matrixStack" is in reverse order. Meaning the child
nearest my viewpoint is in slot 0 and the child nearest the root is in
slot n.
2) pfDCS == pfSCS, so even if its a DCS I can pull it out as a SCS
3) Installing "updateView" as a preApp Traversal will update my list of
veiwpoints (pfCoords) such that my main program can then pick one of
those coords and apply it to the pfChannel.
4) I haven't compiled or tested this yet, so there are likely some
typo's, but you get the idea.

 struct viewpoint_data
  {
   
    int numViewPoints;
    int sizeViewPoints;
    void* viewPoints; //pfCoord*
  };

int updateView(pfTraverser* trav, void* data)
{

  pfNode* node = pfGetTravNode( trav );
  pfList* viewList = (pfList*) data;

  int slotNum;
  slotNum = pfGetNamedUserDataSlot( VIEWPOINT_SLOTNAME );
  struct viewpoint_data* dataStruct = (struct viewpoint_data*)
pfGetUserDataSlot( node, slotNum );
  pfCoord* views = (pfCoord*) dataStruct->viewPoints;

  pfMatrix totalStack;
  pfMakeIdentMat( totalStack);

  for( int i=0; i< pfListArrayLen( viewList ); ++i){

    pfList* matrixStack = (pfList*) pfGet( viewList, i );

   
    for( int j=pfListArrayLen( matrixStack )-1;
         j>=0; --j){

      pfSCS* scs = (pfSCS*) pfGet( matrixStack, j );

      const pfMatrix* mat = pfGetSCSMat( scs );

      pfPostMultMat( totalStack, *mat );
    }

    pfMatrix viewMat;
    pfMakeCoordMat( viewMat, views+i );
    pfPostMultMat( totalStack, viewMat );
    pfGetOrthoMatCoord( totalStack, views+i );
   

  }

}


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Wed Jun 15 2005 - 06:25:39 PDT