Hi, Jean-Sébastien. When you've given me that code I've rearranged it in a way that would be more intuitive to me and it turned out to be this one below. Nothing much really. Just some methods calls,... well, see for yourself - nothing really changed. But I'm worried about something, since it didn't work. I've realized that the 'for' marked in the code is a little bit strange for what I want to happen. As I recall, it was used as it is to keep showing the coordinates of the point you were on with the mouse cursor, in the osgpick example. Is it appropriate in my case? I just want the color to change when I push the left button... Thanks again,
Renan M Z Mendes bool PickHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa) { osgViewer::Viewer* viewer = dynamic_cast<osgViewer::Viewer*>( &aa ); osgUtil::LineSegmentIntersector::Intersections intersections; if(!viewer) { return false; } switch(ea.getEventType()) { case(osgGA::GUIEventAdapter::PUSH): { if(Intersecao(viewer, ea, intersections)) { osg::notify(osg::NOTICE)<< "SELECAO" << std::endl; for(osgUtil::LineSegmentIntersector::Intersections::iterator hitr = intersections.begin(); hitr != intersections.end(); ++hitr) // I'M TALKING ABOUT THIS ONE { if(hitr->drawable.valid()) { osg::ShapeDrawable* shapedrawable = dynamic_cast<osg::ShapeDrawable*>(hitr->drawable.get()); shapedrawable->setColor(osg::Vec4(1.0, 0.0, 0.0, 1.0)); } } } } } } bool PickHandler::Intersecao(osgViewer::Viewer* viewer, const osgGA::GUIEventAdapter& ea, osgUtil::LineSegmentIntersector::Intersections intersections) { return (viewer->computeIntersections(ea.getX(),ea.getY (),intersections)); }
_______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org