PDA

View Full Version : Generating a projector matrix



oscarfh
12-14-2008, 11:35 AM
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

trinitrotoluene
12-14-2008, 01:21 PM
For constructing Pp see gluPerspective (http://www.opengl.org/sdk/docs/man/xhtml/gluPerspective.xml). For constructing Vp see gluLookAt (http://www.opengl.org/sdk/docs/man/xhtml/gluLookAt.xml).
For Ve^(-1) I don't know how to compute it yet.

Hope that help.

oscarfh
12-14-2008, 01:43 PM
That REALLY helps a lot!
Thank you!

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

thank you

trinitrotoluene
12-14-2008, 02:48 PM
See glViewport (http://www.opengl.org/sdk/docs/man/xhtml/glViewport.xml).
See gluProject (http://www.opengl.org/sdk/docs/man/xhtml/gluProject.xml) 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.

oscarfh
12-14-2008, 04:47 PM
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

CatDog
12-14-2008, 05:43 PM
Check out the red book:
http://www.glprogramming.com/red/chapter03.html

CatDog

oscarfh
12-14-2008, 05:53 PM
Ok, I will.

Thank you both for your help!

Oscar

trinitrotoluene
12-14-2008, 05:55 PM
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.