How to get a Node from a Feature ?

classic Classic list List threaded Threaded
4 messages Options
RG RG
Reply | Threaded
Open this post in threaded view
|

How to get a Node from a Feature ?

Hello.

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?
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: How to get a Node from a Feature ?

RG,

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.
Glenn Waldron / Pelican Mapping
RG RG
Reply | Threaded
Open this post in threaded view
|

Re: How to get a Node from a Feature ?

Unfortunately, the feature I am trying to pick is in a ModelLayer.

What about retrieving the Layer then?
Does a single Drawables contains features from several layers? If not, it should be possible to retrieve the corresponding Layer, is it not?
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: How to get a Node from a Feature ?

Actually there is no requirement that features are part of a Layer at all; as a result, there's no easy way to figure it out. However, this thread might be of help:
http://forum.osgearth.org/usage-in-FeatureSourceIndexNode-td7498623.html

Glenn Waldron / Pelican Mapping