I'm trying to implement POI adding and editing.
I use osgEarth::Annotation::PlaceNode as draw type for POI.
Currently with mouse click I can add POIs. Now I want to edit created POI by double clicking it.
My thought was to setName for PlaceNode as "POI/[id]", then use LineSegmentIntersector to get all objects under mouse, and then filter them all with condition on getName().contains("POI/"). After that I could get corresponding POI id from the name.
But the problem is - all PlaceNodes are ignored while searching intersections. Here is my code to find intersections and show all objects names:
bool MouseClickEventHandler::action_editSimplePOI(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
osgViewer::View* view = static_cast<osgViewer::View*>(aa.asView());
if (view->computeIntersections(ea.getX(), ea.getY(), hits))
for (std::multiset<osgUtil::LineSegmentIntersector::Intersection>::iterator it = hits.begin(); it != hits.end(); ++it)
for (osg::Node* node : it->nodePath)
QString name = QString::fromStdString(node->getName());
qDebug() << name;
As a result I can see lots of nodes names like "osgEarth.RexTerrainEngineNode" or empty ones, but no PlaceNodes.
I've double checked that my PlaceNode getName() method returns correct name.
Is it a common behaviour of PlaceNode? How can I bypass it?
Yes, this is normal behavior for PlaceNode. PlaceNode and other annotation types do not render in traditional "scene graph" space; they render as screen-space overlays and are not detectable by an intersection visitor.
I recommend using osgEarth's RTTPicker instead. The "osgearth_pick" example demonstrates it. osgEarth has a global ObjectIndex that supports object identification and picking. Instead of using setName() on your PlaceNode, you would call