[osg-users] World to local coordinates

Robert Osfield robert.osfield at gmail.com
Fri Nov 11 00:40:57 PST 2016


On 11 November 2016 at 07:01, Rambabu Repaka <ramboram488 at gmail.com> wrote:
> I saw the osg/CoordinateSystemNode but iam unable to to locate the model according to latitude and longitude readings.Please share code if anybody knows.

You have access to all the source code you need - the
OpenSceneGraph/examples directory contains over 170 examples, what is
missing is your effort at searching for relevant materials.

I am not going to give you the answer as you need to develop the skill
at finding answers without needing the community to hand hold every
line of code.

You've been given the hint EllipsoidModel so go and do a search in the
OSG examples for usage of this class i.e.

cd OpenSceneGraph/examples
grep EllipsoidModel */*.cpp

You'll get:

osgautocapture/osgautocapture.cpp:
csn->getEllipsoidModel()->convertLatLongHeightToXYZ(lat, lon, alt,
eye.x(), eye.y(), eye.z());
osgfadetext/osgfadetext.cpp:    csn->setEllipsoidModel(new
osg::EllipsoidModel());
osgfadetext/osgfadetext.cpp:osgText::Text*
createText(osg::EllipsoidModel* ellipsoid, double latitude, double
longitude, double height, const std::string& str)
osgfadetext/osgfadetext.cpp:osg::Node*
createFadeText(osg::EllipsoidModel* ellipsoid)
osgfadetext/osgfadetext.cpp:
csn->addChild(createFadeText(csn->getEllipsoidModel()));
osggpx/osggpx.cpp:    osg::ref_ptr<osg::EllipsoidModel> em = new
osg::EllipsoidModel;
osggpx/osggpx.cpp:    osg::ref_ptr<osg::EllipsoidModel> em = new
osg::EllipsoidModel;
osggpx/osggpx.cpp:    osg::ref_ptr<osg::EllipsoidModel> em = new
osg::EllipsoidModel;
osgintersection/osgintersection.cpp:    //osg::EllipsoidModel* em =
csn ? csn->getEllipsoidModel() : 0;
osgmultitexturecontrol/osgmultitexturecontrol.cpp:
osg::EllipsoidModel* em = csn->getEllipsoidModel();
osgposter/osgposter.cpp:    csn->getEllipsoidModel()->convertLatLongHeightToXYZ(
osgsimulation/osgsimulation.cpp:    csn->setEllipsoidModel(new
osg::EllipsoidModel());
osgsimulation/osgsimulation.cpp:                osg::EllipsoidModel*
ellipsoid = csn->getEllipsoidModel();

This should give you plenty of code to look at.  Run these examples
and see if any function in the way you want.

Also have a look at the CoordiateSystemNode and ElipsoidModel headers,
there are methods that do exactly what you need, you just need to be
able to read C++.

Spend the time with these headers and examples and you'll learn a lot
about these particular classess, but even more important you'll
develop your skill as programmer, a key one is being able to
understand 3rd party code.

Robert.



More information about the osg-users mailing list