例子来源于freesouth的视频,但是视频里面的文件好多都找不到所以写一个博文记录下实现了类似的功能
首先在存放模型的文件夹内新建一个cande.earth文件,.earth文件实际上是一个xml文件。
然后,使用notepad++打开
代码中具体的标签含义可以在osgEarth的官网上面查询,过程中使用到了proj4库、gdal库以及osg
<?xml version="1.0" encoding="GB2312" ?>
<map>
<profile>
<srs>+proj=latlong +a=6610000 +b=6600000</srs>
</profile>
<image driver="gdal" name="world-tiff">
<url>../data/world.tif</url>
</image>
<image name="test" driver="osg">
<url>../data/cloud_combined_2048.jpg</url>
<profile>global-geodetic</profile>
<luminance_to_rgba>true</luminance_to_rgba>
</image>
<skirt_ratio>0.1</skirt_ratio>
<sample_ratio>0.5</sample_ratio>
</map>
保存后,打开cmd,输入
osgviewer cande.earth
或者
osgearth_viewer cande.earth
就可以看到如下的画面,如此神秘,但是又好简单。按键盘F可以实现窗口模式和全屏的切换,按w可以查看模型的网格grid以及节点vertex。