Re: mapw with performer

New Message Reply Date view Thread view Subject view Author view

Jim Helman (jimh++at++surreal)
Mon, 03 Jul 95 11:17:08 -0700


If you want the world coordinates (or more precisely, the world
rays corresponding to the four corners of the viewport, you
should compute them in the APP process. The pipe really isn't
required for this.

Here's a code fragment from pfChannel::pick() to help out.
px and py are the [0,1] parameters passed as args to the
function.

rgds,

-jim helman

jimh++at++surreal.asd.sgi.com
415/390-1151

    /* get FOV angles, eyepoint, and near and far planes */
    frust = (pfFrustum *) chan->getViewFrust();
    frust->getFOV(&fovh, &fovv);
    frust->getNearFar(&near, &far);
     
    /* convert px and py to range of [-1,1] */
    xc = px * 2.0f - 1.0f;
    yc = py * 2.0f - 1.0f;
     
    seg.dir[1] = near;
    seg.dir[0] = xc * seg.dir[1] * tanf(PF_DEG2RAD(fovh * 0.5f));
    /* z is up so mouse-y -> z */
    seg.dir[2] = yc * seg.dir[1] * tanf(PF_DEG2RAD(fovv * 0.5f));
     
    chan->getView(eye.xyz, eye.hpr);
    pfMakeEulerMat(mat, eye.hpr[0], eye.hpr[1], eye.hpr[2]);
    chan->getViewOffsets(off.xyz, off.hpr);
    pfMakeEulerMat(offMat, off.hpr[0], off.hpr[1], off.hpr[2]);
    pfXformVec3(seg.dir, seg.dir, offMat);
    pfXformVec3(seg.dir, seg.dir, mat);
    pfNormalizeVec3(seg.dir);
     
    frust->getEye(seg.pos);
    seg.length = far * 2.0f;
     
    pfSegSet segSet;
    segptr = &seg;
     
    /* clip seg intersection with near plane of the viewing frustum */
    chan->getNear(nll, nlr, nul, nur);
    chan->getFar(fll, flr, ful, fur);
    pfMakePtsPlane(&npnl, nll, nlr, nul);
    pfMakePtsPlane(&fpnl, fll, flr, ful);
    pfPlaneIsectSeg(&npnl, segptr, &dn);
    pfPlaneIsectSeg(&fpnl, segptr, &df);
    pfClipSeg(segptr, segptr, dn, df);
     


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

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