Re: [PyOpenGL-Users] OpenGl + Mouse Selection
Brought to you by:
mcfletch
From: Mike C. F. <mcf...@ro...> - 2003-04-21 19:35:30
|
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 Jasper Phillips wrote: >-----BEGIN PGP SIGNED MESSAGE----- >Hash: SHA1 > >I want to be able to "select" different entities rendered in OpenGL w/ >a mouse -- essentially asking which shape the mouse pointer is over. >Ideally this could be used to select game pieces to move, etc. > >This is fairly easy to compute when rending in an orthographic view, as you >can simply translate mouse coordinates to viewpane coordinates. However, >this doesn't work well for perspective views! > >It would be nice to simply ask opengl what lies behind a certain screen >coordinate, but I haven't been able to find anything amongst the "glut" >(rimshot!) of opengl documentation about this. > >Has anyone here had any experience with something like this? I suspect >there must be an easy way to do it, as obviously the information is >available inside of opengl. > >- -Jasper > >-----BEGIN PGP SIGNATURE----- >Version: GnuPG v1.0.6 (GNU/Linux) >Comment: For info see http://www.gnupg.org > >iD8DBQE+pEJN8EpjZ7/X9bIRAilwAKDWUmh9ltlv1HiYRh7G5WO0TlJwWQCg1F3N >v9HHh5Eip+cBteBTCcPFMbE= >=c8Xf >-----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 > > > -- _______________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://members.rogers.com/mcfletch/ |