Hi, a good hackish way I found to do selection in opengl is the following...
Draw each object to the back buffer with a different color. Then read the back buffer where the mouse is to find what color is there... and TADA!!! you have the object. You only need to read 1 pixel where the mouse is clicked, so it's pretty fast. You can find the position on the object by drawing each of it's triangles with separate colors... then to find on a triangle you can draw that triangle with a different color at each vertex -- backwards interpolating the color to find where on the triangle it is. I made a 3D painter using this technique, and it works ok. * oops! I just realised another post mentions this too :) oops. However the link doesn't mention how to find the position on the object... which my description does. On Nov 24, 1:22 pm, "Alex Holkner" <[EMAIL PROTECTED]> wrote: > On Mon, Nov 24, 2008 at 12:41 PM, Simtex <[EMAIL PROTECTED]> wrote: > > > I'm trying to do some basic mouse selection of irregular size 2d- > > objects (rectangular bounds checking isn't sufficient) so I've been > > trying to figure out a way to get better collision detection in > > pyglet. I noticed that the SVN has an experimental directory with a > > sprites.py file that contains a 'collide_list' function that looks > > awfully useful for what I'm trying to do. Does it work? I'm going to > > try it out anyway, but if it doesn't work I'd like to be sure it isn't > > my rudimentary skills causing it to fail :) > > The file is terribly out of date, and needs modifications to work with > the current pyglet (it was developed pre-alpha, before several API > changes). > > The core idea in the collision function there is to use OpenGL query > objects to determine a list of sprites that are drawn over a stenciled > area (which can be any shape). It's a pretty strange way to do > things, and (as suggested by its location) entirely experimental. > From memory it worked fine, but it requires OpenGL 1.5 or later (many > older cards won't have this support). > > For mouse selection (testing an irregular area against a point or > rectangular area), you're better off using GL selection buffers -- > there are many code examples of this around; I'm sure someone on this > list will have some handy. > > Alex. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pyglet-users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pyglet-users?hl=en -~----------~----~----~----~------~----~------~--~---
