PDA

View Full Version : Projection Matrix (onto oblique near plane)


andrewjworz
07-13-2012, 06:01 AM
I would like to define a projection matrix matrix with an oblique near plane. I have a paper which explains how to do this, but it seems that the projection matrix in Vizard isn't defined in the same way as with OpenGl. Can someone explain why they aren't defined in the same way?

Here is a website which explains how to derive the (regular) projection matrix:
http://www.songho.ca/opengl/gl_projectionmatrix.html
The openGL matrix has the following form:

OpenglProjectionMatrix =
[ [ 2n/(r-l), 0 , (r+l)/(r-l) , 0 ] ,
[ 0 , 2n/(t-b), (t+b)/(t-b) , 0 ] ,
[ 0 , 0 , P33 , P34 ] ,
[ 0 , 0 , -1 , 0 ] ]

Using the 'viz.MainWindow.getProjectionMatrix()' command ( and after varying the near and far parameters), one can see that vizard returns a projection matrix of the form:

VizardProjectionMatrix =
[ [ 2n/(r-l), 0 , (r+l)/(r-l) , 0 ] ,
[ 0 , 2n/(t-b), (t+b)/(t-b) , 0 ] ,
[ 0 , 0 , P33 , -1 ] ,
[ 0 , 0 , P43 , 0 ] ]

If eye space is projected onto a non-oblique near plane, it is easy to resolve this issue by simply switching the two elements ( P34 with P43 ) which are out of place . But in order to define a projection matrix with an oblique near plan, I need to define two more elements in the openGL-style matrix ( P31 and P32). My quick fix can't work anymore, so I'm wondering (1) is there anyway I can set the projection matrix as defined by openGL? (2) Is there any special reason the projection matrix is defined differently in Vizard?

Here is the form of the matrix which I need to define:

ObliqueProjectionMatrix =
[ [ 2n/(r-l), 0 , (r+l)/(r-l) , 0 ] ,
[ 0 , 2n/(t-b), (t+b)/(t-b) , 0 ] ,
[ P31 , P32 , P33 , P34 ] ,
[ 0 , 0 , -1 , 0 ] ]

Any help would be appreciated.thanks!
-Andy

farshizzo
07-13-2012, 09:10 AM
Have you tried using the viz.MainWindow.setProjectionMatrix() command?

ObliqueProjectionMatrix = [
2n/(r-l), 0 , (r+l)/(r-l) , 0,
0 , 2n/(t-b), (t+b)/(t-b) , 0,
P31 , P32 , P33 , P34,
0 , 0 , -1 , 0
]

viz.MainWindow.setProjectionMatrix(ObliqueProjecti onMatrix)

Just make sure the projection matrix is a 16 item 1-dimensional array.