Reputation: 11
I need to create a circular geometry using a CircleNode with a very large radius.
I have the problem that, using bathymetric data to show Triton as a wave engine, the geometry goes under the water and is not shown.
I thought about setting NON_CLAMPED as a geometry property, but doing so does not follow the earth's curvature.
I would therefore need the geometry to be Draped to the ground, but with a threshold, i.e. only for height values > 0.
Below is the geometry code
osgEarth::Annotation::Style circleStyle;
circleStyle.getOrCreate<osgEarth::Annotation::PolygonSymbol>()->fill()->color() = Color(Color::Yellow, 1.5);
circleStyle.getOrCreate<osgEarth::Annotation::LineSymbol>()->stroke()->color() = Color(Color::Red, 1.0);
circleStyle.getOrCreate<osgEarth::Annotation::LineSymbol>()->stroke()->width() = 2;
circleStyle.getOrCreate<osgEarth::Annotation::LineSymbol>()->stroke()->stipplePattern() = 0xF0F0; // 0x3333 dotted //0xF0F0 dashed
circleStyle.getOrCreate<osgEarth::Symbology::RenderSymbol>()->lighting() = false;
circleStyle.getOrCreate<osgEarth::Annotation::AltitudeSymbol>()->clamping() = osgEarth::Annotation::AltitudeSymbol::CLAMP_TO_TERRAIN;
circleStyle.getOrCreate<osgEarth::Annotation::AltitudeSymbol>()->technique() = osgEarth::Annotation::AltitudeSymbol::TECHNIQUE_DRAPE;
circleStyle.getOrCreate<osgEarth::Annotation::AltitudeSymbol>()->verticalOffset() = 1.0; // Offset di 5 metri sopra il terreno
circleStyle.getOrCreate<osgEarth::Annotation::AltitudeSymbol>()->binding() = osgEarth::Annotation::AltitudeSymbol::BINDING_VERTEX;
circle = new osgEarth::Annotation::CircleNode();
circle->setName("CERCHIO");
circle->set(
GeoPoint(wgs84, x, y),
Distance(range, Units::METERS),
circleStyle,
Angle(0, Units::DEGREES),
Angle(360, Units::DEGREES),
false);
osg::ref_ptr<osg::StateSet> stateSetCircle = circle->getOrCreateStateSet();
//stateSet->setMode(GL_BLEND, osg::StateAttribute::ON);
stateSetCircle->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
osg::ref_ptr<osg::BlendFunc> blendFunc = new osg::BlendFunc();
blendFunc->setFunction(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
stateSetCircle->setAttributeAndModes(blendFunc, osg::StateAttribute::ON);
osg::ref_ptr<osg::Depth> depth = new osg::Depth();
depth->setWriteMask(true); // Disabilita scrittura nel depth buffer
depth->setFunction(osg::Depth::LEQUAL); // Depth test abilitato
//stateSet->setMode(GL_DEPTH_TEST, true);
stateSetCircle->setAttributeAndModes(depth, osg::StateAttribute::ON);
stateSetCircle->setDefine(OE_LIGHTING_DEFINE, osg::StateAttribute::ON | osg::StateAttribute::PROTECTED);
stateSetCircle->setMode(GL_LIGHTING, osg::StateAttribute::ON | osg::StateAttribute::PROTECTED);
stateSetCircle->setMode(GL_CULL_FACE, osg::StateAttribute::OFF);
//circle->getOrCreateStateSet()->setRenderBinDetails(11, "RenderBin"); // Un valore alto disegna dopo
if (circle != nullptr) {
_mapNode->addChild(circle);
}
Upvotes: 0
Views: 12