Liu Xiaoyan (liuxy++at++ihpc.nus.edu.sg)
Sat, 02 May 1998 18:03:05 +0800
I want to do bounding box to bounding box collision detection.
My approach is by using a dummy vector to activate the ISECT
process, which in turn will activate the pre-isect callback
attached to each node. In this callback, "pfBox.contains ..."
is called to detect the collison between boxes.
What I found strange is that sometimes the pre-isect functions
is called , sometimes not, though the "printf" before the
isect do print sth out.
*****************************************************
The code looks like:
group->setTravFuncs(PFTRAV_ISECT, box2boxHit, NULL);
group->setTravData(PFTRAV_ISECT, (void *)shared_ptr);
int box2boxHit(pfTraverser *trav, void *data)
{
pfNode *node = trav->getNode();
....
if (box1.contains(&box2) != PFIS_FALSE)
printf("\n *************************MAY HIT");
return PFTRAV_CONT;
}
// collision detection between objects, use a dummy line
// to initiate ISEC traversal, actual detection done in
// each node's isecCallback.
pfSegSet segset;
pfHit **hits[32];
segset.mode = PFTRAV_IS_GSET;
segset.userData = (void *)NULL;
segset.activeMask = 1;
segset.isectMask = 0xffffffff;
segset.bound = (void *)NULL;
segset.discFunc = NULL;
segset.segs[0].dir.set(0.0f, 0.0f, -1.0f); // dummy vector
segset.segs[0].length = 1.0f;
(shared_ptr->scene)->isect(&segset, hits); // activate it
What's going wrong?
Thanks for any advice.
Liu
***********************************************************************
Liu Xiaoyan Institute of High Performance Computing
Data Visualisation Group http://www.ihpc.nus.edu.sg Tel:(65)7709267
***********************************************************************
=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
Submissions: info-performer++at++sgi.com
Admin. requests: info-performer-request++at++sgi.com
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:57:21 PDT