Hello,

On 08/04/2014 11:18 AM, Sonya Blade wrote:
> Dear All,
> 
> I'm experiencing very weird problem when using the polytope intersector. 
> Since there is not any explicit example on how 
> to use polytope example with rectangular selection I use osgPick example in 
> OSG and modify the codes to suit my need.

The canonical example for PolytopeIntersector is osgkeyboardmouse which shows 
one possible usage.
 
> Normally the below code picks the objects on scene but shows that 400 picked 
> objects which is not correct and far beyond of 
> scene object range where that I have, I only have 5-6 object in scene, 

As Sebastian Messerschmidt has suggested the PolytopeIntersector returns 
intersections on
a per-primitive level and that also includes all primitives inside the polytope.

If you only want results on a higher level (e.g. per drawable) you can just 
modify 
the counting loop in you code to eliminate duplicate drawables.

Admittedly, the current behaviour is of PolytopeIntersector is not very space- 
or time-efficient
for your use-case. I think a useful extension would be some kind of 
"only-first-intersection"-flag
which should reduce the number of generated intersecions for cases like yours.


Cheers,

Peter

> What could be the reason of that malfunctioning ? I 'll appreciate your 
> guidance on that !.
> 
> case (osgGA::GUIEventAdapter::RELEASE):
>             {
>                 if (btn_counter == 1 )
>                 {
>                     firstX = ea.getX(); firstY = ea.getY();
>                     btn_counter = 2;
>                     break;
>                 }
> 
>                 if (btn_counter==2)
>                 {
>                     btn_counter = 1;
>                     osgUtil::PolytopeIntersector* polytop = new 
> osgUtil::PolytopeIntersector( osgUtil::Intersector::WINDOW,  firstX,firstY, 
> ea.getX(), ea.getY() );
>                     osgUtil::IntersectionVisitor iv(polytop);
>                     view->getCamera()->accept(iv);
> 
>                     int k;
>                     if (polytop->containsIntersections() )
>                     {
> 
>                              osgUtil::PolytopeIntersector::Intersections 
> intersections= polytop->getIntersections();
>                              osg::Vec3 screenpos = 
> osg::Vec3(ea.getX(),ea.getY(),0);
> 
>                              
> for(osgUtil::PolytopeIntersector::Intersections::iterator hitr = 
> intersections.begin();
>                                 hitr != intersections.end(); ++hitr)
>                              {
>                                  k+=1;
>                                 std::cout<< k << "----" << 
> hitr->drawable->getName()<< hitr->drawable->className()<<"\n" ;
> 
>                              }
>                     }
>                 }
>             }
>         }
>     }
> };
> 
> 
> 
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> 

_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to