# Intersection Testing

pfNode and all of its subclasses provide an *isect()* method
for performing intersection testing. The test can return information
on the point of intersection, the triangle intersected, the GeoSet
intersected, and the normal at the point of intersection.
*isect()* uses a pfSegSet to define the rays to test,
and a pfHit array to return the intersections.

pfNode *node;
pfSegSet segset;
pfHit **hits[32];
...
node->isect(&segset, hits);

## pfSegSet

A pfSegSet structure contains an array of up to 32 rays (pfSeg's),
and flags for controlling the intersection traversal.
- segset.activeMask = bit mask indicating which pfSeg's to use;
to just test segs[0], activeMask = 1
- segset.mode = bitwise OR of traversal flags:
- PFTRAV_IS_PRIM - intersect with primitives (triangles)
- PFTRAV_IS_NORM - return normal at point of intersection
- PFTRAV_IS_CULL_BACK - don't test backfacing polygons

- segset.segs[] = list of rays to test. To create a pfSeg defining
a ray from
*(pfVec3 a)* to *(pfVec3 b)*, use
*segset.segs[i].makePts(a,b)*

## pfHit

The results of any intersections are returned in a pfHit array.
*hits[i]* reports the intersection of *segset.segs[i]*
with the database.
*(*hits[i])->query(which,dst)* is used to get specific information.
Some possible options for *which* are:

- PFHIT_POINT - point of intersection; (
*float dst[3]*)
- PFHIT_NORM - polygon normal; (
*float dst[3]*)
- PFHIT_XFORM - scene transformation at intersected node; (
*float dst[16]*)

The values returned for the point and normal are in local coordinates;
they must be multiplied by the node's transformation to get scene
coordinates.

Sample programs:

Previous page
Table of contents
Next page

Last modified 5 February 1996.

Dave Pape, pape@evl.uic.edu