13 #include <osg/io_utils>
27 osgText::Text *updateText)
34 bool handle(
const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa);
36 virtual void pick(osgViewer::View *view,
const osgGA::GUIEventAdapter &ea);
53 osgGA::GUIActionAdapter &aa)
55 if(ea.getModKeyMask() == osgGA::GUIEventAdapter::MODKEY_SHIFT)
57 switch(ea.getEventType())
59 case(osgGA::GUIEventAdapter::PUSH):
61 osgViewer::View *view =
dynamic_cast< osgViewer::View *
>(&aa);
90 const osgGA::GUIEventAdapter &ea)
92 osgUtil::LineSegmentIntersector::Intersections intersections;
94 osg::ref_ptr< osg::Node > node;
96 std::string gdlist =
"";
98 if(view->computeIntersections(ea, intersections))
100 for(osgUtil::LineSegmentIntersector::Intersections::iterator hitr =
101 intersections.begin();
102 hitr != intersections.end();
105 std::ostringstream os;
107 if(!hitr->nodePath.empty() && !(hitr->nodePath.back()->getName().empty()))
110 os <<
"Object \"" << hitr->nodePath.back()->getName() <<
"\""
113 if(hitr->nodePath.back()->getDescription(0) ==
"MESH")
115 std::cout <<
"Object \"" << hitr->nodePath.back()->getName() <<
"\""
118 node = hitr->drawable->getParent(0);
125 std::vector< osg::Geode * > geodes =
127 for(
unsigned i = 0; i < geodes.size(); i++)
149 else if(hitr->drawable.valid())
151 os <<
"Object \"" << hitr->drawable->className() <<
"\"" << std::endl;
156 os <<
" local coords vertex(" << hitr->getLocalIntersectPoint()
158 <<
" normal(" << hitr->getLocalIntersectNormal() <<
")" << std::endl;
159 os <<
" world coords vertex(" << hitr->getWorldIntersectPoint()
161 <<
" normal(" << hitr->getWorldIntersectNormal() <<
")" << std::endl;
163 const osgUtil::LineSegmentIntersector::Intersection::IndexList &vil =
165 for(
unsigned int i = 0; i < vil.size(); ++i)
167 os <<
" vertex indices [" << i <<
"] = " << vil[i] << std::endl;