osg、osgearth教程VS2017
⼀、osg和osgearth关系
osg即OpenSceneGraph,是⼀个开源图形开发包,osgearth是⼀个针对数字地图的库,可以实现类似⾕歌地球的功能,并且图像数据在本地,属于对osg的⼆次开发,因此使⽤osgearth时,⾸先要配好osg的环境。
⼆、环境配置⽅法
1. 使⽤别⼈编译好的lib、bin和include源⽂件,在VS2017⾥配好环境即可,此⽅法最快
2. ⾃⼰编译osg、osgearth,然后⽣成lib、bin等⽂件,编译过程⼗分漫长,编译⼀次需要5个⼩时
三、配置过程
1. 使⽤别⼈编译好的lib和bin⽂件
⽂件夹内代码如上,lib和bin⾥⾯包含osg和osgearth编译好的全部⽂件,data为⼀些模型数据,include为头⽂件源码
接下来打开vs2017,创建⼀个空项⽬
然后粘贴此代码
#include <Windows.h>
#include <osgViewer/Viewer>
#include <osgDB/ReadFile>
elisha
贾斯汀 汀布莱克#include <osgEarthUtil/EarthManipulator>
store怎么读using namespace std;
itsucks
int main()
{
osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer;
河外星系
//操作器
osg::ref_ptr<osgEarth::Util::EarthManipulator> earthManipulator = new osgEarth::Util::EarthManipulator;
//设置相机操作器
viewer->tCameraManipulator(earthManipulator);
viewer->tSceneData(osgDB::readNodeFile("clear.earth"));
viewer->run();
return 0;
}
代码⾥⾯只需要改两个⽂件路径即可,第⼀个是地图缓存⽂件⽬录,可以随意设置,我设置在项⽬⽂件;第⼆个路径是所下载⽂件夹下data
下world.tif的路径,也就是本地地图⽂件路径
放纵是什么意思
代码⾥⾯红⾊警告表⽰include源⽂件、lib、bin等环境没有配好,右键项⽬,点击属性
jels因为配置的是relea版本,所以库⽬录要选lib下的relea⽂件夹,如果配置debuge版的话,就选lib下的debuge⽂件夹路径接下来点击链接器-->输⼊-->附加依赖项,⾥⾯填relea下所有lib⽂件名称
OpenThreads.lib
osg.lib
osgAnimation.lib
osgDB.lib
osgEarth.lib osgEarthAnnotation.lib osgEarthFeatures.lib osgEarthSilverLining.lib osgEarthSplat.lib osgEarthSymbology.lib osgEarthTriton.lib osgEarthUtil.lib
osgFX.lib
dhtmlosgGA.lib
osgManipulator.lib osgParticle.lib osgPrentation.lib osgShadow.lib
apply update from cacheosgSim.lib
童趣的翻译
osgTerrain.lib
osgText.lib
osgUI.lib
osgUtil.lib
osgViewer.lib
osgVolume.lib
osgWidget.lib
将这些lib⽂件名称填⼊附加依赖项