LineSegmentIntersector

43 views
Skip to first unread message

AndrewC

unread,
Apr 14, 2020, 6:27:22 PM4/14/20
to OpenSceneGraph Users
Hi,
I am having a lot of problems with picking with LineSegmentIntersector in OSG 3.6.5.

I have reduced the problem to a a simple cube, center 0.5,0.5,0.5 with a boundingSphere radius of 1.2142

I create the intersection with ( x , y are screen coordinates)

picker=new osgUtil::LineSegmentIntersector ( osgUtil::Intersector::WINDOW, x, y );
osgUtil
::IntersectionVisitor iv ( picker );
getCamera
()->accept ( iv );



When I am "close" to the model geometry in an isometric view ( the cube fills,say, 50% of the screen), this works perfectly. I get the exact intersections coordinates I expect.

When I "pull the camera back" from the geometry and the object is much smaller on the screen, the intersections fail.

After much debugging, the problem is that the intersector fails the test of the intersection of the line with the bounding sphere of my model geometry

Specifically I send up in

bool LineSegmentIntersector::intersects(const osg::BoundingSphere& bs)


The BoundingSphere is in "model space" , and correct, but the _start and _end points used in the calculation are incorrect to intersect the sphere in model space and so the intersection fails.

_start {_v=0x000001ba7308d300 {13.227287349450325, -2.9785854231569449, -5.5167534692525066} }
_end
{_v=0x000001ba7308d318 {11.072576448741074, -5.1332963238661939, -7.6714332827528793} }

Any ideas what is going on. It seems although the vector of start and end is the correct vector ( or the "closer" picking would not work), something is wrong in the transformation into model space.

Thx
Andrew

OpenSceneGraph Users

unread,
Apr 15, 2020, 2:56:24 AM4/15/20
to OpenSceneGraph Users
Hi Andrew,

When you say you have a isometric view, to be clear, you mean you have an orthographic projection of the scene?  The OSG itself support orthographic projection via the osg::Camera's ProjectionMatrix, the intersection.  It can only account for this if the IntersectionVisitor knows about it's setting. 

Have you tried the osgViewer::View(er)::computeIntersections(..) method?

This method knows about the View's Camera so can account for it's projection matrix.

Robert.

--
You received this message because you are subscribed to the Google Groups "OpenSceneGraph Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osg-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osg-users/4fa21208-3ee7-45d7-a9cf-42a4b8a45d52%40googlegroups.com.
_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

AndrewC

unread,
Apr 15, 2020, 12:58:40 PM4/15/20
to OpenSceneGraph Users
In my case its Perspective.


I was able to work around the problem by using a PolyTope intersector with a 1x1 rectangle. That worked perfectly.
To unsubscribe from this group and stop receiving emails from it, send an email to osg-...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages