Hello Manjeet,

How to pick a vertex of any triangle by mouse.

You already posted that question not once, not twice but three times. Plus, Nick gave you a possible solution, and you replied to that message by repeating the question in large font. That seems a bit rude to me, so please review the guidelines of netiquette. You're more likely to get good answers by being polite and patient.

As for your problem, Nick gave you one way which is kind of the "old" OpenGL way - selection buffer is not really optimal now as it causes stalls in the OpenGL pipeline. Personally, I would do it in one of the two following ways:

If you just need any vertex under the mouse when it's clicked (consider many overlapping vertices in a small area, which one do you select?) you can use osgUtil::PolytopeIntersector with a small polytope centered on the mouse location. You can then take for example the vertex closest to the viewpoint. But this won't handle occlusion, i.e. it will select vertices even through other triangles.

Another way is to do a line segment intersection to find a triangle that intersects, and then find the vertex of that triangle that's closest to the intersection. Using osgUtil::LineSegmentIntersector will give you, in the resulting Intersection object, the triangle that was intersected and a ratiolist where ratio i is the contribution of vertex i in the triangle to the intersection point. The vertex with the largest ratio is the closest.

There are other ways, you can search Google for ideas. These two are just off the top of my head.

Hope this helps, and as I said, next time please be patient, this is a great community that really wants to help.

J-S
--
______________________________________________________
Jean-Sebastien Guay    jean-sebastien.g...@cm-labs.com
                               http://www.cm-labs.com/
                        http://whitestar02.webhop.org/
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to