osg纹理材质设置

该博客介绍了一段使用osg库为3D球体模型应用材质和纹理的C++代码。首先,创建了一个osgViewer::Viewer,然后通过osg::Geode和osg::Sphere创建了3D球体,并设置了形状drawable。接着,定义了osg::Material来调整材质的环境光、漫射光、光泽度和镜面反射。再通过osg::Texture2D加载并应用了名为'skymap.jpg'的纹理图像。最后,将材质和纹理添加到StateSet,并在osgViewer中显示模型。
摘要由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 <osg/Image>
#include <osg/Texture2D>
#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);
	osg::ref_ptr<osg::Texture2D>texture = new osg::Texture2D();

	geode->addDrawable(shapeDrawable);

	//设置材质
	osg::ref_ptr&l
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值