CircleNode floating in the air

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

CircleNode floating in the air

Hi, i am trying to draw a circle on the surface of the earth, but my code makes it floating in the air, any suggestions how to change it?

osgEarth::Symbology::Style style;
                osgEarth::Symbology::LineSymbol* linesymb = style.getOrCreate<osgEarth::Symbology::LineSymbol>();
                linesymb->stroke()->color() = color;
                linesymb->stroke()->width() = width;
                linesymb->stroke()->widthUnits() = osgEarth::Units::PIXELS;
                linesymb->tessellation() = 3;
               
               
                osgEarth::Symbology::AltitudeSymbol* altitude = style.getOrCreate<osgEarth::Symbology::AltitudeSymbol>();
                altitude->clamping() = osgEarth::Symbology::AltitudeSymbol::CLAMP_TO_TERRAIN;
                altitude->binding() = osgEarth::Symbology::AltitudeSymbol::BINDING_VERTEX;
               

                osgEarth::Annotation::CircleNode * circleNode = new osgEarth::Annotation::CircleNode(map_node,
                                                                                        position, osgEarth::Linear(radius, osgEarth::Units::METERS), style);
krzysief krzysief
Reply | Threaded
Open this post in threaded view
|

Re: CircleNode floating in the air

solved the problem, in case somebody wandered:

shared_ptr<osgEarth::Symbology::GeometryFactory> geometry_factory = make_shared<osgEarth::Symbology::GeometryFactory>(map_node->getMapSRS());
                osgEarth::Geometry* geometry = geometry_factory->createCircle(position.vec3d(), osgEarth::Linear(radius, osgEarth::Units::METERS));
       
                osgEarth::Features::Feature * feature = new osgEarth::Features::Feature(geometry, map_node->getMapSRS());
       
                osgEarth::Symbology::LineSymbol * line = feature->style()->getOrCreate<osgEarth::Symbology::LineSymbol>();
                line->stroke()->color() = color;
                line->stroke()->width() = width;
                line->stroke()->widthUnits() = osgEarth::Units::PIXELS;

                //maybe it improves performance
                line->tessellation() = 3;

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