David Luebke (luebke++at++cs.unc.edu)
Wed, 29 Mar 1995 16:57:27 -0500 (EST)
What I want to do is this: During a cull callback, I want to transform
the vertices of a polygon and see if that polygon landed on the screen,
and if so where on the screen the polygon vertices ended up. If the polygon
is backfacing (i.e. the verts are clockwise in screenspace) I want to
know that, too. Based on this information my cull callback will either
return PFTRAV_CONT or PFTRAV_PRUNE.
Here's my problem: I can't seem to get the transformation matrix straight
that I need to pfXformPt3() the polygon vertices by. Because this must be
done in the cull process, I don't have access to the viewing and projection
matrix stacks. Using pfGetTravMat I can get the current model matrix,
using pfGetChanViewMat I can get the current viewing matrix. I could
probably derive the projection matrix from the pfFrustum associated with
the current channel, but right now I make the simplifying assumption that the
frustum doesn't change from frame to frame. So I can get the projection
matrix by associating a draw callback with the root of the pfScene:
enterRootDraw(pfTraverser *trav, void *data)
{
mmode(MPROJECTION); /* Get the current projection matrix */
getmatrix(globalProjMatrix);
mmode(MVIEWING);
return PFTRAV_CONT;
}
So there you have it. After the very first frame I supposedly have the
correct model, viewing, and projection matrices during my cull callback.
As I understand things, I should be able to multiply each of the vertices in
the polygon by the composite matrix to transform the vertices into screenspace,
with X and Y coordinates that lie between -1.0 and 1.0 (the viewport xform is
later supposed to take these vertices to their actual pixel values). The only
problem is, it doesn't work. The X and Y coordinates of my transformed verts
don't lie in the [-1,1] range and they don't really make a whole lot of sense.
Before I waste much more time hunting bugs in my code (and I'm sure there are
a number) I wanted to consult with the Performer experts and make sure I'm
not missing any glaring logical errors. Thanks,
Dave
-- David Luebke luebke++at++cs.unc.edu
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:51:08 PDT