FeatureNode intersections

classic Classic list List threaded Threaded
1 message Options
krzysief krzysief
Reply | Threaded
Open this post in threaded view
|

FeatureNode intersections

Hi, i have a Group of FeatureNodes - some circles, lines, rectangles and I want to implement a simple (mouse) selection for them that i can select and for ex. delete them, now that i am new at event handling in osg i unfortunately don't know how to do it, can I ask for any suggestions?

I tried this code:

bool process(osgGA::GUIEventAdapter* ea, osgGA::GUIActionAdapter* aa, osg::View* view){
if(ea->getEventType() == osgGA::GUIEventAdapter::PUSH)
        {
                if(osgViewer::View* v = dynamic_cast<osgViewer::View*>(view))
                {
                        std::cout << " casted!" << std::endl;
                        IntersectionPicker picker(v);
                        picker.setBuffer(20);
                        IntersectionPicker::Hits hits;
                        picker.pick(ea->getX(), ea->getY(), hits);
                        for(auto hit : hits)
                        {
                              std::cout << " hit!" << std::endl;
                                ref_ptr<osg::Node> node = picker.getNode<osg::Node>(hit);
                                if(node.valid())
                                {
                                if(ref_ptr<Annotation::FeatureNode> ft = dynamic_pointer_cast<Annotation::FeatureNode>(node))
                                                std::cout << " got feature!" << std::endl;
                                }
                        }
                        return true;
                }
        }
}