当前位置:编程学习 > C/C++ >>

Open Inventor的VRML2转换SoToVRML2Action

view plaincopy to clipboardprint?
#include <Inventor/SoDB.h> 
  #include <Inventor/SoInteraction.h> 
  #include <Inventor/SoInput.h> 
  #include <Inventor/SoOutput.h> 
  #include <Inventor/actions/SoWriteAction.h> 
  #include <Inventor/actions/SoToVRML2Action.h> 
  #include <Inventor/nodes/SoSeparator.h> 
  #include <Inventor/VRMLnodes/SoVRMLGroup.h>  
  int 
  main(int argc, char *argv[])  
  {  
    SoDB::init();  
    SoInteraction::init();  
    SoInput in;  
    in.openFile(argv[1]);  
    printf("Reading... ");  
    SoSeparator *root = SoDB::readAll(&in);  
    if (root) {  
      root->ref();  
      SbString hdr = in.getHeader();  
      in.closeFile();  
      printf("Converting... ");  
      SoToVRML2Action tovrml2;  
      tovrml2.apply(root);  
      SoVRMLGroup *newroot = tovrml2.getVRML2SceneGraph();  
      newroot->ref();  
      root->unref();  
      printf("Writing... ");  
      SoOutput out;  
      out.openFile("out.wrl");  
      out.setHeaderString("#VRML V2.0 utf8");  
      SoWriteAction wra(&out);  
      wra.apply(newroot);  
      out.closeFile();  
      newroot->unref();  
    }  
    return 0;  
  } 
补充:软件开发 , C语言 ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,