The polytope intersector tests to see if a frustum (i.e. truncated
pyramid) volume contains or intersects with geometry. In the case of a
testing a polygon or a fully contained line segment, there is no single
point that describes the intersection. This is fine for selection when
you are primarily interested in merely determining the node the user
clicked on. If you need an exact intersection point, you have to use a
LineSegmentIntersector (but this makes it difficult to pick lines and
points) or implement your own Intersector class that reports back more
detailed intersection information.
- Pete
On 7/20/2012 10:00 AM, Bob Slobodan wrote:
Hi guys,
I'm having some difficulties with a polytope intersector.
My scene uses polygons, lines and points, so I decided to use a polytope
intersector to find which object the user wants to select. Here is my code :
Code:
osg::ref_ptr<osg::Viewport> viewport = camera->getViewport();
double mx = viewport->x() + (int)((double
)viewport->width()*(ea.getXnormalized()*0.5+0.5));
double my = viewport->y() + (int)((double
)viewport->height()*(ea.getYnormalized()*0.5+0.5));
double w = SELECTION_SENSITIVITY;
double h = SELECTION_SENSITIVITY;
osg::ref_ptr<osgUtil::PolytopeIntersector> picker = new
osgUtil::PolytopeIntersector( osgUtil::Intersector::WINDOW, mx-w, my-h, mx+w, my+h );
Then I look into the picker and retrieve the selected object and the exact
coordinates of the click.
This works just fine when I only need to find out which object was clicked, but
the coordinates of the intersection with a polygon are not the exact
coordinates of the click. It's actually the coordinates of the ray starting at
the bottom left corner of the polytope. I'm not sure of how the
polytopeIntersector works but I guess it's only because this ray is the first
to be tested and to intersect an object of the scene.
I tried to reduce my SELECTION_SENSITIVITY constant, but then, it's much harder
to select a line or a point.
What could I do to get the coordinates of the intersection with the ray that is
the closest to the center of the polytope ? Should I use another kind of
intersector ?
Sorry if I wasn't clear enough. Ask me if you want more details.
Thank you !
Bob
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=48958#48958
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
--
Peter Amstutz
Senior Software Engineer
Technology Solutions Experts
Natick, MA
02131
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org