Show
Ignore:
Timestamp:
12/08/07 17:37:05 (6 years ago)
Author:
robert
Message:

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."

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgkeyboardmouse/osgkeyboardmouse.cpp

    r6941 r7626  
    235235            if (picker->containsIntersections()) 
    236236            { 
    237                 osgUtil::PolytopeIntersector::Intersections& intersections = picker->getIntersections(); 
    238  
    239                 for (osgUtil::PolytopeIntersector::Intersections::iterator it=intersections.begin(); 
    240                      it!=intersections.end(); ++it) { 
    241                     osgUtil::PolytopeIntersector::Intersection intersection=*it; 
    242  
    243                     osg::NodePath& nodePath = intersection.nodePath; 
    244                     node = (nodePath.size()>=1)?nodePath[nodePath.size()-1]:0; 
    245                     parent = (nodePath.size()>=2)?dynamic_cast<osg::Group*>(nodePath[nodePath.size()-2]):0; 
    246  
    247                     if (node) std::cout<<"  Hits "<<node->className()<<" nodePath size"<<nodePath.size()<<std::endl; 
    248                     toggleScribe(parent, node); 
    249                 } 
    250  
     237                osgUtil::PolytopeIntersector::Intersection intersection = picker->getFirstIntersection(); 
     238 
     239                osg::notify(osg::NOTICE)<<"Picked "<<intersection.localIntersectionPoint<<std::endl 
     240                    <<"  Distance to ref. plane "<<intersection.distance 
     241                    <<", max. dist "<<intersection.maxDistance 
     242                    <<", primitive index "<<intersection.primitiveIndex 
     243                    <<", numIntersectionPoints " 
     244                    <<intersection.numIntersectionPoints 
     245                    <<std::endl; 
     246 
     247                osg::NodePath& nodePath = intersection.nodePath; 
     248                node = (nodePath.size()>=1)?nodePath[nodePath.size()-1]:0; 
     249                parent = (nodePath.size()>=2)?dynamic_cast<osg::Group*>(nodePath[nodePath.size()-2]):0; 
     250 
     251                if (node) std::cout<<"  Hits "<<node->className()<<" nodePath size "<<nodePath.size()<<std::endl;     
     252                toggleScribe(parent, node); 
    251253            } 
    252254