LineSegmentIntersector will almost never hit non-polygon geometry. A perfect hit between a line and another line is difficult with floating point math.
You should probably use the PolytopeIntersector ( http://trac.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a00616.html ) which intersects a VOLUME representing the intersection ray against the lines of the geometry, being much more inclusive. PolytopeIntersector is slower of course. On Fri, Oct 10, 2014 at 11:42 PM, jiang.sa...@gmail.com < jiang.sa...@gmail.com> wrote: > Hi guys, > > Recently, I have build a test application based on osg 3.2 and osgEarth > 2.5 which loads some linestring geometry. > Then I tried to calculate the spatial distance between two lines using > > > > > > > > > > > > > > > *osgUtil::LineSegmentIntersector::Intersections results; if (getMapNode() > && view->computeIntersections(x, y, results, _intersectionMask)) { // find > the first hit under the mouse: > osgUtil::LineSegmentIntersector::Intersection first = *(results.begin()); > osg::Vec3d point = first.getWorldIntersectPoint(); double lat_rad, lon_rad, > height; > getMapNode()->getMap()->getProfile()->getSRS()->getEllipsoid()->convertXYZToLatLongHeight( > point.x(), point.y(), point.z(), lat_rad, lon_rad, height); lat = > osg::RadiansToDegrees(lat_rad); lon = osg::RadiansToDegrees(lon_rad); hgt = > height;* > *}* > > But always is the intersection point on terrain, not linestring. > > Do you have any suggestion to complish it ? > Thanks! > > ------------------------------ > jiang.sa...@gmail.com > > _______________________________________________ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > -- Chris 'Xenon' Hanson, omo sanza lettere. xe...@alphapixel.com http://www.alphapixel.com/ Training • Consulting • Contracting 3D • Scene Graphs (Open Scene Graph/OSG) • OpenGL 2 • OpenGL 3 • OpenGL 4 • GLSL • OpenGL ES 1 • OpenGL ES 2 • OpenCL Digital Imaging • GIS • GPS • osgEarth • Terrain • Telemetry • Cryptography • Digital Audio • LIDAR • Kinect • Embedded • Mobile • iPhone/iPad/iOS • Android @alphapixel <https://twitter.com/alphapixel> facebook.com/alphapixel (775) 623-PIXL [7495]
_______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org