Thomas Hudson (hudson++at++cs.unc.edu)
Thu, 6 Jun 1996 12:14:58 -0400 (EDT)
Never found an API feature for it. I'll append source code to show what I do.
(This code is used for dynamically tesselating various curved objects based on
their screen size, but most of the interesting objects (trimmed Bezier surfaces)
are far from stable enough to release). I've run a little post-draw loop that
verifies that the coordinates I project are identical to those that OpenGL
draws. Originally derived from code by David Luebke of pfPortals, another
UNC student.
Tom
UNC-Chapel Hill Walkthrough and Modeling Groups
// hudson++at++cs.unc.edu
// global matrix to hold the projection matrix, which we calculate once
// per frame
pfMatrix * gVPMat;
static pfFrustum * baseFrust;
static pfMatrix * rotMat; // convert from Performer to GL coord systems
In the initialization routines...
baseFrust = new (arena) pfFrustum;
rotMat = new (arena) pfMatrix;
rotMat->makeRot(-90.0f, 1.0f, 0.0f, 0.0f);
A callback called every frame... If called as an APP traversal,
it lags one frame behind the actual viewpoint, but we do this because
of problems with multiprocessing.
// cbUpdateDynamicTesselationState
//
// Sets up global variable gVPMat, which is the product of the
// inverse viewing matrix and the projection matrix. Does other
// frame-by-frame maintenance. Should be attached to a node in
// the graph that is the parent of all dynamic tesselation objects
// (or promoted from a callback to a regular function in the
// application loop)
int cbUpdateDynamicTesselationState (pfTraverser * trav, void *) {
pfChannel * chan = trav->getChan();
pfMatrix frustMat, projMat;
chan->getBaseFrust(baseFrust);
baseFrust->getGLProjMat(frustMat);
projMat.mult(*rotMat, frustMat);
pfMatrix invMat, viewMat;
chan->getViewMat(invMat);
viewMat.invertOrtho(invMat);
gVPMat->mult(viewMat, projMat);
return PFTRAV_CONT;
}
Now we have our bounding box in item->corners[]; the following may produce
crazy numbers if your bounding box is being clipped by the hither plane,
but we clamp the output anyway so having large numbers doesn't bother us.
A safer approach would be to use two different matrices (a slower proecss),
as the comment notes.
pfVec3 pbverts [8]; // vertices of bounding prism
for (i = 0; i < 8; i++) {
pbverts[i].fullXformPt(item->corners[i], *gVPMat);
// probably ought to use viewMat, do a hither clip, and then
// use projMat
}
=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer.html
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:52:59 PDT