Hi Gianni,

On 03.11.2014 11:47, Gianni Ambrosio wrote:
> Hi Peter,
> thank you for the fast reply.
> 
> I need some clarifications about question 1.
> In my application I will use the "picked" point to calculate, and then show, 
> the arclength of a path, i.e. the length of the path from start to the picked 
> point. So I would not need to show coordinates to the user. So I guess WINDOW 
> or PROJECTION would be the same for my case.
> But I would like to understand why I get different coordinates from 
> "intersection.localIntersectionPoint" with osgUtil::Intersector::WINDOW wrt 
> osgUtil::Intersector::PROJECTION
> 
> Here is a code snippet as an example:
> 
> Code:
> 
>    osgUtil::PolytopeIntersector* picker;
>    {
>       osg::Viewport* viewport = viewer->getCamera()->getViewport();
>       double mx = viewport->x() + (int)((double 
> )viewport->width()*(ea.getXnormalized()*0.5+0.5));
>       double my = viewport->y() + (int)((double 
> )viewport->height()*(ea.getYnormalized()*0.5+0.5));
> 
>       double w = 5.0f;
>       double h = 5.0f;
>       picker = new osgUtil::PolytopeIntersector( 
> osgUtil::Intersector::WINDOW, mx-w, my-h, mx+w, my+h );
>       osgUtil::IntersectionVisitor iv(picker);
>       viewer->getCamera()->accept(iv);
>       if (picker->containsIntersections())
>       {
>          osgUtil::PolytopeIntersector::Intersection intersection = 
> picker->getFirstIntersection();
>          std::cout << "osgUtil::Intersector::WINDOW " << 
> intersection.localIntersectionPoint.x() << " " << 
> intersection.localIntersectionPoint.y() << " " << 
> intersection.localIntersectionPoint.z() << std::endl;
>       }
>    }
>    {
>       double mx = ea.getXnormalized();
>       double my = ea.getYnormalized();
>       double w = 0.05;
>       double h = 0.05;
>       picker = new osgUtil::PolytopeIntersector( 
> osgUtil::Intersector::PROJECTION, mx-w, my-h, mx+w, my+h );
>       osgUtil::IntersectionVisitor iv(picker);
>       viewer->getCamera()->accept(iv);
>       if (picker->containsIntersections())
>       {
>          osgUtil::PolytopeIntersector::Intersection intersection = 
> picker->getFirstIntersection();
>          std::cout << "osgUtil::Intersector::PROJECTION " << 
> intersection.localIntersectionPoint.x() << " " << 
> intersection.localIntersectionPoint.y() << " " << 
> intersection.localIntersectionPoint.z() << std::endl;
>       }
>    }
> 
> 
> 
> And I get an output like this:
> 
> osgUtil::Intersector::WINDOW 18.8821 0.0163024 0
> osgUtil::Intersector::PROJECTION 31.7343 0.0274029 0
> osgUtil::Intersector::WINDOW 18.8821 0.0163024 0
> osgUtil::Intersector::PROJECTION 31.7343 0.0274029 0
> osgUtil::Intersector::WINDOW 22.529 0.019452 0
> osgUtil::Intersector::PROJECTION 34.8797 0.0301198 0
> 
> The WINDOW case shows different coordinates (look at X coordinate please) wrt 
> PROJECTION case, but they does not seem to be one in pixel and the other 
> normalized. Am I missing something?

The PROJECTION/WINDOW parameter specifies the coordinate system of the polytope 
you are using.
The intersections points you are printing are in the local coodinate system, 
i.e. the one where the basic
geometry was defined.
The PolytopeIntersector has the added quirk that the localIntersectionPoint is 
actually the geometric
center of all intersectionPoints. IntersectionPoints are points where the 
primitive is intersecting a polytope plane
and all primitive vertices completely inside the polytope volume. This could 
account for different results you are seeing.

> Moreover in the WINDOW case I need to be closer to the geomwetry to get a 
> valid intersection. Can you explain me please why?

The WINDOW case uses a 10 by 10 pixel area around the mouse position and the 
projection case
uses 0.1*screenWidth by 0.1*screenHeight which is only the same if you have a 
screen resolution of 100x100.
 
> Best regards,
> Gianni

Best regards,
Peter


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

Reply via email to