i want to draw sphere on map,but not display,what is wrong?

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

i want to draw sphere on map,but not display,what is wrong?

my code,

        osg::Vec3d pt;
        _mapNode->getMapSRS()->getEllipsoid()->convertLatLongHeightToXYZ(osg::inDegrees(20.0), osg::inDegrees(20.0), 10000, pt[0], pt[1], pt[2]);

        osg::Sphere *cone = new osg::Sphere(pt, 1000);
        osg::ShapeDrawable *shapeDrawable = new osg::ShapeDrawable(cone);
        osg::Geode *geode = new osg::Geode;
        geode->addDrawable(shapeDrawable);

        osg::Group *group = new osg::Group;
        group->addChild(geode);

        _rootNode->addChild(group);

thank first.
Josiah425 Josiah425
Reply | Threaded
Open this post in threaded view
|

Re: i want to draw sphere on map,but not display,what is wrong?

You may want to place your geode in a GeoPosition node to give it the position at which to place it.  Make sure your _rootNode is a child of or is the _mapNode.  Then insert the GeoPosition node as a child of the _mapNode
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: i want to draw sphere on map,but not display,what is wrong?

In reply to this post by qing
qing,
Your code works fine under osgEarth 2.10 / OSG 3.6 (assuming you are using a geocentric map).

Side note: ShapeDrawables will render, but they are fixed-function only; so they will not be able to accept lighting or any other shader-based features in osgEarth.
Glenn Waldron / Pelican Mapping