1

I am writing to you after several negative attempts.

I am working with OSGEarth, in particular I cannot set the longitude, latitude and height of the camera for the starting position.

I'm afraid it is associated with the fact that I use the EarthManipulator

So I create the camera:

osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());  
osg::ref_ptr<osg::Camera> camera = new osg::Camera;
camera->setGraphicsContext(gc);
camera->setViewport(new osg::Viewport(0, 0, traits->width, traits->height));
camera->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);

Then, So I create the view to which I pass the EarthManipulator

osg::ref_ptr<osgViewer::Viewer> g_viewer = new osgViewer::Viewer;

osg::Vec3d eye(1110.0, 1110.0, 1110.0);
osg::Vec3d center(10.0, 10.0, 10.0);
osg::Vec3d up(0.0, 1.0, 0.0);

g_viewer->setCamera(camera.get());

EarthManipulator* manip = new EarthManipulator();

manip->setViewpoint(Viewpoint(
    "Home",
    -71.0763, 42.34425, 0,
    // -71.0763, 42.34425, 0,   // longitude, latitude, altitude
    24.261, -21.6, 3450.0), // heading, pitch, range//3450
    4.0);     // duration, 4.0);

g_viewer->setCameraManipulator(manip);

But I can't move from the usual point.

I also tried to work on the EarthMipulator, in particular setting the home position

manip->setHomePosition()

but nothing changes

1 Answers1

2

The method you want is EarthManipulator::setHomeViewpoint:

manip->setHomeViewpoint(Viewpoint(
    "Home",
    -71.0763, 42.34425, 0,   // longitude, latitude, altitude
    24.261, -21.6, 3450.0)); // heading, pitch, range

Hope this helps!