[info-performer] Intersection path in pfHit

Date view Thread view Subject view Author view

From: Frederic Rouas (frederic.rouas++at++oktal.fr)
Date: 05/16/2003 09:02:29


Hi,

I'm using Perfomer 3.0.1 on WinXP.

You will find hereafter a code sample illustrating the problem i have
computing intersections on
a scene and getting the path to the hit node : though the isect action
actually hit a geometry node,
the returned path to the hit node has always a null length !!!

In my actual application, I need to use clone instancing. If I can't get
the path to the hit node,
how can I retrieve the hit object ?

Code :

 #include <stdlib.h>
 #include <stdio.h>

 #include <Performer/pf/pfChannel.h>
 #include <Performer/pf/pfLightSource.h>
 #include <Performer/pf/pfNode.h>
 #include <Performer/pf/pfScene.h>
 #include <Performer/pf/pfDCS.h>
 #include <Performer/pf/pfTraverser.h>

 #include <Performer/pf.h>
 #include <Performer/pr.h>
 #include <Performer/pfutil.h>
 #include <Performer/pfdu.h>

 int
 main (int argc, char *argv[])
 {
  pfInit();
  pfuInit();
     pfdInitConverter("esprit.pfb");

  pfMultiprocess( PFMP_DEFAULT );
  pfConfig();
  pfFilePath(".:/usr/share/Performer/data");

  pfScene *scene = new pfScene;
  scene->addChild(new pfLightSource);

  pfPipe *p = pfGetPipe(0);
  pfPipeWindow *pw = new pfPipeWindow(p);
  pw->setWinType(PFPWIN_TYPE_X);
  pw->setName("OpenGL Performer");
  pw->setOriginSize(0,0,500,500);
  pw->open();

  pfChannel *chan = new pfChannel(p);
  chan->setScene(scene);
  chan->setFOV(45.0f, 0.0f);
  chan->setNearFar(0.1f, 1000.0f);

  pfuInitInput( pw, PFUINPUT_X );

  pfNode *root;
  pfDCS* dcs;

  root = pfdLoadFile("esprit.pfb");
  dcs = new pfDCS;
  dcs->addChild(root);
  dcs->setTrans( 0.0f , 10.0f, -0.5f );
  scene->addChild(dcs);

  scene->setTravMask( PFTRAV_ISECT, 0xFFFFFFFF, PFTRAV_SELF | PFTRAV_DESCEND
| PFTRAV_IS_CACHE, PF_SET);

  pfSegSet segSet;
  segSet.activeMask = 1;
  segSet.isectMask = 0xFFFFFFFF;
  segSet.mode = PFTRAV_IS_PRIM | PFTRAV_IS_NORM | PFTRAV_IS_CULL_BACK;
  segSet.bound = NULL;
  segSet.userData = NULL;
  segSet.discFunc = NULL;
  segSet.segs[ 0 ].length = 50000.0;
  segSet.segs[0].pos.set(0.0, 0.0, 0.0);
  segSet.segs[0].dir.set(0.0, 1.0, 0.0);

  while (TRUE)
  {
   pfSync();
   pfFrame();

   pfHit** hits[1024];
   int isect = 0;
   isect = scene->isect(&segSet, hits);
   if (isect)
   {
    pfNode * node = NULL;
    hits[0][0]->query(PFQHIT_NODE, &node);

    pfPath *path = NULL;
    hits[0][0]->query(PFQHIT_PATH, &path);

    if (node)
    {
     printf("intersected node %x (path length %i)\n",node, path->getNum());
    }
   }
  }

  pfExit();
  return 0;
 }

Frédéric Rouas
Mail : frederic.rouas++at++oktal.fr


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Fri May 16 2003 - 09:00:31 PDT