Window dimension in world coordinate
Hi!
I've a window of length 1280 and height 800. I've setup the projection matrix and the modelview matrix, is possible to know the dimension of the window in world coordinate?
I would know the coordinate of the up-left corner etc.
Thanks!
Quote:Original post by Molle85
top-left -1, 1, 0
top-right 1, 1, 0
bottom-left -1, -1, 0
bottom-right 1, -1, 0
I'm confused, if I place a point in (-1, 1, 0), I can't see this point, is out of the camera frustum. In order to have this dimension, how I must set the projection and the modelview matrix?
That is in view projection space, so if you set the world matrix to inverse of the view projection you will have it in that space
It might be a good exercise - if you want to know more about OpenGL, anyway - to read up on matrix math. Using graphics is one thing, but understanding how it works fundamentally is another entirely.
If you check on opengl.org, you can probably find something helpful.
If you check on opengl.org, you can probably find something helpful.
Quote:Original post by datalurkur
It might be a good exercise - if you want to know more about OpenGL, anyway - to read up on matrix math. Using graphics is one thing, but understanding how it works fundamentally is another entirely.
If you check on opengl.org, you can probably find something helpful.
he never mentioned that he was using opengl, and wiki has probably more information about matrix math
Quote:Original post by Molle85Quote:Original post by datalurkur
It might be a good exercise - if you want to know more about OpenGL, anyway - to read up on matrix math. Using graphics is one thing, but understanding how it works fundamentally is another entirely.
If you check on opengl.org, you can probably find something helpful.
he never mentioned that he was using opengl, and wiki has probably more information about matrix math
Well, this IS the OpenGL forum, you know...
I found this quite useful, mentioned in another old thread. I'm having trouble finding good info on how gluUnProject works though. Because it seems to exaggerate the movements I make with the mouse with the projected coordinates even though I've set up all matrices to work with 1280x720.
Vector3 Unproject( int x, int y ){ Vector3 coords; //Something to store our return value in GLfloat wx, wy, wz; //Window coordinates GLdouble cx, cy, cz; //Object coordinates GLdouble mv[16]; //Modelview matrix GLdouble proj[16]; //Projection matrix GLint vp[4]; //Viewport glGetDoublev( GL_MODELVIEW_MATRIX, mv ); glGetDoublev( GL_PROJECTION_MATRIX, proj ); glGetIntegerv( GL_VIEWPORT, vp ); //re-enable various settings we may have turned off glEnable(GL_DEPTH_TEST); //Re-enable depth testing and masking glDepthMask(GL_TRUE); glDepthRange(0.0f,1.0f); wx = ( float ) x; wy = ( float ) vp[3] - ( float ) y; //To invert the y glReadPixels( x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &wz ); gluUnProject( wx, wy, wz, mv, proj, vp, &cx, &cy, &cz ); coords = Vector3( cx, cy, cz ); return coords;}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement