From: Gary Herron <gherron@di...>  20100414 16:47:54

Eleftherios Garyfallidis wrote: > Hello, > > Thank you again for your response. > >  Show quoted text  > On Tue, Apr 13, 2010 at 11:20 AM, Greg Ewing > <greg.ewing@... <mailto:greg.ewing@...>> wrote: > > Eleftherios Garyfallidis wrote: > > to get > > the near plane I believe you need to gluUnProject with z=0. > and to get the far plane you need to gluUnProject with z=1 > > > You're quite right, I was misremembering, sorry. > > > Surprisingly, when I do glu.gluUnProject(x,viewport[3]y,0.) > and glu.gluUnProject(x,viewport[3]y,1.) in PyOpenGL it seems > it works fine but when I am feeding the transformation > matrices by myself I am getting this error "Projection Failed". > > > That sounds like there is something wrong with your matrices. > How are you getting them? Are you getting them directly from > OpenGL, or calculating them yourself? If you're calculating them > yourself, you might be making a mistake somewhere. > > > What happens if you retrieve the relevant matrices from OpenGL > and feed them to gluUnProject? If that works, compare them with > your own matrices to see if there is a difference. > > > Yes this is what I am doing just calculating these matrices using > the following PyOpenGL functions > > import OpenGL.GL as gl > > modelviewmatrix=gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX) > > projectionmatrix=gl.glGetDoublev(gl.GL_PROJECTION_MATRIX) > > viewport=gl.glGetDoublev(gl.GL_VIEWPORT) I have not followed this thread at all  so I don't know the history. Nevertheless, I see a potential problem. The call to gluUnProject expects the viewport to be passed in as integers (GLint*) so you should be using glGetIntegerv not glGetDoublev to get the viewport as an array of integers. Here's gluUnProject's spec: GLint gluUnProject( GLdouble winX, GLdouble winY, GLdouble winZ, const GLdouble * model, const GLdouble * proj, const GLint * view, // !!!!! GLdouble* objX, GLdouble* objY, GLdouble* objZ); Using glGetDoublev for the two matricies and glGetIntegerv for the viewport as input to gluUnProject has always worked well for me. > > These matrices are numpy arrays do you think that it might be a > problem when we put these as input in gluUnProject? Should I transform > them into something else perhaps? > > By the way I do confirm that when using gluUnProject without feeding > in the transformation matrices as in glu.gluUnProject(x,viewport[3] > y,0.) does work correctly :) I made some tests with picking planes > and the accuracy of picking was excellent!!! The tests involved > checking if the segment AB (where A is near and B is far) intersects > with planes. For my application I need to check against many planes so > I made a function for this in cython. The link for the code is here > > http://github.com/Garyfallidis/Fos/blob/master/fos/core/collision.pyx > > Best wishes, > Eleftherios > > >  > >  > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and finetune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intelswdev >  > > _______________________________________________ > PyOpenGL Homepage > http://pyopengl.sourceforge.net > _______________________________________________ > PyOpenGLUsers mailing list > PyOpenGLUsers@... > https://lists.sourceforge.net/lists/listinfo/pyopenglusers >  Gary Herron, PhD. Department of Computer Science DigiPen Institute of Technology (425) 8954418 