Hi, 
I am trying to get the intersection points between an intersection plane and a 
terrain using osgUtil::PlaneIntersector。 
The code is listed as following: 

osg::Plane planeLeft( osg::Vec3(1,0,0), osg::Vec3(0+1,0,0) );//define an 
intersetion plane 
osg::Polytope polytopeLeft;//define the range of planeLeft 
polytopeLeft.add( osg::Plane(osg::Vec3(0,1,0), osg::Vec3(0,0,0)) ); 
polytopeLeft.add( osg::Plane(osg::Vec3(0,-1,0), 
osg::Vec3(0,GlobalVariable::g_maxDepth,0)) ); 
osg::ref_ptr<osgUtil::PlaneIntersector> insectorLeft = new 
osgUtil::PlaneIntersector(planeLeft, polytopeLeft); 
osgUtil::IntersectionVisitor ivleft(insectorLeft); 
geodeTerrain->accept(ivleft); 
if (insectorLeft->containsIntersections() ) 
{ 
//output the intersection points 
fstream file; 
file.open("Terrain.txt",ios::out); 

osgUtil::PlaneIntersector::Intersections& intersections = 
insectorLeft->getIntersections(); 
osgUtil::PlaneIntersector::Intersections::iterator itr = intersections.begin(); 
for ( unsigned int i=0; i<(*itr).polyline.size(); ++i ) 
{ 
file<<(*itr).polyline[i].x()<<","<<(*itr).polyline[i].y()<<","<<(*itr).polyline[i].z()<<std::endl;
 
} 
file.close(); 
} 
I can get the intersection points successfully. But, when I change the terrain 
value just multiplying it with 3 and intersect with the same plane again, the 
sequence of output intersection points is reversed. So I wonder how can I 
control the sequence of the intersection points. 

Thank you! 

Cheers, 
Tianyun
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to