czg++at++iname.com
Thu, 28 Aug 1997 11:15:58 -0700
Thanks for reply of my earlly question about how to distinguish
nodes.
Now I encounter another difficulty. I use intersect traversal to
get the hight above the terrain. The terrain group and the cloud
group are masked with different intersect masks using pfNodeTravMask.
The terrain is 0x01 and cloud is 0x08. Then I set segset.isectMask
to 0x01. When the view point is above terrain and under cloud, it
works right. But when above cloud, the hight is against the CLOUD.
What's wrong?
Thanks inadvance
Cao Zhigang
My code is as follows:
in generic.c :
pfSegSet segset;
void
InitIsect(void)
{
segset.activeMask = 1;
segset.isectMask = 0x0001;
segset.discFunc = NULL;
segset.bound = NULL;
segset.mode = PFTRAV_IS_PRIM|PFTRAV_IS_NORM|PFTRAV_IS_CULL_BACK;
pfSetVec3(segset.segs[0].dir, 0.0f, 0.0f, -1.0f);
segset.segs[0].length = 50000.0f;
}
/* using ViewState->viewCoord as shared->yval & shared->zval */
void
IsectFunc(void *data)
{
int isect;
pfVec3 pnt, xpnt;
pfMatrix xmat;
pfHit **hits[32];
/* update location of intersection segment */
pfSetVec3(segset.segs[0].pos,
ViewState->viewCoord.xyz[PF_X],
ViewState->viewCoord.xyz[PF_Y],
ViewState->viewCoord.xyz[PF_Z]);
/* do an intersection test against the scene graph */
isect = pfNodeIsectSegs(ViewState->scene, &segset, hits);
/* if successful, print out the hight of view point against the
terrain */
if (isect)
{
pfQueryHit(*hits[0], PFQHIT_POINT, &pnt);
/* transform object point into scene coordinates */
pfQueryHit(*hits[0], PFQHIT_XFORM, xmat);
pfXformPt3(xpnt, pnt, xmat);
}
printf("\n%8.3f", ViewState->viewCoord.xyz[PF_Z]-pnt[PF_Z]);
}
in perfly.c :
int
initSceneGraph(pfScene *scene)
{
pfNode *root;
int i;
int j;
int loaded = 0;
pfSphere bsphere;
int intersectmask[2];
.
.
.
/* setup Database files and intersect mask */
DatabaseFiles[0]=terrainfile;
DatabaseFiles[1]=cloudfile;
NumFiles=2;
intersectmask[0]=0x01;
intersectmask[1]=0x08;
/* Load each of the files named on the command line */
for (i = 0; i < NumFiles; i++)
{
for (j = 0; j < ViewState->iterate; j++)
{
/* Load the database. create a hierarchy under node "root" */
root = pfdLoadFile(DatabaseFiles[i]);
.
.
.
pfAddChild(ViewState->sceneGroup, root);
++loaded;
/* set intersect mask */
pfNodeTravMask(root, PFTRAV_ISECT, intersectmask[i],
PFTRAV_SELF | PFTRAV_DESCEND, PF_SET);
}
}
=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
Submissions: info-performer++at++sgi.com
Admin. requests: info-performer-request++at++sgi.com
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:55:47 PDT