SoRotor

/*-------------------------------------------------------------- * Rotor node example. * Read in the tower and vanes of a windmill from a file. * Use a rotor node to rotate the vanes. *------------------------------------------------------------*/ #include <Inventor/SoDB.h> #include <Inventor/SoInput.h> #include <Inventor/Win/SoWin.h> #include <Inventor/Win/viewers/SoWinExaminerViewer.h> #include <Inventor/nodes/SoSeparator.h> #include <Inventor/nodes/SoRotor.h> #ifdef WIN32 # include "print.h" #endif 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; } int main(int, char **argv) { // Initialize Inventor and Win HWND myWindow = SoWin::init(argv[0]); SoSeparator *root = new SoSeparator; root->ref(); // Read in the data for the windmill tower SoSeparator *windmillTower = readFile("../data/windmillTower.iv"); root->addChild(windmillTower); // Add a rotor node to spin the vanes SoRotor *myRotor = new SoRotor; myRotor->rotation.setValue(SbVec3f(0.0f, 0.0f, 1.0f), (float)(M_PI/32.0f)); // z axis myRotor->speed = 0.1f; root->addChild(myRotor); // Read in the data for the windmill vanes SoSeparator *windmillVanes = readFile("../data/windmillVanes.iv"); root->addChild(windmillVanes); // Create a viewer SoWinExaminerViewer *myViewer = new SoWinExaminerViewer(myWindow); // attach and show viewer myViewer->setSceneGraph(root); myViewer->setTitle("Windmill"); 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、付费专栏及课程。

余额充值