SoInput Read file

/*----------------------------------------------------------- * Example of reading from a file. * Read a file given a filename and return a separator * containing all of the file. Return NULL if there is * an error reading the file. *----------------------------------------------------------*/ #include <Inventor/SoDB.h> #include <Inventor/SoInput.h> #include <Inventor/Win/SoWin.h> #include <Inventor/Win/viewers/SoWinExaminerViewer.h> #include <Inventor/nodes/SoSeparator.h> #ifdef WIN32 # include "print.h" #endif / // CODE FOR The Inventor Mentor STARTS HERE SoSeparator * readFile(const char *filename) { // Open the input file SoInput mySceneInput; if (!mySceneInput.openFile(filename)) { fprintf(stderr, "Cannot open file %s/n", filename); return NULL; } // Read the whole file into the database SoSeparator *myGraph = SoDB::readAll(&mySceneInput); if (myGraph == NULL) { fprintf(stderr, "Problem reading file/n"); return NULL; } mySceneInput.closeFile(); return myGraph; } // CODE FOR The Inventor Mentor ENDS HERE / int main(int, char **argv) { // Initialize Inventor and Win HWND myWindow = SoWin::init(argv[0]); // Read the file SoSeparator *scene = readFile("../data/models/household/plant.iv"); // Create a viewer SoWinExaminerViewer *myViewer = new SoWinExaminerViewer(myWindow); // attach and show viewer myViewer->setSceneGraph(scene); myViewer->setTitle("File Reader"); myViewer->show(); // Loop forever SoWin::show(myWindow); SoWin::mainLoop(); return 0; }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值