Jump to content
  • Advertisement
Sign in to follow this  
schupf

OpenGL Projection matrix question

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


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

?

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!