Ugly rectangle corners

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

Ugly rectangle corners

Hi, i am using this code to create a rectangle:

ref_ptr<osgEarth::Geometry> geometry = geometry_factory->createRectangle(
                position.vec3d(),
                osgEarth::Linear(rect_width, osgEarth::Units::METERS),
                osgEarth::Linear(rect_height, osgEarth::Units::METERS)
        );

        ref_ptr<Features::Feature> feature = new osgEarth::Features::Feature(geometry, mapNode->getMapSRS());
       
        ref_ptr<Symbology::LineSymbol> line = feature->style()->getOrCreate<Symbology::LineSymbol>();
        line->stroke()->color() = color;
        line->stroke()->width() = width;
        line->stroke()->widthUnits() = osgEarth::Units::PIXELS;
       
        ref_ptr<Annotation::FeatureNode> featureNode = new osgEarth::Annotation::FeatureNode(mapNode, feature);

but the edges of it are very ugly, not round nor sharp, just like in the picture below:

is there any way to make it rounded?
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: Ugly rectangle corners

krzysief,

If you use a real-world stroke width (like 100km) you will get rounded corners. You can also control the corners/caps with the stroke.lineJoin and stroke.lineCap properties.

With a pixel-width stroke you will get OpenGL lines (what you see now) unless you are using osgEarth 2.10, in which case you will get mitered corners.

Glenn Waldron / Pelican Mapping