[osg-users] Realtime Pointpicking

Daniel Neos daniel.rd at hotmail.de
Fri Jun 24 08:06:58 PDT 2016


Hi,

I have a Pickhandler and a dynamically changing scene which consists only of a geometry node. To be more specific, the geometry node represents a point cloud consisting over ~100000 vertices.

Using a line intersector makes it nearly impossible to get an intersection, but the Intersector I am using, the polytopeintersector, needs ~200ms to get an intersection, which is too long for my application. I need a 'smooth' visualization of ~20-25fps and this would be definitley a bottleneck.

Is there a more simple way to get intersections of a non-solid object fast?

Here is my PickHandler. Input arguments in my application are the normalized (x,y)coordinates from the GUIEventAdapter, buffer is the tolerance with 0.005 and the viewer casted from the ActionAdapter.


Code:

bool PickHandler::getPickedPoint(double x, double y, float buffer,
    osgViewer::View* viewer)
{
 osg::ref_ptr<osgUtil::PolytopeIntersector> intersector(0);
    try
    {
        intersector = new osgUtil::PolytopeIntersector(
            osgUtil::Intersector::PROJECTION,
            x - buffer, y - buffer, x + buffer, y + buffer);
    }
    catch (const std::bad_alloc&)
    {
        return false;
    }

    // DimZero = check only for points
    intersector->setDimensionMask(osgUtil::PolytopeIntersector::DimZero);

    intersector->setIntersectionLimit(osgUtil::Intersector::LIMIT_NEAREST);
    osgUtil::IntersectionVisitor iv(intersector);
    viewer->getCamera()->accept(iv);

    if (intersector->containsIntersections())
    {
        osgUtil::PolytopeIntersector::Intersection intersection
            = *(intersector->getIntersections().begin());

        const osg::Vec3f& p = intersection.intersectionPoints[0];
        m_point.set(p[0], p[1], p[2]);
        return true;
    }
    return false;




Thank you!

Cheers,
Daniel[/code]

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=67797#67797








More information about the osg-users mailing list