OpenGL Projection matrix question

This topic is 2875 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hello,

I am using OpenSceneGraph, which internally uses OpenGL. I transform a vector from view space to projection space with this code:
 Vec4 vecVS(0, 0, -10, 1); Vec4 vecProj = vecVS * projMat; 
The view space vector has coordinates of (0, 0, -10, 1), so I expected the point to have x,y coordinates of 0,0, since the point is exactly in the middle
of the near plane. But when I print vecProj, I surprisingly get these values:

(0.000, -4.512, 8.018, 10.000)
[/quote]
x seems to be correct, but how can y be -4.512? Shouldn't y be 0 too? Has anyone an idea what could be wrong?

Share on other sites
How did you make your projection matrix? And what is its value?

Share on other sites
The matrix is automatically computed by OpenSceneGraph and looks like this:
 (1.732, 0.000, 0.000 0.000) (0.000, 3.112, 0.000 0.000) (0.000, 0.451, -1.002 -1.000) (0.000, 0.000, -2.002 0.000) 

Share on other sites
Vec4 vecVS(0, 0, -10, 1); Vec4 vecProj = projMat * vecVS ; //Or someting like : vecProj = vecVS * transpose(projMat) 
?

Share on other sites
Given the vector and the projection matrix, the result you get is correct. The question is; why is there a 0.451 in the second element on the third row? That element is what is commonly used as the translation part of the matrix, so it means that you have a non-symmetric projection matrix (it is in the Y-direction, so your projection matrix has, for example, non-symmetric bottom and top values). If that is not what you want, then you have to go back to the source of that matrix and see why it is non-symmetric.

• Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 9
• 11
• 15
• 21
• 26