I am using python with Qt from past 1 year.. now i have to use pyqt with opengl.
i am tring to write a sample program which can able to draw object ( eg cube,dot) and user can able to select using mouse.
but now i have done all the possible way to use opengl functions but still not able to select :(
I am using folowing code to pick : -
def pick3d( self, event ):
-
-
# 1. initialization
-
-
x = event.x()
-
y = event.y()
-
pixels = 5
-
buffer_size = 512
-
viewport = GL.glGetIntegerv(GL.GL_VIEWPORT)
-
-
# 2. selection logic
-
GL.glSelectBuffer(buffer_size)
-
GL.glRenderMode(GL.GL_SELECT)
-
GL.glInitNames()
-
GL.glPushName(0);
-
GL.glMatrixMode(GL.GL_PROJECTION)
-
GL.glPushMatrix()
-
GL.glLoadIdentity()
-
-
#This Creates A Matrix That Will Zoom Up To A Small Portion Of The Screen, Where The Mouse Is.
-
GLU.gluPickMatrix(x, (viewport[3]-y), 5, 5, viewport)
-
#Apply The Perspective Matrix
-
GLU.gluPerspective(45, (viewport[2]-viewport[0])/(viewport[3]-viewport[1]), 0.1, 100.0);
-
-
GL.glMatrixMode(GL.GL_MODELVIEW) #Select The Modelview Matrix
-
GL.glLoadIdentity() #Reset The Modelview Matrix
-
GL.glTranslatef(0.0,0.0,-10.0) #Move Into The Screen 20 Units
-
-
# previousviewmatrix = GL.glGetDoublev(GL.GL_PROJECTION_MATRIX)
-
# GL.glLoadIdentity()
-
# GLU.gluPickMatrix( x, viewport[3]-y, 5, 5, viewport )
-
# GL.glMultMatrixd(previousviewmatrix)
-
# GL.glMatrixMode(GL.GL_MODELVIEW)
-
self.makeObject(True)
-
-
GL.glMatrixMode(GL.GL_PROJECTION) #Select The Projection Matrix
-
GL.glPopMatrix() # Pop The Projection Matrix
-
GL.glMatrixMode(GL.GL_MODELVIEW) # Select The Modelview Matrix
-
self.buffer=GL.glRenderMode(GL.GL_RENDER)
-
-
# GL.glFlush()
-
# GL.glMatrixMode(GL.GL_PROJECTION)
-
# GL.glLoadMatrixd(previousviewmatrix)
-
# self.buffer = GL.glRenderMode(GL.GL_RENDER)
-
#
-
# # 3. update graphics
-
# self.updateGL()
-
-
# 4. process selction buffer if control is pressed
-
return self.processBuffer()
-
-
def processBuffer(self):
-
print len(self.buffer)
-
print "--------- pick3d ----------"
-
print " - nhits =", len( self.buffer )
-
if( len(self.buffer) == 0 ): print "hit nothing"
-
else:
-
min = self.buffer[0][0]
-
for record in self.buffer:
-
minDepth, maxDepth, names = record
-
# add all hit objects to selectedObjects
-
for i in range(len(names)):
-
if(self.selected.count(names[i]) == 1):
-
print " - unselected: ", names[i]
-
self.selected.remove(names[i])
-
else:
-
self.selected.append(names[i])
-
print " - selectedObjects: ", self.selected
-
-
return self.selected
can any one help me.. please give me any working simple program for selection
0 2414 Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jimmy Johns |
last post by:
Hi, why hasn't there a version of pyOpenGL for python 2.3.x yet? Currently
the binary installers for windows only work with python 2.2, and will give
an when installing for python 2.3. I can't...
|
by: Steven Gutstein |
last post by:
This is probably a fairly newbie type problem, but I'm trying to use
PyOpenGL, and don't seem to have installed it correctly.
I'm running Python 2.3 on a Windows NT machine. Whenever I go into...
|
by: Erik Max Francis |
last post by:
I was interesting in adding selection and hit testing to ZOE, and was
looking at the PyOpenGL wrappers' handling of selection and picking. I
see glSelectBuffer to specify the size of the buffer,...
|
by: Sébastien Ramage |
last post by:
Bonjour à tous,
Dans la folie j'ai installé le nouveau python, impatient de voir les
nouveautés
mais je pense que j'ai été un peu rapide car j'ai voulu utiliser
pyOpenGL et là problème il...
|
by: joroy |
last post by:
Hi all,
I think this is ctypes related but how can I call the glShaderSourceARB
function?
The function have this header:
glShaderSourceARB( GLhandleARB(shaderObj), GLsizei(count),...
|
by: sweetmelon |
last post by:
(I'm a newbie in Python and pyOpenGL.)
Environment:
WinXP SP2
Python ver. 2.5
WingIDE
easy_install is installed
PIL, pyNum is installed
Download PyOpenGL-3.0.0a5-py2.5.egg
run: easy_install...
|
by: shirish |
last post by:
Hi all,
Is it possible to have Python+Pygame+PyOpenGL in one compact
package so people can play the games released at pyweek.org . I have
been having a hard time getting the whole thing on windows...
|
by: seb.haase |
last post by:
Hi,
I am distributing a package with a precompiled collection of modules
and packages useful for Python based medical/biological/astronomical
image analysis and algorithm development. (Codename:...
|
by: Colin J. Williams |
last post by:
I have just installed PyOpenGL and get a
series of warning messages:
Best match: PyOpenGL 3.0.0b3
Downloading...
|
by: Clay Hobbs |
last post by:
I need a tutorial for PyOpenGL (specifically, to be used with wxPython).
I searched with Google and didn't find one. Does anybody know where one
is?
-- Ratfink
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| | |