Re: [newsletters] Re: [PyOpenGL-Users] OpenGl + Mouse Selection
Brought to you by:
mcfletch
From: Mike C. F. <mcf...@ro...> - 2003-04-22 15:19:47
|
Setup the projection matrix to be slightly larger than a single point (OpenGLContext gives you a 2x2 area). Here's the code from OpenGLContext/renderpass's SelectRenderPass class (matrixSize is just a tuple of (2,2) in this case): def PickProjection( self ): """Setup the constrained picking matrix and result buffer We set up the view frustum to be a box centered around the picking point of size self.matrixSize, projecting back into the screen from our current viewpoint. We then set up the selection buffer into which our results will be saved, and then switch to selection-mode rendering. """ glMatrixMode(GL_PROJECTION) glLoadIdentity() glInitNames() x,y = self.pickPoint gluPickMatrix( x,y, self.matrixSize [0], self.matrixSize [1], self.getViewport() ) glSelectBuffer(self.bufferSize) glRenderMode(GL_SELECT) You can find documentation on gluPickMatrix here: http://pyopengl.sourceforge.net/documentation/manual/gluPickMatrix.3G.html HTH, Mike sebastien HEITZMANN wrote: > I use this method with good success. > > I just have a little problem. My program paint some line on the OpenGL > panel and when i try to select one, I need to be very close to select > it. Is it a way to make the select area more large ? > > Thanks in advance. > > SEB > > Jasper Phillips a écrit: > >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >> >> >> That sounds like what I want. Thanks for the search reference! >> - -Jasper >> >> On Mon, 21 Apr 2003, Mike C. Fletcher wrote: >> >> >>> There are a number of ways to do this, but the most common way I've >>> encountered is to use the glSelectBuffer-based selection mechanisms >>> which come with OpenGL. You can find sample code for the >>> glSelectBuffer stuff in OpenGLContext or just about any OpenGL >>> reference or programming Web site (such as NeHe). >>> >>> The basic approach is to re-render the scene in "select" mode, >>> pushing "names" (integers) onto the selection stack as you render to >>> a frustum which is the projection of your picking point to >>> infinity. When you exit the select rendering mode you receive a >>> list of records indicating which names were active when items were >>> rendered to the frustum. >>> >>> Hope this helps, >>> Mike >>> >> >> >> [snip my original question] >> -----BEGIN PGP SIGNATURE----- >> Version: GnuPG v1.0.6 (GNU/Linux) >> Comment: For info see http://www.gnupg.org >> >> iD8DBQE+pFYa8EpjZ7/X9bIRAj6zAJ9Qd3y0PFhixkxbplYA+dxw4vCnYQCgwnGY >> ic7GD51sUgA+UrrgT+jii2M= >> =04I+ >> -----END PGP SIGNATURE----- >> >> >> >> ------------------------------------------------------- >> This sf.net email is sponsored by:ThinkGeek >> Welcome to geek heaven. >> http://thinkgeek.com/sf >> _______________________________________________ >> PyOpenGL Homepage >> http://pyopengl.sourceforge.net >> _______________________________________________ >> PyOpenGL-Users mailing list >> PyO...@li... >> https://lists.sourceforge.net/lists/listinfo/pyopengl-users >> >> >> >> > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > PyOpenGL Homepage > http://pyopengl.sourceforge.net > _______________________________________________ > PyOpenGL-Users mailing list > PyO...@li... > https://lists.sourceforge.net/lists/listinfo/pyopengl-users > -- _______________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://members.rogers.com/mcfletch/ |