bob wrote:
> I was just wondering how you should handle negative z coordinates when
> converting a 3d point to 2d. Although they are outside the viewing
> frustum, I think you still must convert them to 2d when you are
> rasterizing a triangle that intersects the viewing frustum but happens
> to have a coordinate with a negative z.
You do have to handle them, but the projection isn't what you want
because you'll quickly end up with the polygons around the camera
covering up the screen because when Z gets close to zero, the divide
(1/z) gets huge, and you end up with gargantuan polygons.
What you need to is figure out where polygons intersect your near clip
plane (as opposed to simply going negative) and then "scissor" them. My
Googling skills seem inadequate for this, but basically what you need to
do is chop the triangle at the near plane, which will often yield a
trapezoid that you may have to turn into two triangles. Anything that
interpolates across your triangle (color, texture coordinates, etc.)
needs to be recomputed for those new vertices, obviously. ...and then
anything that's left behind the clip plane (including vertices that have
a negative Z) are discarded.
-tom!
--


|