Re: Isect

New Message Reply Date view Thread view Subject view Author view

Mario Veraart (rioj7++at++fel.tno.nl)
Wed, 22 Apr 1998 12:45:21 +0200 (MET DST)


> Hi All,
>
> We're running a Line-of-Sight program which uses performer libraries and
> isect to calculate the height of terrain given a certain lat/lon that
> has been converted to x,y positions. There are some points on the
> database which are not returning valid isect hits. I've run some tests
> and have determined that there are some points within a certain polygon
> which return a valid isect and within the same polygon there are other
> points which don't have valid isect returns.
>
> I don't know what else to try to figure this one out. I didn't write
> the code. Of course the person who did has since left.
>
> Example of code:
>
> float TerrainServer::elevation(int x, int y)
> {
> pfCoord view;
> pfHit **hits[32];
> int isect;
>
> //update location of intersection segment
> segset.segs[0].pos.set(x,y,2500.0f);
If you read the man page of pfNode on the section of intersction you
see that it's better to fill in some more fields of the segset
structure. They don't have a default value.
You must also fill in the direction of the segment and the length of
the segment.

    segset.mode = PFTRAV_IS_PRIM | PFTRAV_IS_CULL_BACK;
    segset.isectMask = ~0; // intersect with everything
    segset.activeMask = 0x01; // one segment specified
    segset.segs[0].pos.set(x,y,2500.0f);
    segset.segs[0].dir.set(0,0,-1.0f);
    segset.segs[0].length = 10000.0f;

> view.xyz.set(x,y,2500.0f);
> view.hpr.set(0.0f, -90.0f, 0.0f);
> chan->setView(view.xyz,view.hpr);
There is no need for these three lines.

Mario
>
> // do an intersection test against the scene graph
> isect = root->isect(&segset,hits);
> // if successful, set our height to that of the point of contact
> // plus a small offset
> if (isect)
> {
> pfVec3 pnt, xpnt;
> pfMatrix xmat, xmat2;
> (*hits[0])->query(PFQHIT_POINT, &pnt);
>
> // transform object point into scene coordinates
> (*hits[0]->query(PFQHIT_XFORM, &xmat);
> xpnt.xformPt(pnt, xmat);
>
> return (xpnt[PF_Z] - altOffset_);
> }
> }
>
> Thanks in advance for any assistance.
>
> Suzie
=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
            Submissions: info-performer++at++sgi.com
        Admin. requests: info-performer-request++at++sgi.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:57:17 PDT

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