Open Inventor练习-SoElapsedTime引擎作用
来源:互联网 发布:高中数学软件 编辑:程序博客网 时间:2024/05/29 10:15
// 预定义COIN宏#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/SoSeparator.h>int main(int argc, char **argv){SoDB::init();// 初始化SoDB读取iv文件HWND hWnd = SoWin::init(argv[0]);// 产生窗口句柄SoSeparator *pRootSeparator = new SoSeparator;pRootSeparator->ref();// 创建根节点并ref计数SoInput input;if (input.openFile("engine.iv"))// 加载iv文件并读取全部内容{pRootSeparator->addChild(SoDB::readAll(&input));}SoWinExaminerViewer viewer(hWnd);// 创建view窗体显示COIN三维内容viewer.setSceneGraph(pRootSeparator);// 设置显示的根节点viewer.show();// view窗体显示三维内容SoWin::show(hWnd);// windows下显示三维内容viewer.viewAll();// 显示物体全部查看模式SoWin::mainLoop();// 进入显示主循环pRootSeparator->unref();// unref删除节点计数让COIN释放资源return 0;}
一下是01.iv的内容
#Inventor V2.1 asciiSeparator { Transform { rotation 0 0 1 0 = ComposeRotation { axis 0 1 0 angle 0 = ElapsedTime {speed 0.5 } . timeOut } . rotation } DrawStyle { style LINES } Sphere { } }
Transform和ConposeRotation一起结合SoElapsedTime实现自动旋转的功能,等价于SoRotationXYZ的沿轴旋转功能能。
此部分的Open Inventor等价代码如下
// 预定义COIN宏#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/SoSeparator.h>// IV等效代码#include <Inventor/nodes/SoMaterial.h>#include <Inventor/nodes/SoTransform.h>#include <Inventor/nodes/SoCube.h>#include <Inventor/nodes/SoCoordinate3.h>#include <Inventor/nodes/SoIndexedLineSet.h>#include <Inventor/nodes/SoRotation.h>#include <Inventor/engines/SoElapsedTime.h>#include <Inventor/nodes/SoDrawStyle.h>#include <Inventor/nodes/SoSphere.h>#include <Inventor/nodes/SoRotationXYZ.h>int main(int argc, char **argv){SoDB::init();// 初始化SoDB读取iv文件HWND hWnd = SoWin::init(argv[0]);// 产生窗口句柄SoSeparator *pRootSeparator = new SoSeparator;pRootSeparator->ref();// 创建根节点并ref计数SoInput input;if (input.openFile("engine.iv"))// 加载iv文件并读取全部内容{// pRootSeparator->addChild(SoDB::readAll(&input));// IV等效代码SoElapsedTime *pElapsedTime = new SoElapsedTime;pElapsedTime->speed = 0.5f;SoRotationXYZ *pRotationXYZ = new SoRotationXYZ;pRotationXYZ->axis = SoRotationXYZ::Y;pRotationXYZ->angle.connectFrom(&pElapsedTime->timeOut);pRootSeparator->addChild(pRotationXYZ);SoDrawStyle *pDrawStyle = new SoDrawStyle;pDrawStyle->style = SoDrawStyle::LINES;pRootSeparator->addChild(pDrawStyle);pRootSeparator->addChild(new SoSphere);}SoWinExaminerViewer viewer(hWnd);// 创建view窗体显示COIN三维内容viewer.setSceneGraph(pRootSeparator);// 设置显示的根节点viewer.show();// view窗体显示三维内容SoWin::show(hWnd);// windows下显示三维内容viewer.viewAll();// 显示物体全部查看模式SoWin::mainLoop();// 进入显示主循环pRootSeparator->unref();// unref删除节点计数让COIN释放资源return 0;}
显示的效果如下
- Open Inventor练习-SoElapsedTime引擎作用
- Open Inventor练习-一维拖拽器SoTranslate1Dragger
- Open Inventor练习-文件读取
- Open Inventor练习-文件存储
- Open Inventor练习-三维物体选择操作
- Open Inventor练习-传感器(SoFieldSensor)功能
- Open Inventor练习-纹理(SoTexture2)
- 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显示三维场景
- 如何查看进程打开了哪些文件?---linux下的proc文件系统
- 操作符重载
- 输入一个字符串,输出该字符串的最长重复子序列。
- 离线iOS应用的HTML 5制作指南
- struts2.0中struts.xml配置文件详解
- Open Inventor练习-SoElapsedTime引擎作用
- cPanel设置:防盗链/远程MySQL/泛域名解析/禁止IP
- 系统设计中业务规则与系统规则的应用
- 吸塑与吹塑工艺介绍
- 苦逼的日期控件自绘
- SQL Azure 服务器端架构
- popen()函数
- java中使用正则表达式
- JAVA操作Excel文件