Hi Gianni,

On 03.11.2014 10:37, Gianni Ambrosio wrote:
> Hi All,
> I'm trying to handle mouse movements to show some informations to the user.
> I have basically two questions.
> 
> 1) Lookig at "osgkeyboardmouse.cpp" example found the following code:
> 
> Code:
> 
>             if (_useWindowCoordinates)
>             {
>                 // use window coordinates
>                 // remap the mouse x,y into viewport coordinates.
>                 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));
> 
>                 // half width, height.
>                 double w = 5.0f;
>                 double h = 5.0f;
>                 picker = new osgUtil::PolytopeIntersector( 
> osgUtil::Intersector::WINDOW, mx-w, my-h, mx+w, my+h );
>             } else {
>                 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 );
>             }
> 
> 
> 
> Is there a casa in which osgUtil::Intersector::WINDOW option is preferred 
> with respect to osgUtil::Intersector::PROJECTION?

The window coordinates will give you a pixel based pick area whereas the 
projection coordinates
work on normalized [-1,1] coordinates.
If your application supports different screen resolutions it might be more 
intuitive for the user
to use window coordinates.
 
> 2) osgUtil::LineSegmentIntersector does not seem to work fine if the geometry 
> is a line created with:
> 
>    osg::Vec3Array* vertices = new osg::Vec3Array;
>    ...
>    osg::DrawElementsUInt* elements = new 
> osg::DrawElementsUInt(osg::PrimitiveSet::LINE_STRIP);
>    geometry->setVertexArray(vertices);
>    geometry->addPrimitiveSet(elements);
> 
> In this case when I move the mouse over that geometry I get 
> containsIntersections() = false.
> Could you please explain me why?

LineSegementIntersector only handles primitives that cover a 2d-area 
(triangle/quad-strip/sets and such).
PolytopeIntersector can handle all primitives but it slower for 2d primitives.

> Regards,
> Gianni


Best regards,
Peter

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

Reply via email to