Open Inventor练习-纹理(SoTexture2)

Open Inventor显示纹理相对OpenGL简单许多,SoTexture2节点可以非常方便的完成复杂的纹理操作,一下是一个纹理演示的例子,虽然比较简单,但是纹理的功能已经表现出来了。代码如下

#define COIN_DLL #define SOWIN_DLL // 加载COIN库文件 #ifdef _DEBUG #pragma comment(lib, "SoWin1d.lib") #pragma comment(lib, "Coin3d.lib") #else #pragma comment(lib, "SoWin1.lib") #pragma comment(lib, "Coin3.lib") #endif // 添加COIN头文件-Window操作显示库和节点库 #include <Inventor/Win/SoWin.h> #include <Inventor/Win/viewers/SoWinExaminerViewer.h> #include <Inventor/nodes/SoCube.h> #include <Inventor/nodes/SoRotor.h> #include <Inventor/nodes/SoTexture2.h> #include <Inventor/nodes/SoSeparator.h> int main(int argc, char ** argv) { HWND mainwin = SoWin::init(argc, argv, argv[0]); SoSeparator * root = new SoSeparator; root->ref(); SoRotor * rotor = new SoRotor; rotor->rotation.setValue(SbVec3f(0, 0, 1), 1.5707963f); rotor->speed.setValue(0.05f); SoTexture2 * texture = new SoTexture2; texture->filename.setValue("elf.tga"); SoCube * cube = new SoCube; root->addChild(rotor); root->addChild(texture); root->addChild(cube); SoWinExaminerViewer * eviewer = new SoWinExaminerViewer(mainwin); eviewer->setSceneGraph(root); eviewer->setDecoration(FALSE); eviewer->setTitle("a simple textured cube"); eviewer->show(); SoWin::show(mainwin); SoWin::mainLoop(); delete eviewer; root->unref(); return 0; }
IV文件如下

#Inventor V2.1 ascii Separator { Rotor { rotation 0 0 1 0 speed 0.05 } Texture2 { filename "elf.tga" } Cube { } }
贴图纹理文件可以在此链接下载

http://download.csdn.net/detail/soprettyzz/2660647


运行结果如下


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值