[PyOpenGL-Users] gluUnProject Projection Failed
Brought to you by:
mcfletch
|
From: Eleftherios G. <gar...@gm...> - 2010-04-12 17:57:13
|
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
|