From Peter Hrenka, "Due to popular demand I would like to submit this
enhanced version of PolytopeIntersector. New features of PolytopeIntersector : * Dimension mask: The user may specify the dimensions of the primitives to be tested. Checking polytope-triangle and polytope-quad intersections is rather slow so this can be turned off. * Reference plane: The resulting intersections are sorted by the distance to this plane. New memebers of PolytopeIntersector::Intersection : * distance: Distance of localIntersectionPoint to the reference plane * maxDistance: Maximum distance of all intersectionPoints to the reference plane. * intersectionPoints: The points intersecting the planes of the polytope or points completely inside the polytope. * localIntersectionPoint: arithmetic mean of all intersection points * primitiveIndex: Index of the primitive that intersected I added some more output to the example osgkeyboardmouse."
This commit is contained in:
@@ -234,20 +234,22 @@ public:
|
||||
|
||||
if (picker->containsIntersections())
|
||||
{
|
||||
osgUtil::PolytopeIntersector::Intersections& intersections = picker->getIntersections();
|
||||
osgUtil::PolytopeIntersector::Intersection intersection = picker->getFirstIntersection();
|
||||
|
||||
for (osgUtil::PolytopeIntersector::Intersections::iterator it=intersections.begin();
|
||||
it!=intersections.end(); ++it) {
|
||||
osgUtil::PolytopeIntersector::Intersection intersection=*it;
|
||||
osg::notify(osg::NOTICE)<<"Picked "<<intersection.localIntersectionPoint<<std::endl
|
||||
<<" Distance to ref. plane "<<intersection.distance
|
||||
<<", max. dist "<<intersection.maxDistance
|
||||
<<", primitive index "<<intersection.primitiveIndex
|
||||
<<", numIntersectionPoints "
|
||||
<<intersection.numIntersectionPoints
|
||||
<<std::endl;
|
||||
|
||||
osg::NodePath& nodePath = intersection.nodePath;
|
||||
node = (nodePath.size()>=1)?nodePath[nodePath.size()-1]:0;
|
||||
parent = (nodePath.size()>=2)?dynamic_cast<osg::Group*>(nodePath[nodePath.size()-2]):0;
|
||||
|
||||
if (node) std::cout<<" Hits "<<node->className()<<" nodePath size"<<nodePath.size()<<std::endl;
|
||||
toggleScribe(parent, node);
|
||||
}
|
||||
osg::NodePath& nodePath = intersection.nodePath;
|
||||
node = (nodePath.size()>=1)?nodePath[nodePath.size()-1]:0;
|
||||
parent = (nodePath.size()>=2)?dynamic_cast<osg::Group*>(nodePath[nodePath.size()-2]):0;
|
||||
|
||||
if (node) std::cout<<" Hits "<<node->className()<<" nodePath size "<<nodePath.size()<<std::endl;
|
||||
toggleScribe(parent, node);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user