Tessellation problems with large polygons

classic Classic list List threaded Threaded
4 messages Options
David David
Reply | Threaded
Open this post in threaded view
|

Tessellation problems with large polygons

I am trying to draw large extruded polygons, like ones that could cover an entire country.  When my polygons are this large, the lines properly tessellate between vertices but it doesn't look like the top of the polygon does.  It looks like it's cutting through the Earth.

Here's the code where I setup the style and geometry for the feature.

// Style
osgEarth::Symbology::Style shapeStyle;

// Fill Symbol
osgEarth::Symbology::PolygonSymbol* fillSymbol = shapeStyle.getOrCreate<osgEarth::Symbology::PolygonSymbol>();
fillSymbol->fill()->color() = osgEarth::Symbology::Color::White;

// Line Symbol
osgEarth::Symbology::LineSymbol* lineSymbol = shapeStyle.getOrCreate<osgEarth::Symbology::LineSymbol>();
lineSymbol->stroke()->color() = osgEarth::Symbology::Color::Black;
lineSymbol->stroke()->width() = 2.0f;
lineSymbol->tessellation() = 20;

// Render Symbol
osgEarth::Symbology::RenderSymbol* renderSymbol = shapeStyle.getOrCreate<osgEarth::Symbology::RenderSymbol>();
renderSymbol->lighting() = false;

// Altitude Symbol
osgEarth::Symbology::AltitudeSymbol* altSymbol = shapeStyle.getOrCreate<osgEarth::Symbology::AltitudeSymbol>();
altSymbol->clamping() = osgEarth::Symbology::AltitudeSymbol::CLAMP_RELATIVE_TO_TERRAIN;

// Geometry
mpPolygon3D = new osgEarth::Symbology::Polygon();
updatePoints(); // Copy the points into the polygon

// Feature
osgEarth::Features::Feature* feature = new osgEarth::Features::Feature(mpPolygon3D, scene.mapSrs(), shapeStyle);

// Feature Node
mpNode3D = new osgEarth::Annotation::FeatureNode(scene.mapNode(), feature);
mpNode3D->setStyle(shapeStyle);
scene.featureNode()->addChild(mpNode3D);

And this is what it looks like.

Tessellation problem with large polygon

Also, I can't seem to get the polygon to ignore the scene's lighting.  I thought that's what the lighting property of the RenderSymbol would do but setting it to true or false doesn't seem to make any difference.  I need to be able to see the polygons regardless of the lighting on the globe.
David David
Reply | Threaded
Open this post in threaded view
|

Re: Tessellation problems with large polygons

I forgot, elsewhere I'm adding an ExtrusionSymbol to the style and I was setting the flatten property to true.  I removed that property from the ExtrusionSymbol and it looks better.  The top of the polygon is obviously curving with the terrain now, but the terrain still appears to jut through the polygon when it's very large.

My extrusion symbol is defined like this.

osgEarth::Symbology::ExtrusionSymbol* extSymbol = shapeStyle.getOrCreate<osgEarth::Symbology::ExtrusionSymbol>();
extSymbol->height() = extrudeHeight;
extSymbol->heightReference() = osgEarth::Symbology::ExtrusionSymbol::HEIGHT_REFERENCE_Z;

And here's what it looks like now (without the flattening effect).

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

Re: Tessellation problems with large polygons

David,
It's the same problem you originally saw (with flatten = true) -- the triangles making up the "roof" are so large they are passing though the earth.

This is a limitation of the ExtrusionSymbol. A workaround would be to draw the "wall" as one feature (extruded line string), and the "roof" as a separate polygon feature with an altitude offset (AltitudeSymbol::verticalOffset).

Hope this helps.
Glenn Waldron / Pelican Mapping
David David
Reply | Threaded
Open this post in threaded view
|

Re: Tessellation problems with large polygons

I'll come back and revisit this in the next couple of days, but your approach makes sense.  Thanks for the feedback.