There was a mistake in my previous message. I was testing the code after
subtle changes but I forgot to change it back to normal... (But it doesn't
work all the same...)

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)
                    {
                        osg::notify(osg::NOTICE)<< "ENTERED THE FOR" <<
std::endl;
                        if(hitr->drawable.valid()) // it was written
'!hitr->drawable.valid()', but I've corrected it
                        {
                            osg::notify(osg::NOTICE)<< "ENTERED HERE" <<
std::endl;
                            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

Reply via email to