OSG入门——绘制地球云图

本文介绍了一个使用osgEarth和相关库来加载并显示地球模型的C++程序示例。该程序通过读取特定文件(如cloudmade.earth)来初始化地球节点,并将其设置为场景的一部分,最终实现在窗口中渲染地球模型。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

</pre><pre>
#include <osg/Group>
#include <osgViewer/Viewer>
#include <osgDB/ReadFile>
#include <osgViewer/api/Win32/GraphicsWindowWin32>
#include <osgEarthAnnotation/RectangleNode>
#include <osgEarthSymbology/Style>
#include <osgEarthSymbology/AltitudeSymbol>

//using namespace osgEarth::Annotation;


#include <iostream>
#ifdef _DEBUG
#pragma comment(lib,"osgDBd.lib");
#pragma comment(lib,"osgViewerd.lib")
#pragma comment(lib,"osgd.lib");
#else
#pragma comment(lib,"osgDB.lib");
#pragma comment(lib,"osgviewer.lib");
#pragma comment(lib,"osg.lib");
#endif

int main()
{
	osg::ref_ptr<osg::Group> root = new osg::Group;
	osgViewer::Viewer myViewer;
	osg::ref_ptr<osg::Node> earth = osgDB::readNodeFile("cloudmade.earth");
	if (!earth.get())  
	{  
		std::cout<<"open file is failed!"<<std::endl;  
		return -1;  
	}  
	root->addChild(earth);
	myViewer.setSceneData(root.get());
	myViewer.realize();  
	myViewer.run();  

}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值