Open Inventor练习-纹理(SoTexture2)
来源:互联网 发布:js基本数据类型有几种 编辑:程序博客网 时间:2024/06/06 01:19
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 asciiSeparator { Rotor { rotation 0 0 1 0 speed 0.05 } Texture2 { filename "elf.tga" } Cube { }}
贴图纹理文件可以在此链接下载
http://download.csdn.net/detail/soprettyzz/2660647
运行结果如下
- Open Inventor练习-纹理(SoTexture2)
- Open Inventor练习-传感器(SoFieldSensor)功能
- Open Inventor练习-一维拖拽器SoTranslate1Dragger
- Open Inventor练习-文件读取
- Open Inventor练习-文件存储
- Open Inventor练习-SoElapsedTime引擎作用
- Open Inventor练习-三维物体选择操作
- Open Inventor练习-SoWinExaminerViewer的继承演示
- Open Inventor练习-iv文件读写显示1
- Open Inventor练习-iv文件读写显示2
- Open Inventor练习-iv文件读写显示3
- Open Inventor练习-iv文件读写显示4
- Open Inventor练习-SoEventCallback,SoKeyboardEvent键盘事件(红绿灯)
- Open Inventor练习-SoRayPickAction和SoMouseButtonEvent点选操作
- Open Inventor练习-SoSelection三维场景中查找功能
- Open Inventor练习-SoSelection节点下三维物体选择功能
- Open Inventor练习-SoWin中SoWinExaminerViewer显示三维场景
- Open Inventor练习-SoWin中SoWinRenderArea显示三维场景
- c语言 学生管理系统(数组实现)
- 常用禁止缓存的四种方法
- HT 相关
- iphone之发布版本的时候移除NSLog输出的方法
- 命令行菜单
- Open Inventor练习-纹理(SoTexture2)
- C#通过抓包模拟网站用户登录
- WinCE 读取ico文件
- VS+++opencv++MFC++数米粒【计算联通区域的个数及联通区域内像素的个数】
- linux内核编译错误记录
- Android开发之多线程处理、Handler详解
- C#原生邮件发送+发送日志记录
- C++指针探讨 (一)
- Windows 7 starting with a temporary profile