Open Inventor的VRML2转换SoToVRML2Action

来源:互联网 发布:hifi耳机推荐 知乎 编辑:程序博客网 时间:2024/05/16 02:13
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;
}
原创粉丝点击