Open Inventor显示区域设置SoReoriganizeAction
来源:互联网 发布:猫鼠游戏真实事件 知乎 编辑:程序博客网 时间:2024/05/19 16:33
The code below is an example of a program that applies an SoReorganizeAction on a scene graph, converting all shapes into shapes that can be rendered using vertex array or VBO rendering.
#include <Inventor/SoDB.h> #include <Inventor/nodes/SoSeparator.h> #include <Inventor/nodes/SoCoordinate3.h> #include <Inventor/nodes/SoCoordinate4.h> #include <Inventor/nodes/SoNormal.h> #include <Inventor/nodes/SoTextureCoordinate2.h> #include <Inventor/nodes/SoSeparator.h> #include <Inventor/actions/SoWriteAction.h> #include <Inventor/actions/SoSearchAction.h> #include <Inventor/errors/SoDebugError.h> #include <Inventor/nodes/SoShapeHints.h> #include <Inventor/SoInput.h> #include <Inventor/SoOutput.h> #include <Inventor/SoInteraction.h> #include <Inventor/actions/SoReorganizeAction.h> #include <cassert> #include <cstdio> static void strip_node(SoType type, SoNode * root) { SoSearchAction sa; sa.setType(type); sa.setSearchingAll(TRUE); sa.setInterest(SoSearchAction::ALL); sa.apply(root); SoPathList & pl = sa.getPaths(); for (int i = 0; i < pl.getLength(); i++)
{ SoFullPath * p = (SoFullPath*) pl[i]; if (p->getTail()->isOfType(type))
{ SoGroup *g = (SoGroup*)p->getNodeFromTail(1); g->removeChild(p->getIndexFromTail(0)); } } sa.reset(); } int main(int argc, char ** argv ) { if (argc < 3) { fprintf(stderr,"Usage: reorganize <infile> <outfile> [nostrip]/n"); return -1; } SbBool strip = TRUE; if (argc > 3) { if (strcmp(argv[3], "nostrip") == 0) strip = FALSE; else { fprintf(stderr,"Usage: reorganize <infile> <outfile> [nostrip]/n"); return -1; } } SoDB::init(); SoInteraction::init(); SoInput input; SbBool ok = input.openFile(argv[1]); if (!ok) { fprintf(stderr,"Unable to open file./n"); return -1; } SoSeparator * root = SoDB::readAll(&input); SbBool vrml1 = input.isFileVRML1(); SbBool vrml2 = input.isFileVRML2(); if (vrml2) { fprintf(stderr,"VRML2 not supported yet/n"); return -1; } if (!root) { fprintf(stderr,"Unable to read file./n"); return -1; } root->ref(); fprintf(stderr,"Applying SoReorganizeAction..."); SoReorganizeAction reorg; reorg.apply(root); fprintf(stderr,"done/n"); SoOutput out; if (out.openFile(argv[2])) { if (strip) { // strip coord3, texcoord and normal nodes fprintf(stderr,"stripping old nodes from scene graph/n"); strip_node(SoCoordinate3::getClassTypeId(), root); strip_node(SoCoordinate4::getClassTypeId(), root); strip_node(SoNormal::getClassTypeId(), root); strip_node(SoTextureCoordinate2::getClassTypeId(), root); } fprintf(stderr,"writing target/n"); SoWriteAction wa(&out); wa.apply(root); } root->unref(); return 0; } // main()
- Open Inventor显示区域设置SoReoriganizeAction
- Open Inventor显示区域设置SoReoriganizeAction
- Open Inventor显示区域SbViewportRegion
- Open Inventor显示区域SbViewportRegion
- Open Inventor练习-iv文件读写显示1
- Open Inventor练习-iv文件读写显示2
- Open Inventor练习-iv文件读写显示3
- Open Inventor练习-iv文件读写显示4
- Open Inventor练习-SoWin中SoWinExaminerViewer显示三维场景
- Open Inventor练习-SoWin中SoWinRenderArea显示三维场景
- Open Inventor 简介
- Basic Open Inventor
- Practical Open Inventor
- Open Inventor 简介
- 一个Open Inventor程序
- Open Inventor学习资源
- open inventor 映射实例
- Open Inventor学习资源
- 导航中GPS位置与地图匹配、道路匹配算法
- linux下,让目录栈显示行号。
- 持续集成学习笔记-入门篇(3)持续集成环境的搭建
- 通过PHP怎样取到android系统下apk应用的包名,版本号等信息
- 华丽的css3效果演示集合
- Open Inventor显示区域设置SoReoriganizeAction
- eclipse中文字体太小的问题
- C++标准转换运算符const_cast
- PluginResolutionException( Failed to read artifact descriptor for org.apache.maven.plugins:)
- AT&T与Intel汇编语言的比较
- 警告:xxxx 是 Sun 的专用 API,可能会在未来版本中删除
- 腾讯 vs 百度
- JBPM4.4环境搭建
- fckeditor的jsp中的使用