Hi,
I use osgUtil::LineSegmentIntersector to obtain the intersections between a
mouse or a ray starting from a wand and a terrain generated with
VirtualPlanetBuilder and to display the latitude, longitude and height of the
intersection point.
When I use the LineSegmentIntersector with the mouse and I use the camera which
accept the IntersectionVisitor, the values of latitude, longitude and height
are correct.
Here is my code :
osg::ref_ptr osgUtil::LineSegmentIntersector picker = new
osgUtil::LineSegmentIntersector(osgUtil::Intersector::WINDOW, x, y);
osgUtil::IntersectionVisitor iv(picker.get());
view-getCamera()-accept(iv);
if (picker-containsIntersections())
{
intersections = picker-getIntersections();
for(osgUtil::LineSegmentIntersector::Intersections::iterator hitr =
intersections.begin();
hitr != intersections.end();
++hitr)
{
osg::CoordinateSystemNode* csn = new osg::CoordinateSystemNode;
csn-setEllipsoidModel(new osg::EllipsoidModel());
csn-addChild(group);
point = hitr-getWorldIntersectPoint();
double latitude;
double longitude;
double height;
csn-getEllipsoidModel()-convertXYZToLatLongHeight(point.x(),point.y(),point.z(),latitude,longitude,height);
latitude = osg::RadiansToDegrees(latitude);
longitude = osg::RadiansToDegrees(longitude);
std::cout lat,long,height( latitude ,
longitude , height ) std::endl;
}
}
But, my goal is to obtain the intersections of the terrain with a ray starting
from a wand. I use here LineSegmentIntersector with the start point of a wand
and the end point and I use the rootNode which accept the IntersectionVisitor.
But in this case, the values of latitude, longitude and height are false.
Here is my code :
osg::Vec3 wandp1;
osg::Vec3 wandp2;
osg::ref_ptr osgUtil::LineSegmentIntersector picker = new
osgUtil::LineSegmentIntersector(wandp1,wandp2);
osgUtil::LineSegmentIntersector::Intersections intersections;
osgUtil::IntersectionVisitor iv(line.get());
rootNode-accept(iv);
if(picker-containsIntersections()){
//same code as before
}
In red are the differences between the two methods.
I don't understand what is the problem.
Can you help me, please?
Thank you!
Cheers,
lucie
--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=30262#30262
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org