Hello Martin,
I have a model with lots of points and I want to find the front/first point
under the mouse click (quickly)
Options are a polytrope intersector with a small box (2x2 5x5 pixels).
What if I used a few line lineintersectors spaced a pixel apart, would that be
faster?
LineSegmentIntersector will not find points (at all). Even for 3D
geometry, I wouldn't suggest using multiple LineSegmentIntersections
because then you might miss objects (between the lines) - you're subject
to sampling issues.
PolytopeIntersector will not order results in closest-first fashion, but
for points, you can do that yourself. Just order by the distance between
the camera's eye point and the given point.
This is possible for points but not for general geometry, for example
imagine a bowl containing fruit, and picking from above:
| |
| | polytope
\ | / |
\ / bowl with fruit
\_oOOo_/
The polytope above will pick both the fruit and the bowl, but which one
is closest? The bowl is closest for part of the polytope, but the fruit
are closest for another part.
Since points are zero-dimensional you can order them by distance without
ambiguity.
Also is there a way to use the colour under the mouse cursor to quickly check
if there is a point (by comparing to background) before doing the intersector?
You could do that yourself by doing a readPixel in the mouse x,y point
that was clicked. But it might be slow because it will flush the
graphics fifo, and in general it won't work because the background might
not be the clear color (if you have a skydome/skybox, or an environment
in your scene).
But if you want to try it, the way I'd do this is to delay the actual
picking for one frame. Have your event handler add a camera post-draw
callback that does an osg::Image::readPixels for the current camera and
checks for those x,y. If there's an object there, it can then do the
actual intersection test or whatever you want. The camera post-draw
callback then removes itself (so it isn't used for all frames, just the
frames where a pick was attempted - the osgViewer::ScreenCaptureHandler
does this so that it takes a screenshot only once).
Hope this helps,
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