Hello, everyone.

    In my application, I use ShapeDrawables, which are selected by the user
by mouse picking. An extract of the code concerning the picking is as
follows:

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 de ";
                    osgUtil::LineSegmentIntersector::Intersections::iterator
hitr = intersections.begin();

                    if(hitr->drawable.valid())
                        {
                            osg::ShapeDrawable* shapedrawable =
dynamic_cast<osg::ShapeDrawable*>(hitr->drawable.get());
                            changeColor(shapedrawable);
                            std::string nome = shapedrawable->getName();
                        }

                }
            }
    }
}

bool PickHandler::Intersecao(osgViewer::Viewer* viewer, const
osgGA::GUIEventAdapter& ea,
                             osgUtil::LineSegmentIntersector::Intersections
&intersections)
{
    return (viewer->computeIntersections(ea.getX(),ea.getY
(),intersections));
}


           I've looked through the doxygen documentation but couldn't find
any method that would return the drawable where the shapedrawable is
attached to. This way I would be able to get to the parent that has all the
information I need. Let me give an example to simplify.
          I have selected a sphere on the screen that is the drawable (in
the form of a shapedrawable) of an instace of the class Sphere (not the
osg's). How do I access the data that is inherent to every intance of that
class? A ShapeDrawable is not a Node, so I can't get a Parent... How do I do
it?

                                        Thanks,

                                             Renan M Z Mendes
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to