osg 网格显示球体

该博客主要展示了如何使用osg库在C++中创建一个3D球体,并通过设置材质使其呈现红色。同时,它还演示了如何启用显示网格的功能,允许用户按'w'键在视图中以网格模式查看球体。
摘要由CSDN通过智能技术生成
#pragma comment(lib,"OpenThreadsd.lib")
#pragma comment(lib,"osgViewerd.lib")
#pragma comment(lib,"osgDBd.lib")
#pragma comment(lib,"osgd.lib")
#pragma comment(lib,"osgGAd.lib")

#include <osgViewer/Viewer>
#include <osgDB/ReadFile>
#include <osg/Node>
#include <osg/Material>
#include <osg/ShapeDrawable>
#include <osg/StateSet>
#include <osgGA/StateSetManipulator>	//网格显示头文件

int main()
{

	osg::ref_ptr<osgViewer::Viewer>viewer = new osgViewer::Viewer();
	osg::ref_ptr<osg::Geode>geode = new osg::Geode();
	osg::ref_ptr<osg::Sphere>sphere = new osg::Sphere(osg::Vec3(0,0,0),2.0);
	osg::ref_ptr<osg::ShapeDrawable> shapeDrawable = new osg::ShapeDrawable(sphere);
	geode->addDrawable(shapeDrawable);
	osg::ref_ptr<osg::Material>material = new osg::Material();
	material->setAmbient(osg::Material::FRONT_AND_BACK,osg::Vec4(1.0,0,0
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值