Hi Ben, In my engine, I got a method that takes a View and an optional NodePath. Notes: - I created an invisible plane so that I can test against that plane. - pointerX and pointerY are class members (you may refactor so that it suits your needs). - Here my method assumes there is at most one intersection (see the ASSERT()). - setPickPosition() is a method that stores the result (= the intersection/pick position).
void computePickPos(osgViewer::View & view, osg::NodePath * pPickNodePath = NULL) { if (pPickNodePath && pPickNodePath->empty()) return; osgUtil::LineSegmentIntersector::Intersections intersections; bool intersected; if (pPickNodePath) intersected = view.computeIntersections(pointerX, pointerY, *pPickNodePath, intersections); else intersected = view.computeIntersections(pointerX, pointerY, intersections); if (intersected) { ASSERT(intersections.size() <= 1); if (intersections.size()>0) setPickPosition(intersections.begin()->getWorldIntersectPoint()); } } Hope it helps. Sukender PVLE - Lightweight cross-platform game engine - http://pvle.sourceforge.net/ Le Mon, 09 Mar 2009 20:31:55 +0100, Ben Axelrod <baxel...@coroware.com> a écrit: > I have been using osgUtil::PickVisitor for a while now to pick objects in my > tree under the mouse. But now I need to cast a ray into the scene under the > mouse and manually intersect it with an imaginary plane. Is there some > helper function to do this mouse ray cast for me? Specifically, something > that would take as input 2 ints for the position of the mouse, and maybe the > camera or projection and view matrices, then output a vector? > > Thanks, > -Ben > _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org