[osg-users] LineSegmentIntersector doesn't give accurate Coordinates

Jochen Schwitzer fasoldma63759 at th-nuernberg.de
Thu Jun 21 04:30:48 PDT 2018


Hi Robert,

thanks for your quick response.

so here's what I'm doing:


Code:

        if (viewer)
        {
            returnValue =
                ReactOnLCSPointClick(
                    *viewer, i_eventAdapter.getX(), i_eventAdapter.getY());
        }




I tried as well with getXnormalized() and Intersector::PROJECTION but then it was even more far off


Code:
    osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector = new osgUtil::LineSegmentIntersector(
        osgUtil::Intersector::WINDOW, i_clickXCoordinate, i_clickYCoordinate);

    osgUtil::IntersectionVisitor iv(intersector.get());

    iv.setTraversalMask(~0x1);

    io_viewer.getCamera()->accept(iv);

 osgUtil::LineSegmentIntersector::Intersections intersections = intersector->getIntersections();

    for (osgUtil::LineSegmentIntersector::Intersections::const_iterator i = intersections.begin();
            i != intersections.end(); ++i)
    {
        if (nodePath.back()->getName() == "xxx")
        {

            osg::Vec3 lcsIntersectPoint = i->getLocalIntersectPoint();
            float x = lcsIntersectPoint.x()
            float y = lcsIntersectPoint.y();
            returnValue = true;
            break;
        }
    }



I draw a point at the coordinates i get in the end

Thank you!

Cheers,
Jochen

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




Attachments: 
http://forum.openscenegraph.org//files/capture_252.png




More information about the osg-users mailing list