#include #include /* remember to do node->setTravMask(PFTRAV_ISECT, 0xffffffff, PFTRAV_SELF|PFTRAV_DESCEND|PFTRAV_IS_CACHE, PF_OR); to enable intersection caching */ int isectTest(pfNode *node,pfVec3 pos,pfVec3 dir,pfVec3 *retPoint,pfVec3 *retNorm) { pfSegSet segset; pfHit **hits[32]; segset.activeMask = 1; segset.isectMask = 0xffffffff; segset.discFunc = NULL; segset.bound = NULL; /* replace PFTRAV_IS_PRIM by PFTRAV_IS_GSET to only test GeoSet bounding boxes; or, use PFTRAV_IS_GEODE to only test Geode bounding spheres */ segset.mode = PFTRAV_IS_PRIM | PFTRAV_IS_NORM | PFTRAV_IS_CULL_BACK; segset.segs[0].pos = pos; segset.segs[0].dir = dir; segset.segs[0].length = 1000.0f; if (node->isect(&segset, hits)) { pfVec3 pnt, norm; pfMatrix xmat; (*hits[0])->query(PFQHIT_POINT, pnt.vec); (*hits[0])->query(PFQHIT_XFORM, (float*)xmat.mat); pnt.xformPt(pnt, xmat); *retPoint = pnt; (*hits[0])->query(PFQHIT_NORM, norm.vec); norm.xformVec(norm, xmat); *retNorm = norm; return 1; } return 0; } int isectTest2(pfNode *node,pfVec3 rayPoint0,pfVec3 rayPoint1,pfVec3 *retPoint) { pfSegSet segset; pfHit **hits[32]; segset.activeMask = 1; segset.isectMask = 0xffffffff; segset.discFunc = NULL; segset.bound = NULL; segset.mode = PFTRAV_IS_PRIM; segset.segs[0].makePts(rayPoint0,rayPoint1); if (node->isect(&segset, hits)) { pfVec3 pnt; pfMatrix xmat; (*hits[0])->query(PFQHIT_POINT, pnt.vec); (*hits[0])->query(PFQHIT_XFORM, (float*)xmat.mat); pnt.xformPt(pnt, xmat); *retPoint = pnt; return 1; } return 0; }