osgearth设置倾斜摄影的代码
时间: 2023-09-17 14:12:39 浏览: 189
以下是一个osgEarth设置倾斜摄影的示例代码:
```
#include <osgEarth/Map>
#include <osgEarth/MapNode>
#include <osgEarth/GeoTransform>
#include <osgEarth/VerticalOffset>
#include <osgEarthUtil/TMS>
#include <osgEarthUtil/Sky>
#include <osgEarthUtil/EarthManipulator>
#include <osgViewer/Viewer>
using namespace osgEarth;
using namespace osgEarth::Util;
int main(int argc, char** argv)
{
// 创建一个地图对象
Map* map = new Map();
// 添加TMS图层
TMSImageLayerOptions layerOptions("My TMS Layer", "http://myserver.com/mytms/{z}/{x}/{y}.jpg");
map->addImageLayer(new TMSImageLayer(layerOptions));
// 创建地图场景
osg::ref_ptr<MapNode> mapNode = new MapNode(map);
// 创建地球变换节点
osg::ref_ptr<GeoTransform> geoTransform = new GeoTransform();
geoTransform->setPosition(osgEarth::GeoPoint(osgEarth::SpatialReference::create("wgs84"), 0, 0, 0, osgEarth::ALTMODE_ABSOLUTE));
// 将地球变换节点添加到地图场景中
osg::ref_ptr<osg::Group> root = new osg::Group();
root->addChild(geoTransform.get());
root->addChild(mapNode.get());
// 设置地球倾斜视图
osg::ref_ptr<osgEarth::Util::EarthManipulator> manip = new EarthManipulator();
manip->setViewpoint(osgEarth::Viewpoint("tilted", 0, -90, 10000000));
osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer();
viewer->setCameraManipulator(manip.get());
// 添加天空和光照
osg::ref_ptr<osgEarth::Util::SkyNode> skyNode = new osgEarth::Util::SkyNode();
skyNode->attach(viewer->getCamera());
viewer->setSceneData(skyNode.get());
// 显示场景
viewer->setSceneData(root.get());
return viewer->run();
}
```
阅读全文