IntersectionPicker problem with FeatureNodes

classic Classic list List threaded Threaded
8 messages Options
krzysief krzysief
Reply | Threaded
Open this post in threaded view
|

IntersectionPicker problem with FeatureNodes

Hi, i am trying to pick FeatureNodes from earth, everything seems to be fine as long as the nodes are small, but when they are for example big enough to cover about 1/4 of the earth's surface picking gets VERY inaccurate. The object is being detected as picked even when I click far far away from it.

Here is my code for picking:

IntersectionPicker picker(view);
IntersectionPicker::Hits hits;
if (picker.pick(mouse_x, mouse_y, hits)){
        for(auto hit : hits)
        {
                if(auto* feature_node = picker.getNode<FeatureNode>(hit))
                        //do sth with node


I tried playing with buffer and limit params but it have no effects.

~Kris
Blanky Blanky
Reply | Threaded
Open this post in threaded view
|

Re: IntersectionPicker problem with FeatureNodes

If I recall correctly, the picker intersects a ray through the scenegraph and collects things that collide with it. If I had to guess, on a really large object this ray is falsely intersecting and isn't supposed to be 100% perfect since it's an approximation.

If you have only a few objects in the scene graph, then you can possibly create your own accurate picker. Check where you clicked for example and loop through all of the osgEarth::Annotation::FeatureNode objects and check if the x() and y() position for the event adapter resides within the bounding box any of the FeatureNode objects. Although not ideal, it will be more accurate at the expense of speed with many objects.

Just looking at the source of all of it some pseudo code that might get you started if this is a route you'd like to take:

1. Click and capture the x() and y() for the event adapter in the handler.

2. Have a function that loops through all of the objects in your scene graph either by traversal or some container for your FeatureNodes, especially if you only need to check for one type.

3. While looping through the FeatureNodes, get each Feature from it and check if its corresponding osgEarth::Geometry's bounds contain your x() and y() click position.

My colleague and I applied this to a Rubber Band-like tool to collect what was contained within it accurately, when covering large portions of the world.

Hope this helps!

- Blanky
krzysief krzysief
Reply | Threaded
Open this post in threaded view
|

Re: IntersectionPicker problem with FeatureNodes

Thanks for your response Blanky!

I tried this and it works for featurenodes, but i also have some other osg objects on the map that i can not put into my looping vector from architectural reasons. So there is no way accurate picker that will work on every node and every zoom?
krzysief krzysief
Reply | Threaded
Open this post in threaded view
|

Re: IntersectionPicker problem with FeatureNodes

I also want to mention that LineSegmentIntersector finds perfectly osg objects and FILLED feturenodes, but the featurenode lines and unfilled polygons are being avoided, why is that?
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: IntersectionPicker problem with FeatureNodes

A LineSegmentIntersector cannot intersect lines or points, only triangles. A PolytopeIntersector might work but would fail on draped geometries or any geometries that are altered by a vertex shader. The goal of the RTTPicker is the address these use cases.
Glenn Waldron / Pelican Mapping
krzysief krzysief
Reply | Threaded
Open this post in threaded view
|

Re: IntersectionPicker problem with FeatureNodes

Thanks Glenn, but i am forced to pick multiple overlapping objects in the scene so i cannot use RTTPicker, however i found the solution to my problem (i know that it isn't the best for performance), when the picker picks an object from whole graph i pick again but this time with the restriction of the picked graph and now it works pixel perfect:

IntersectionPicker specific_picker(view, picked_node, ~0, pick_radius, IntersectionPicker::NO_LIMIT);
IntersectionPicker::Hits specific_hits;
if(specific_picker.pick(mouse_x, mouse_y, specific_hits))
    //code...
iyigitel iyigitel
Reply | Threaded
Open this post in threaded view
|

Re: IntersectionPicker problem with FeatureNodes

Very cool krzysief. I was also looking for something like this. Thanks for sharing.

Iskender.
Iskender Yigitel
krzysief krzysief
Reply | Threaded
Open this post in threaded view
|

Re: IntersectionPicker problem with FeatureNodes

No problem ;)