Re: Intersections with Performer

New Message Reply Date view Thread view Subject view Author view

Kowsik Guruswamy (kowsik++at++buggy.coryphaeus.com)
Tue, 11 Jul 1995 10:08:20 -0700


On Jul 11, 10:57am, Tanner Lovelace wrote:
> Subject: Intersections with Performer
> Greetings,
>
> I'm trying to use performer's intersection routines to test for
> obstacles in front of a vehicle. Unfortunately, I don't think
> I entirely understand performer's approach to intersections.
> Basically, given some base coordinate, I want to test for
> intersections straight ahead, and to either side at a 40 degree
> angle. I want to limit the test to about 100 meters in front of
> the vehicle (it's not necessary to go out any further).

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

New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:51:40 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.