跟进代码。 首先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 =...
使用osgviewer加载查看,发现osgviewer不能正确渲染这个模型(如下图所示)。 怀疑是obj格式与OSG兼容性的问题,尝试使用Blender转换一下这个模型。打开Blender,Import这个模型。由于卫星模型对于默认场景太大了,只能看到一小部分,大部分模型被裁切掉了。 参考下图设置Blender视图的Clip Distance。 这里数字设置大一点,比如50000...
EarthManipulator>mainManipulator=newosgEarth::Util::EarthManipulator;viewer.setCameraManipulator(mainManipulator);viewer.setUpViewInWindow(100,100,800,600);returnviewer.run();} 这里有两个点值得注意,其一是使用了缓存机制,可以在浏览的时候变浏览边生成缓存,所以设置了一个缓存目录;其二是加载了一个底图数据,...
//#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...
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...
("BlueMarble", gdal); map->addLayer(layer); AddVector(map); osgViewer::Viewer viewer; viewer.setSceneData(mapNode); osg::ref_ptr< osgEarth::Util::EarthManipulator> mainManipulator = new osgEarth::Util::EarthManipulator; viewer.setCameraManipulator(mainManipulator); //解决Lines or ...
osgViewerd.lib osgTextd.lib (4)新建cpp文件中输入以下代码: 测试结果: 注意:如果调试时显示计算机中丢失osg130-osgDBd.dll就重启电脑(对的 就是这样) 注:如果提示缺少zlib.dll,这两个dll均可以在OSG依赖的第三方库3rdParty文件夹中可以找到,注意x86与x64选择,将这两个dll拷贝至OSG的bin目录(你加入环境变量...
这段代码首先包含了必要的头文件,然后创建了一个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...