ns.dept3.buaa.edu.cn (baofyu++at++ns.dept3.buaa.edu.cn)
Mon, 20 Apr 1998 14:11:22 +0800
pfSegSet segset;
const pfSeg **segptr;
pfHit **hits[32];
// Create group node to hold SCS's; attach it to scene
pfGroup * ground =(pfGroup *) pfdLoadFile("yu02.flt");
pfGroup * root = new pfGroup();
root->addChild(ground);
// Set up ground and his children for intersections
scene->addChild(root);
ground->setTravMask(PFTRAV_ISECT,0x06,
PFTRAV_SELF|PFTRAV_DESCEND|PFTRAV_LOD_CUR,PF_OR);
scene->setTravMask(PFTRAV_ISECT, 0x06,
PFTRAV_SELF|PFTRAV_DESCEND|PFTRAV_LOD_CUR,PF_OR);
// Set up intersection segment, pointing down for "terrain" following
segset.activeMask = 13;
segset.isectMask = 0xFFFF;
segset.discFunc = NULL;
n = 13;
segptr = (pfSeg **)pfMalloc(sizeof(pfSeg *)*n,NULL);
for (int i = 0; i < n; i++)
{
segset.segs[i].dir.set(0.0f, 0.0f, -1.0f);
segset.segs[i].length = 100000.0f;
segptr[i] = &segset.segs[i];
}
// set location of intersection segment of crater
x = 100.0f;
y = 100.0f;
z = 10000.0f;
segset.segs[0].pos.set(x, y, z);
r = 16.0f;
for (i = 1; i < n; i++)
{
pfSinCos(360.0f / n * i, &s, &c);
segset.segs[i+1].pos.set(x + c * r, y + s * r, z);
}
cylinder = new pfCylinder();
cylinder->around(segptr, n);
segset.bound = &cylinder;
segset.mode =
PFTRAV_IS_PRIM|PFTRAV_IS_NORM|PFTRAV_IS_CULL_BACK|PFTRAV_IS_BCYL|PFTRAV_LOD_
CUR;
// do an intersection test against the scene graph
isect = scene->isect(&segset, hits);
while (!shared->exitFlag)
{
pfFrame();
// if successful, set crater height to that of the point of contact.
if (isect)
{
.........
}
}
This program works well when terrain node ("ground") is not pfLOD.
pfSegset can inersect with ground and I can query inersetion point and
normal. when I use another terrain flt file which is pfLOD, the pfSegset can
not intersect with terrain. Why? I want know how I should do when I want to
interset with pfLOD terrain using pfSegset. Who can answer me? I need help.
baofeng Yu
Advanced Simulation Technology Lab,
Automatic Control Dept.,
Beijing University of Aeronautics and Astronautics
China
email address: baofyu++at++ns.dept3.buaa.edu.cn
This archive was generated by hypermail 2.0b2 on Mon Apr 19 1999 - 23:11:07 PDT