I am trying to retrieve the node corresponding to a given feature.
More specifically, I am using the RTT picker to retrieve the feature under the mouse. I would also like to retrieve the corresponding node in the Scene Graph.
I can do the opposite: Retrieve the feature from the node (using the node’s stateSet to get the uniform, then retrieving the ObjectId from it, and finaly using the Registry to get the Feature), but I couldn’t find a way to retrieve the Node using the feature or the ObjectId.
Would You have a hint on how to do that?
Alternatively, is it possible to retrieve the feature’s layer?
If you used a FeatureNode (in code, or in an AnnotationLayer from your earth file) you can cast the ObjectIndex::get result to an AnnotationNode. The osgearth_pick example does this in MyPickCallback.
If your features are in a ModelLayer or FeatureModelLayer, there is no way to do it. Those type of layers combine many features into single Drawables for performance purposes, so a single Drawable might contain many features, or a single feature might be split among many Drawables. There is no one-to-one mapping of a Feature to a Node.