intersections with bars

New Message Reply Date view Thread view Subject view Author view

Henrik Ladholm (hela++at++ppvku.ericsson.se)
Wed, 30 Aug 1995 15:11:00 +0200


Hi,
I'm trying to do intersection tests with a bounding cylinder. On page 150 in Performer 1.2
programming guide " If only a rough volume-volume intersection is required, you can specify
a bounding cylinder in the pfSegSet without any line segments at all and request discriminator
callbacks at the PFTRAV_IS_NODE and PFTRAV_IS_GSET level. "
I want to do this in order to detect collisions with vertical or horizontal "bars" in the
landscape. I miss these with segment intersection. Has someone a fragment of code that
accomplishes this (without too much performance degradation) ?
Downbelow is a peace of code that does not! work.

//--------------------this doesn't work------------------------------------------
    pfMatrix eyeMatrix = is set up as the eyeposition;
    // make segment that points in +Y direction from eyepoint and is 4 m long
    // It is only used to make the appropriate cylinder with radius 0.4 m
    pfSeg seg;
    pfCoord eyeCoord,newAheadCoord;
    pfGetOrthoMatCoord(eyeMatrix,&eyeCoord);
    pfMatrix newAheadMatrix;
    pfCopyMat(newAheadMatrix,eyeMatrix);
    pfPreTransMat(newAheadMatrix,0,4.0,0,newAheadMatrix);
    pfGetOrthoMatCoord(newAheadMatrix,&newAheadCoord);
    pfMakePtsSeg(&seg,eyeCoord.xyz,newAheadCoord.xyz);
    // make a cylinder around the segment
    pfCylinder cylinder;
    pfSeg* segArray[]={&seg};
    pfCylAroundSegs(&cylinder,segArray,1);
    cylinder.radius = 0.4;//override radius
    // create pfSegSet
    pfHit** hits[32];
    pfSegSet segSet;
    segSet.mode = PFTRAV_IS_GSET|PFTRAV_IS_CULL_BACK|PFTRAV_IS_BCYL;
    segSet.isectMask = PFUCOLLIDE_OBJECT|PFUCOLLIDE_EVENTWALL;
    segSet.activeMask = 0;// mask for the segments, in this case 0 segments
    segSet.segs[0] = seg;
    segSet.bound = &cylinder;
    segSet.discFunc = NULL;
    segSet.userData = NULL;
    // do intersection with appropriate node
    pfNode* sceneNode = is set to the scene;
    long retValue = pfSegsIsectNode(sceneNode, &segSet, hits);
\\-----------------------------------------------------------------------------

Comments and suggestions will be appreciated :-]

Regards
Henrik Ladholm
Ericsson Infocom
Sweden


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:51 PDT

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