From 59f417f1e01d9667ffd6f7c9481b599023856d1c Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 15 Jul 2019 16:13:57 +0100 Subject: [PATCH] Added test of picking --- examples/osgtext3D/osgtext3D.cpp | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/examples/osgtext3D/osgtext3D.cpp b/examples/osgtext3D/osgtext3D.cpp index 15bdbfdc2..f71be4e30 100644 --- a/examples/osgtext3D/osgtext3D.cpp +++ b/examples/osgtext3D/osgtext3D.cpp @@ -43,9 +43,15 @@ public: { } - virtual bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter&) + virtual bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa) { - if (ea.getEventType() == osgGA::GUIEventAdapter::KEYUP) + if (ea.getEventType() == osgGA::GUIEventAdapter::PUSH) + { + osgViewer::View* view = dynamic_cast(&aa); + if (view) pick(view,ea); + return false; + } + else if (ea.getEventType() == osgGA::GUIEventAdapter::KEYUP) { if (ea.getKey() == osgGA::GUIEventAdapter::KEY_Up) { @@ -83,6 +89,24 @@ public: return false; } + void pick(osgViewer::View* view, const osgGA::GUIEventAdapter& ea) + { + osgUtil::LineSegmentIntersector::Intersections intersections; + if (view->computeIntersections(ea, intersections)) + { + OSG_NOTICE<<"found intersections : "<localIntersectionPoint<