osgearth学习笔记1:地球节点构建

【准备记录osgearth学习过程,欢迎各位看官留言交流评论~】

osgEarth场景显示主要有4个步骤
1、构建earth文件,EarthNode
2、创建osgViewer
3、设置Earth操作器
4、设置场景参数

一、earth文件准备

<!-- 
osgEarth Sample - GDAL Driver
Demonstrates the simplest possible use of the GDAL driver to load a GeoTIFF image.
-->

<map>
    <image name="World GeoTIFF" driver="gdal">
        <url>../data/world.tif</url>
    </image>
</map>

这是一个最简单的earth文件,只有tif格式的离线地球形状,后期可以根据需要添加影像、地形、标注等数据。

二、地球节点加载

    m_viewer = new osgViewer::Viewer;
	m_viewer->setThreadingModel(m_viewer->SingleThreaded);
	//m_viewer->setRunFrameScheme(m_viewer->ON_DEMAND);
	auto earthManipulator = new osgEarth::Util::EarthManipulator();
	// 修改鼠标滚轮放大缩小地图的方式
	earthManipulator->getSettings()->bindScroll(osgEarth::Util::EarthManipulator::ACTION_ZOOM_IN, osgGA::GUIEventAdapter::SCROLL_UP);
	earthManipulator->getSettings()->bindScroll(osgEarth::Util::EarthManipulator::ACTION_ZOOM_OUT, osgGA::GUIEventAdapter::SCROLL_DOWN);
	m_viewer->setCameraManipulator(earthManipulator);

	m_root = new osg::Group;
	m_earthNode = osgDB::readNodeFile((QApplication::applicationDirPath() + "/data/simple.earth").toStdString().c_str());
	//m_earthNode = osgDB::readNodeFile("D:/OSE/OSGEarthSDK/earthFiles/myearth.earth");
	m_root->addChild(m_earthNode);
	m_viewer->setSceneData(m_root);

三、结果展示

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值