Taper/Perspective transformation

How do I set up a transformation matrix which mimics a looking-straight-down-perspective projection?

I need control over the (x,y) point directly underneath the camera, the camera elevation, and the lens length, but the camera-target direction is always -UnitZ and the camera-up vector is always UnitY. I need points on the z=0 plane to remain unmolested, points with z>0 to move away from the projected camera point and points with z<0 to move towards it.

I know how to do this with a simple linear scale using the z-coordinate as a factor, but I also need to transform the normals of the shapes because I need to work out whether edges are hidden or silhouette.

Maybe this piece on projection matrix in OpenGL is useful? It’s full of maths, but the end result seems relatively simple.


Thanks menno, but in the end I went for faux perspective by tweaking the M02 and M12 cells in an identity transform to get per-object X and Y shearing. Since the geometry is only supposed to be displayed in a grid, the fact that transforms for adjacent object don’t quite match up doesn’t matter… (shearing factors are exaggerated in this image).