Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Rightclick on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: Eleftherios Garyfallidis <garyfallidis@gm...>  20100412 17:57:13
Attachments:
Message as HTML

Hello, I am using the pyopengl version 3.0.0 in Ubuntu 9.10 and I am trying to get a pick ray when I press 'p' in the keyboard. To do that I found that is well suggested to use gluUnProject. if key == 'p': modelviewmatrix=gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX) print 'ModelViewMatrix' print modelviewmatrix projectionmatrix=gl.glGetDoublev(gl.GL_PROJECTION_MATRIX) print 'ProjectionMatrix' print projectionmatrix viewport=gl.glGetDoublev(gl.GL_VIEWPORT) print 'Viewport' print viewport print float(x), viewport[3]float(y) wx,wy,wz= glu.gluUnProject(float(x),viewport[3]float(y),0., modelviewmatrix, projectionmatrix, viewport) print 'World Coordinate' print wx,wy,wz And the output is giving me a value error projection failed as you can see below ModelViewMatrix [[ 1. 0. 0. 0.] [ 0. 1. 0. 0.] [ 0. 0. 1. 0.] [ 0. 0. 150. 1.]] ProjectionMatrix [[ 1.28300059 0. 0. 0. ] [ 0. 1.73205078 0. 0. ] [ 0. 0. 1.00010002 1. ] [ 0. 0. 0.20001 0. ]] Viewport [ 0. 0. 1080. 800.] 693.0 489.0 Traceback (most recent call last): File "_ctypes/callbacks.c", line 295, in 'calling callback function' File "scene.py", line 294, in keystroke viewport) File "/usr/lib/pymodules/python2.6/OpenGL/lazywrapper.py", line 9, in __call__ return wrapper( baseFunction, *args, **named ) File "/usr/lib/pymodules/python2.6/OpenGL/GLU/projection.py", line 60, in gluUnProject raise ValueError( """Projection failed!""" ) ValueError: Projection failed! Any ideas? Best wishes, Eleftherios 
From: Greg Ewing <greg.ewing@ca...>  20100413 10:30:13

Eleftherios Garyfallidis wrote: > wx,wy,wz= glu.gluUnProject(float(x),viewport[3]float(y),0., > modelviewmatrix, > projectionmatrix, > viewport) I don't think that 0 is a valid value for the z coordinate when you're unprojecting in a perspective projection. Also, to get a ray, you need to know *two* points in the scene. The way I do it is to call gluUnProject twice, once with z = the near plane, and once with z = the far plane. A line between the two resulting points gives you your pick ray.  Greg 
From: Eleftherios Garyfallidis <garyfallidis@gm...>  20100414 09:59:29
Attachments:
Message as HTML

Hello, Thank you again for your response.  Show quoted text  On Tue, Apr 13, 2010 at 11:20 AM, Greg Ewing <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) 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 
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 
Sign up for the SourceForge newsletter:
No, thanks