EarthManipulator

classic Classic list List threaded Threaded
6 messages Options
Adam Adam
Reply | Threaded
Open this post in threaded view
|

EarthManipulator

This might just be my incompetence with OSG, but I can't seem to get the EarthManipulator to zoom to a point.

         osg::ref_ptr<osgEarthUtil::EarthManipulator> manip = new osgEarthUtil::EarthManipulator();
         osgEarthUtil::Viewpoint viewpoint(osg::Vec3d(40.78,-73.96, 0), 0, 0, 1000);
         fprintf(stderr, (viewpoint.isValid())? "VALID POINT!\n": "INVALID POINT!\n");
         manip->setViewpoint(viewpoint);
         _viewer.setCameraManipulator(manip);

It prints valid point every time, but the camera doesn't change.  I'm trying to have it zoom to NYC at the start, but it doesn't appear to do anything.
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: EarthManipulator

Adam,

You need to set the viewpoint after assigning the manipulator to the viewer (and after assigning the viewer's scene data as well). I have never tried setting a viewpoint before starting the viewer's frame loop; maybe it will work, but if not, call setViewpoint after starting the viewer (using an eventhandler or an update callback or something - see osgearth_simple).

Regarding your viewpoint: The focal point it x,y,z; so you probably want to swap your lat and long (since lat is y and long is x). You also have a pitch of 0, which means your camera is parallel to the ground; -90 would be straight down for example.

Glenn
Glenn Waldron / Pelican Mapping
Adam Adam
Reply | Threaded
Open this post in threaded view
|

Re: EarthManipulator

Glenn,

Thanks!  And, it looks like setting the viewpoint before the frame loop does not work (not really a problem).  Thanks for the viewpoint tip, we have 1 interface that does (lat, long, alt) and another that does (long, lat, alt) so I'm always mixing them up.  Everything looks good now, thanks.

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

Re: EarthManipulator

Adam, I put in a patch that should allow you to set the Viewpoint before the frame loop starts. Give it a try. I have not actually tested it myself yet :)

Glenn
Glenn Waldron / Pelican Mapping
Adam Adam
Reply | Threaded
Open this post in threaded view
|

Re: EarthManipulator

Sorry it's a week of spreadsheets and diagrams, I'll give it a try next week.  Thanks though, it should help later on.
Adam Adam
Reply | Threaded
Open this post in threaded view
|

Re: EarthManipulator

In reply to this post by gwaldron
      osg::ref_ptr<osgEarthUtil::EarthManipulator> manip = new osgEarthUtil::EarthManipulator();
      _viewer.setCameraManipulator(manip);

      osgEarthUtil::Viewpoint viewpoint(osg::Vec3d(-73.96, 40.78, 0), 0, -90, 100000);
      manip->setViewpoint(viewpoint, 100);

      _viewer.realize();

Works great!  Thanks again Glenn.