[SOLVED] osgEarth 3.0 :: RTTPicker :: Qt :: Advice needed.

classic Classic list List threaded Threaded
7 messages Options
kefir kefir
Reply | Threaded
Open this post in threaded view
|

[SOLVED] osgEarth 3.0 :: RTTPicker :: Qt :: Advice needed.

This post was updated on .
Hello again, now I need your advice on RTTPicker. My goal is to use it without its' own dedicated view. Looking at the examples I came up with following initialization code:

viewer->stopThreading(); //still have no idea if that applies to my case
viewer->getCamera()->setNodeMask(~0);

// Install the query tool.
if(!picker)
picker = new RTTPicker();

if(!pickerCallback)
pickerCallback = new OSGEPickerCallback(this);

viewer->addEventHandler( picker );
picker->addChild( rootNode );//have tried passing mapNode here with same effect

picker->setDefaultCallback( pickerCallback );

viewer->startThreading();


OSGEPickerCallback is basically callback class straight from examples. Only difference is that it just fires "hit" with id or "miss" on mouse release into the console.
And it only misses, though map clearly contains a FeatureLayer with CircleNode in it.

Maybe I did misunderstand its' use and forgot to pass something to the callback class...
Any help will be appreciated.

UPD: For some reason it fires "hit" message when clicking on earth's atmosphere halo effect...
Solution was to add node to the registry, so it then could be picked. Here's implementation that worked for me:

Style circleStyle;

circleStyle.getOrCreate()->fill()->color() = Color(Color::Cyan, 0.5f);
circleStyle.getOrCreate()->outline() = true;
circleStyle.getOrCreate()->clamping() = AltitudeSymbol::CLAMP_TO_TERRAIN;
circleStyle.getOrCreate()->technique() = AltitudeSymbol::TECHNIQUE_DRAPE ;
circleStyle.getOrCreateSymbol()->stroke()->width() = 2.0f;
circleStyle.getOrCreateSymbol()->stroke()->color() = Color(Color::Red, 1.0f);
circleStyle.getOrCreateSymbol()->tessellationSize()->set(50.1, Units::METERS);

examNode = new CircleNode();
examNode->set(pt, Distance(5.0, Units::METERS), circleStyle);
examNode->setDynamic(true);

//add index for object picking
ObjectIndex* index = osgEarth::Registry::objectIndex();
index->tagNode(examNode, examNode);


layer->getNode()->asGroup()->addChild(examNode);


gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: osgEarth 3.0 :: RTTPicker :: Qt :: Advice needed.

kefir,
Can you please elaborate on "use it without its own dedicated view?" What does that mean?
Which version of osgEarth are you using?
Glenn Waldron / Pelican Mapping
kefir kefir
Reply | Threaded
Open this post in threaded view
|

Re: osgEarth 3.0 :: RTTPicker :: Qt :: Advice needed.

gwaldron wrote
Can you please elaborate on "use it without its own dedicated view?" What does that mean?
Sure... In the example application a separate view is being constructed. It draws outlines of objects/features that RTTPicker "sees". Also As it seems the picker itself works through that secondary view rather then through the main view.

gwaldron wrote
Which version of osgEarth are you using?
3.0 as title implies. Examples work fine.
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: osgEarth 3.0 :: RTTPicker :: Qt :: Advice needed.

Right, missed that in the title :)

You need to add your data to the ObjectIndex in order for it to be pickable:

ObjectIndex* index = osgEarth::Registry::objectIndex();
ObjectID oid = index->tagNode(node, object);

"object" is the object to put in the index; "node" is the corresponding scene graph node. They can be the same.

Regarding the RTT debug view: If you comment lines 227-235 in osgearth_pick.cpp, the picking still functions properly (for me anyway).
Glenn Waldron / Pelican Mapping
kefir kefir
Reply | Threaded
Open this post in threaded view
|

Re: osgEarth 3.0 :: RTTPicker :: Qt :: Advice needed.

Next time I will include footer with version. ;)

Thank you, Glenn! Will try shortly.

As a thought - maybe it is wise to add an option/property to the node that if set will automatically add said node to the index on creation? Or is it just against your architectural choices?

Anyway information you have provided should be enough to make picker work.
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: osgEarth 3.0 :: RTTPicker :: Qt :: Advice needed.

kefir,
Probably not. I think this approach gives the developer more flexibility. For example, you might want to index the node to a Feature object, or another Node, or an application object. Data loaded from earth files it automatically tagged, but that makes sense since the developer has no direct access to it.
Glenn Waldron / Pelican Mapping
kefir kefir
Reply | Threaded
Open this post in threaded view
|

Re: osgEarth 3.0 :: RTTPicker :: Qt :: Advice needed.

I meant something like
examNode->setEnableIndexing(true);

With false set by default would have been nice as a convenience function. But of course not necessary.