PDA

View Full Version : Selection and Picking for VBO objects



rakeshthp
02-04-2010, 11:02 AM
Hello,

How can i perform selection and picking for a triangular mesh which is displayed using VBO..?

Thanks in advance

Rosario Leonardi
02-04-2010, 01:40 PM
I don't see any connection between picking and VBO.
If you are starting a program now and you want to use the "gl*Names" i suggest you to change strategy.

For picking I suggest to put your objects in a BPS (or octree, or kd-tree or any space division structure) make a rough pass to select the bounding box (or bounding sphere) and then remove false positive by checking every triangle in the mesh.

It really depend on the number of triangles and the number of the object. If you have only one object with a lot of triangle the tree structure is useless and maybe you can use some algorithm to partition the mesh.

It also depend in the precision you need, in a lot of cases bounding volume are enough.

Pziko
02-04-2010, 01:57 PM
I'd recommend the method of rendering each object in a unique color to the back buffer and using glReadPixels to read the color at the cursor pos.

You can encode 2^24 different values into RGB, if you have >2^24 triangles then you'll have to do multiple passes.

Advantage over the above method is that all you need to write is a custom render function, rather than altering your fundamental data structure or having to introduce more matrix math etc.

See http://www.opengl.org/resources/faq/technical/selection.htm

and http://www.opengl.org/resources/faq/technical/color.htm#0050

DarkShadow44
02-05-2010, 12:25 PM
I just render my Mesh into a FBO (with clear Depth-Buffer), and then test with glReadPixels if there is a depth. But that works only if you want to select your whole mesh, not different triangles ;)