[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] collision detection



enrike wrote:
i need some help with collisions. I am using pyopengy to crate some complex shapes and i need to detect the mouse click on them.
It sounds like you've already found several solutions. I'll throw one more your way. OpenGL has a feature called "Pick Buffers" or "Select Buffers". These allow you to perform pixel precise polygon selection on any sort of complex 3d scene and drawing primitives.

You use it by setting OpenGL into Pickbuffer Mode. You set an area or pixel on the screen you are interested and then draw the scene pretty much like normal. Although OpenGL doesn't actually draw anything. As you draw, you can assign integer ID tags to the drawing commands. When you are done "drawing" you ask OpenGL which of these ID tags was found in the active area. I believe you also get information like 3d depth, but it may just be sorted?

Anyways, it is a little more complex, but powerful to use. It may not matter as much with a 2D scene, but it is a big win for 3D scenes and multiple types of drawing primitives.