Kowsik Guruswamy (kowsik++at++buggy.coryphaeus.com)
Tue, 11 Jul 1995 10:08:20 -0700
Performer does intersection testing using line segments, which is pretty
straight forward to use. You set up a pfSegSet with all the line segments and
then call pfSegsIsectNode() to do the collision. Each line segment has an
origin a *DIRECTION VECTOR* [not a HPR triplet] and a length. If you don't want
the line segments to intersect with the vehicle, you need to set the
intersection traversal mask and node traversal masks [see pfNodeTravMask] so
that collision detection is done only on the desired objects.
Since, it's line segments that do the actual intersection, you might want to do
some field of view testing to check for the proximity of the object and then
call pfSegsIsectNode to get the actual collision point. Your line segments may
not work all the time, since there might be some object that can get in between
these three line segments that you have set up.
> What follows is the code I have to do this. Unfortunately,
> it doesn't seem to work. I'm sure I'm just overlooking something
> obvious, and if anyone has any suggestions, I would be appreciative.
> Thanks in advance.
[snip]
> // Copy the base coordinate to our segments. This will form three
> // vectors starting at the same place and pointing to the same direction.
> memcpy(&seg_set.segs[0].pos, &base_coord.xyz, sizeof(pfVec3));
> memcpy(&seg_set.segs[0].dir, &base_coord.hpr, sizeof(pfVec3));
>
> memcpy(&seg_set.segs[1].pos, &base_coord.xyz, sizeof(pfVec3));
> memcpy(&seg_set.segs[1].dir, &base_coord.hpr, sizeof(pfVec3));
>
> memcpy(&seg_set.segs[2].pos, &base_coord.xyz, sizeof(pfVec3));
> memcpy(&seg_set.segs[2].dir, &base_coord.hpr, sizeof(pfVec3));
Something that I can spot immediately, is that the 'dir' component of the
pfSegSet takes a direction vector and *****NOT***** a hpr triplet. You should
convert the hpr into a direction vector using something like pfMakePolarSeg:
pfMakePolarSeg (&seg, pos, heading, pitch, length);
// seg.dir contains the direction vector.
> // Now, lets point two of the vectors to either side.
> seg_set.segs[1].dir[0] = base_coord.hpr[0] - 40.0; // 40 degs ccw
> seg_set.segs[2].dir[0] = base_coord.hpr[0] + 40.0; // 40 degs cw
Same problem as above!
> // Setup length of our rays to intersect with.
> seg_set.segs[0].length = 100; // 100 meters
> seg_set.segs[1].length = 100; // 100 meters
> seg_set.segs[2].length = 100; // 100 meters
>
> // Set up segment to be tested against geometry
> seg_set.mode = PFTRAV_IS_PRIM | PFTRAV_IS_CULL_BACK;
> seg_set.userData = 0;
> seg_set.activeMask = 0x7; // bit vector specifying which segs to use
> seg_set.isectMask = PFUCOLLIDE_MASK;
> seg_set.bound = 0;
> seg_set.discFunc = 0;
[snip]
>-- End of excerpt from Tanner Lovelace
-- kowsik++at++coryphaeus.com
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:51:40 PDT