# Generating a projector matrix

Hi,
I am a newbie in computer graphics and Opengl.
I am doing a work for my university and I need to calculate a projection matrix containing the model view projection and the texture viewport transformation.
I am stucked for some days, I already googled and in this article http://developer.nvidia.com/attach/6549
I found this formula that I think that may help me:

Te=|1/2 0 0 1/2| Pp Vp Ve^-1
|1/2 0 0 1/2|
|0 1/2 0 1/2|
|0 0 1/2 1/2|

where: Vp is the view matrix for the projector, Pp is the projection matrix and Ve^-1 is the inverse of camera (or eye).
(is it right?)

I couldn’t understand where the viewport fits here.

Also, I don’t know how to build these three matrices (Pp, Vp, Ve^-1), I have this data stored as variables:

vectors for eye,target,up;
floats for znear,zfar,fovy,aspect;

can anyone help me please? I am really stuck and I don’t know where to look for some answer or what else search in google.

Also, I found this website about the view matrix: http://www.toymaker.info/Games/html/camera.html
but I think it doesn’t apply for Opengl.

Thank you,
Oscar

For constructing Pp see gluPerspective. For constructing Vp see gluLookAt.
For Ve^(-1) I don’t know how to compute it yet.

Hope that help.

That REALLY helps a lot!
Thank you!

just one more question:
do you know where does the viewport fit here?

thank you

See glViewport.
See gluProject for the process of transforming the position of a vertex in the screen.

Edit: WinZ is the value ([0.0 1.0]) stored in the depth buffer.

Hi,
Thank you again.
My question is: do you know where it fits in this matrix we just created?
I can’t understand that.

Thank you,
Oscar

Check out the red book:
http://www.glprogramming.com/red/chapter03.html

CatDog

Ok, I will.

Thank you both for your help!

Oscar

Look the figure 3 at the bottom of page 3. Unlike the camera transform, I think there is no viewport transform for the projector transform. If you compare the final stage of both transform, the final stage of the camera transformation transform the normalized device coordinate (NDC space) [-1 1] for each x,y,z to [0 viewport_width] [0 viewport_height] and [0 1] for window space. The final stage of the projector transformation transform the projector clip space to the texture space [0 1] (this is the scale and bias matrix).

Hope that I have answered right this time.