osgEarth::Symbology::Style in osgEarth 2.10

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

osgEarth::Symbology::Style in osgEarth 2.10

Hello,

I've tested that the osgEarth::Symbology::LineSymbol::Stroke is not working correctly in osgEarth 2.10.
I must supply a stipple pattern to the osgEarth::Features::Feature that will contain the geometry otherwise no outline will appear. Here is the code I've used to test:

    //Code to create an osgEarth::MapNode from .earth file (either 2D/3D)
    //Code to create an osgViewer::Viewer with an osgEarth::Util::EarthManipulator and set its scene data to the osgEarth::MapNode
    ...

    osgEarth::Symbology::Style polyStyle;
    polyStyle.getOrCreate<osgEarth::Symbology::PolygonSymbol>()->fill()->color() = osg::Vec4(1.0, 1.0, 1.0, 1.0);
    polyStyle.getOrCreate<osgEarth::Symbology::LineSymbol>()->stroke()->color() =  osg::Vec4(1.0, 0.0, 0.0, 1.0);
    polyStyle.getOrCreate<osgEarth::Symbology::LineSymbol>()->stroke()->width() = 5.0f;

    osgEarth::Geometry* geom = new osgEarth::Geometry;
    geom->push_back(0, 0, 1000);
    geom->push_back(5, 0, 1000);
    geom->push_back(5, 5, 1000);
    geom->push_back(0, 5, 1000);
    geom->close();

    osgEarth::Features::Feature* feature = new osgEarth::Features::Feature(geom, mapNode->getMapSRS()->getGeographicSRS(), polyStyle);

    osgEarth::Annotation::FeatureNode* featureNode = new osgEarth::FeatureNode(feature);

    mapNode->addChild(featureNode);
   
    viewer->frame();


Expected: To see a white square with a thin red solid border whose left corner is centered at lat: 0, lon: 0 with a width of 5 latitude and a height of 5 longitude.

Observed: Seeing a white square whose left corner is centered at lat: 0, lon: 0 with a width of 5 latitude and a height of 5 longitude.

Note: Switching the Qt .pro file's include paths back and forth from 2.9 and 2.10 install folders prove the behavior is only present in the 2.10 build and not the 2.9 build.

Things I've tried:

1. Setting the Stroke's stipple value to 0.
2. Setting the PolygonStyle's outline to be true. (Should already be true by default according to .h comments).
3. Adding it to a map node constructed for both a 2D projection and 3D projection of the earth has no visible difference.
4. Clamping the map node to the terrain.
5. Draping the map node to the terrain.
6. Tessellating the geometry.

P.S: I've also noticed when I do supply a stipple pattern, if I have added the Drape/Clamp style to the AltitudeSymbol, then the visible Stroke's stipple pattern does not clamp with the geometry. Also, the stipple pattern seems to behave strangely in 2.10, as if it looks too thick and artifacts strangely (looks extremely lossy/aliased) sometimes when any drag event occurs with Draping enabled on a 2D projected map, not a 3D map. This leads me to believe that something was changed regarding the Stroke from 2.9 to 2.10 because I believe this was working previously too, however I will update this fact after confirmation tomorrow.
Blanky Blanky
Reply | Threaded
Open this post in threaded view
|

Re: osgEarth::Symbology::Style in osgEarth 2.10

The solution was relatively simple. Someone else's post on the forum pointed me to the correct direction.

1) You must #include <osgEarth/GLUtils>
2) You must call the static function from this include on your viewer's camera like so:

osgViewer::Viewer view;
osgEarth::GLUtils::setGlobalDefaults(view.getCamera()->getOrCreateStateSet());

That's it.
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: osgEarth::Symbology::Style in osgEarth 2.10

Bingo. Someone should really put this in the FAQ...
Glenn Waldron / Pelican Mapping