Picking FeatureNode with ModelSymbol

classic Classic list List threaded Threaded
6 messages Options
Tension Tension
Reply | Threaded
Open this post in threaded view
|

Picking FeatureNode with ModelSymbol

I'm using RTTPicker for picking nodes, and it's working fine with most featurenodes, except ones with modelsymbol (and no other polygon/linesymbol). For example i have area filled with trees, and i can't pick it. If i set some linesymbol/polygonsymbol to my style, i can pick it if i click on polygon/line, but not model.
Also some observersion: if i use this features/styles within FeatureModelLayer instead of making them FeatureNode, i can pick them. Maybe i need to set some property to featurenode?

osgEarth 3.0 + osg 3.6.3

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

Re: Picking FeatureNode with ModelSymbol

Are you creating your FeatureNode in earth file or in code?

If code, you will need to tell your object index to tag the node for selection. This happens automatically when loading it from an earth file.

osgEarth::Registry::objectIndex()->tagNode(featureNode, featureNode);
Glenn Waldron / Pelican Mapping
Tension Tension
Reply | Threaded
Open this post in threaded view
|

Re: Picking FeatureNode with ModelSymbol

This post was updated on .
From code. Yes, i know about tagNode. If I didn’t do that, I wouldn’t be able to pick other featurenodes (or same nodes with added polygon/linesymbol). But my point is the problem only with featurenodes with modelsymbol and without line/polygon symbols.

So assume i have style with altitudesymbol and modelsymbol and feature with polygon geometry, so this models would fill my polygon (or just single point for single model). In this case, i can't pick (by clicking on model) featurenodes created with this style/feature. If i add a polygon/line symbol, i can pick it (by clicking on polygon/line, not model). Also, in this case, basic shader for "picked" indication (like in osgearth_pick application) only works for polygon/lines and not for models.

I will try to do the same using earth file later.
Tension Tension
Reply | Threaded
Open this post in threaded view
|

Re: Picking FeatureNode with ModelSymbol

Same thing with earth file opened by osgearth_pick. Example:

<map version="2">

    <GDALImage name="world-tiff">
        <url>../data/world.tif</url>
    </GDALImage>

    <annotations name="Annotations: FeatureNode">    
        <feature name="Forest">
            <srs>wgs84</srs>
            <geometry>
                POLYGON((-159.5 25.45, -159.5 25.5, -159.45 25.5))
            </geometry>
            <style type="text/css">
                altitude-clamping:   terrain;
                altitude-technique:  map;
                model:               "../data/tree.ive";
                model-placement:     random;
                model-scale:         20;
            </style>
        </feature>
    </annotations>
                   
    <viewpoints>
        <viewpoint name="FeatureNode" heading="-120" height="0" lat="25.5" long="-159.45" pitch="-25" range="5000"/>
    </viewpoints>
</map>

If you add fill or stroke options, you would be able to pick it, but only by hover your cursor over polygon/line, but not over model.
Tension Tension
Reply | Threaded
Open this post in threaded view
|

Re: Picking FeatureNode with ModelSymbol

In reply to this post by Tension
Hi!

I guess i found the solution. When you construct featureNode, you need to pass GeometryCompileOptions with instancing = false (default = true). Something like this:

GeometryCompilerOptions geomOpt;
geomOpt.instancing() = false;
osg::ref_ptr<FeatureNode> featureNode = new FeatureNode(f, style, geomOpt, styleSheet);
ObjectID index = Registry::objectIndex()->tagNode(featureNode, featureNode);

After that, i can pick my featureNodes with modelsymbols!

Is there any reason why i should enable draw-instancing? Can somebody explain what this option actually do? And does this option have any effect in features without modelsymbol?

Thanks.


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

Re: Picking FeatureNode with ModelSymbol

Hi Tension,
Good find. That is a bug if you want to log it in GitHub.

Instancing is just a performance thing; it will render faster when you have a large number of objects.
Glenn Waldron / Pelican Mapping