1

经过几次消极的尝试后,我给你写信。

我正在使用OSGEarth,特别是我无法为起始位置设置相机的经度、纬度和高度。

恐怕这与我使用EarthManipulator的事实有关

所以我创建了相机:

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);

然后,我创建了将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);

但我不能改变通常的观点。

我还尝试在 EarthMipulator 上工作,特别是设置起始位置

manip->setHomePosition()

但没有任何改变

4

1 回答 1

2

你想要的方法是 EarthManipulator::setHomeViewpoint:

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

希望这可以帮助!

于 2020-02-05T12:04:21.640 回答