RTTPicker not working with annotation added programmatically

classic Classic list List threaded Threaded
2 messages Options
JohnD JohnD
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RTTPicker not working with annotation added programmatically

Hi

I added the following to the osgearth_pick example ahead if the line - return viewer.run();

// ----------------------------------------
const SpatialReference* geoSRS = MapNode::get(node)->getMapSRS()->getGeographicSRS();Style pm;
pm.getOrCreate<IconSymbol>()->url()->setLiteral( "D:/dev/support/data/data/placemark32.png" );
pm.getOrCreate<IconSymbol>()->declutter() = true;
pm.getOrCreate<TextSymbol>()->halo() = Color("#5f5f5f");
PlaceNode * placeNode = new PlaceNode(MapNode::get(node), GeoPoint(geoSRS, -110.00, 34.0), "MyPlace", pm);
// Puts placeNode into the objectIndex (object ID = 36)
// hoping that RTTPicker would pick and return the object ID
Registry::objectIndex()->tagNode( placeNode, placeNode );
placeNode->setName("MyPlace");
placeNode->setPriority(9);
osg::Group* groupPlaces = new osg::Group();
groupPlaces->addChild(placeNode);
root->addChild( groupPlaces );

return viewer.run();
// ----------------------------------------

The PlaceNode displayed on the map but RTTPicker did not work (Name "MyPlace", Object ID 36).

The RTTPicker only displays and picks the PlaceNode loaded from annotation.earth (Name "Place", Object ID 13).

What am I doing wrong?



Thanks

JohnD
JohnD JohnD
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: RTTPicker not working with annotation added programmatically

Hi

Fixed.

Changed:
        osg::Group* root = dynamic_cast<osg::Group*>(node);
To:
        osg::Group* root = dynamic_cast<osg::Group*>(MapNode::get(node));

and I can now pick the programmatically added PlaceName (Name "MyPlace", Object ID 36)

Hope this helps other with the same problem.

Loading...