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

Reply via email to