跟进代码。 首先osgearthviewer程序加载earth的方式分为两种: 1.根据earth文件(load方式) 2.使用SDK加载(create方式) 我们使用earth文件是load方式,直接看load函数,定位到这个位置 //load an earth file, and support all or our example command-line options//and earth file <external> tagsosg::Node* node =...
跟进代码。 首先osgearthviewer程序加载earth的方式分为两种: 1.根据earth文件(load方式) 2.使用SDK加载(create方式) 我们使用earth文件是load方式,直接看load函数,定位到这个位置 //load an earth file, and support all or our example command-line options//and earth file <external> tagsosg::Node* node =...
打开cmd,输入osgearth_viewer clouds.earth观察会不会出现下面的图,出现即表示编译成功 欢迎关注我的公众号: 编程技术与生活(ID:hw_cchang)
这段代码首先包含了必要的头文件,然后创建了一个Viewer对象。通过调用Viewer的setSceneData方法,并传入osgDB::readNodeFile函数的结果,我们可以加载并设置场景数据。最后,调用Viewer的run方法开始渲染和显示场景。在这个例子中,我们假设存在一个名为"tree.osg"的场景文件,它包含了构建场景所需的各种节点和属性。4 ...
#include<Windows.h>#include<iostream>#include<string>#include<osgViewer/Viewer>#include<osgDB/ReadFile>#include<osgEarth/MapNode>#include<osgEarth/ImageLayer>#include<osgEarthDrivers/gdal/GDALOptions>#include<osgEarthDrivers/cache_filesystem/FileSystemCache>#include<osgEarthDrivers/feature_ogr/OGRFeatur...
//#include<osgViewer/Viewer>#include<osgEarth/Notify>#include<osgEarth/EarthManipulator>#include<osgEarth/MapNode>#include<osgEarth/Threading>#include<osgEarth/ShaderGenerator>#include<osgDB/ReadFile>#include<osgGA/TrackballManipulator>#include<osgUtil/Optimizer>#include<iostream>#include<osgEarth/Metrics...
viewer.setCameraManipulator(new EarthManipulator); // Map is datamodel for collection of layers. osg::ref_ptr<osgEarth::Map> rootMap = new osgEarth::Map ; //GeoTiff Layer string worldTifFilename = "D:/codes/osgEarth-Projects/osgearth3.4/data/world.tif"; ...
EarthManipulator>mainManipulator=newosgEarth::Util::EarthManipulator;viewer.setCameraManipulator(mainManipulator);viewer.setUpViewInWindow(100,100,800,600);returnviewer.run();} 这里有两个点值得注意,其一是使用了缓存机制,可以在浏览的时候变浏览边生成缓存,所以设置了一个缓存目录;其二是加载了一个底图数据,...
mViewer = new osgViewer::Viewer; osg::ref_ptr<osg::Node> mp = osgDB::readNodeFile("../../earthfile/china-simple.earth"); mRoot->addChild(mp); 1. 2. 3. 4. 5. 6. 7. 8. 9. (2)第二种方式就是通过osgEarth的API添加,一般地,添加影像所使用的驱动类型为GDAL,其类为osgEarth::Dr...
osgEarth::Viewpoint vp; osgEarth::GeoPoint newPoint(map->getSRS(), 108.9594, 34.2196, 0); vp.focalPoint() = newPoint; vp.heading() = 0; vp.pitch() = -90; vp.range() = 1000; mainManipulator->setViewpoint(vp); viewer.setUpViewInWindow(100, 100, 800, 600); return viewer.run...