Make a feature pickable

classic Classic list List threaded Threaded
3 messages Options
remoe remoe
Reply | Threaded
Open this post in threaded view
|

Make a feature pickable

I try to make features pickable. But it doesn't find the feature in the index:

FeatureSourceIndexOptions fsio;
fsio.enabled() = true;

Session* session = new Session(mapNode->getMap(), style_sheet.get());
osg::ref_ptr<FeatureSourceIndex> fsi = new FeatureSourceIndex(
    session->getFeatureSource(),
    Registry::objectIndex(),
    fsio);

osg::ref_ptr<osg::Group> group = new FeatureSourceIndexNode(fsi.get());
...
Annotation::FeatureNode* fnode = new Annotation::FeatureNode(mapNode, features[i], style[i]);
group->addChild(fnode);
...
FeatureSourceIndexNode::reconstitute(group.get(), fsi.get());
mapNode->addChild(group);

What i've missed?

Thanks
Remo Eichenberger, Switzerland
jasonbeverage jasonbeverage
Reply | Threaded
Open this post in threaded view
|

Re: Make a feature pickable

Hey Remo,

You need to call setIndex on the FeatureNode.  We just added that recently to osgearth for this very reason.

So for example:
FeatureSourceIndexNode index = new FeatureSourceIndexNode(new FeatureSourceIndex(0, osgEarth::Registry::objectIndex(), FeatureSourceIndexOptions()));
FeatureNode featureNode = new FeatureNode(mapNode, *features);
featureNode->setIndex(index);
index->addChild(featureNode);



On Mon, Jul 9, 2018 at 12:00 PM remoe [via osgEarth] <[hidden email]> wrote:
I try to make features pickable. But it doesn't find the feature in the index:

FeatureSourceIndexOptions fsio;
fsio.enabled() = true;

Session* session = new Session(mapNode->getMap(), style_sheet.get());
osg::ref_ptr<FeatureSourceIndex> fsi = new FeatureSourceIndex(
    session->getFeatureSource(),
    Registry::objectIndex(),
    fsio);

osg::ref_ptr<osg::Group> group = new FeatureSourceIndexNode(fsi.get());
...
Annotation::FeatureNode* fnode = new Annotation::FeatureNode(mapNode, features[i], style[i]);
group->addChild(fnode);
...
FeatureSourceIndexNode::reconstitute(group.get(), fsi.get());
mapNode->addChild(group);

What i've missed?

Thanks
Remo Eichenberger, Switzerland



If you reply to this email, your message will be added to the discussion below:
http://forum.osgearth.org/Make-a-feature-pickable-tp7591945.html
To start a new topic under osgEarth, email [hidden email]
To unsubscribe from osgEarth, click here.
NAML
remoe remoe
Reply | Threaded
Open this post in threaded view
|

Re: Make a feature pickable

Jason, thanks for your hint! It works!

Remo Eichenberger, Switzerland