问题描述
- 写了一个Qt界面,然后现在想把做好的openinventor显示模块嵌进去
-
写了一个Qt界面,然后现在想把做好的openinventor显示模块嵌进去,都是基于vs2010做的,怎么办?
解决方案
http://blog.sina.com.cn/s/blog_3fd731da01009e2x.html
解决方案二:
用 SoWin classes are specific to the Microsoft Windows environment.
http://oivdoc94.vsg3d.com/content/184-qt
#include <Inventor/Qt/SoQt.h>
#include <Inventor/Qt/SoQtRenderArea.h>
#include <Inventor/nodes/SoCone.h>
#include <Inventor/nodes/SoDirectionalLight.h>
#include <Inventor/nodes/SoMaterial.h>
#include <Inventor/nodes/SoPerspectiveCamera.h>
#include <Inventor/nodes/SoSeparator.h>
int main(int, char **argv)
{
// Initialize Inventor. This returns a main window to use.
// If unsuccessful, exit.
QWidget *myWindow = SoQt::init(argv[0]); // pass the app name
if (myWindow == NULL)
return 1;
// Make a scene containing a red cone
SoSeparator *root = new SoSeparator;
SoPerspectiveCamera *myCamera = new SoPerspectiveCamera;
SoMaterial *myMaterial = new SoMaterial;
root->ref();
root->addChild(myCamera);
root->addChild(new SoDirectionalLight);
// Red
myMaterial->diffuseColor.setValue(1.0, 0.0, 0.0);
root->addChild(myMaterial);
root->addChild(new SoCone);
// Create a render area in which to see our scene graph.
// The render area will appear within the main window.
SoQtRenderArea *myRenderArea = new SoQtRenderArea(myWindow);
// Make myCamera see everything.
myCamera->viewAll(root, myRenderArea->getViewportRegion());
// Put our scene in myRenderArea, change the title
myRenderArea->setSceneGraph(root);
myRenderArea->setTitle("Hello Cone");
myRenderArea->show();
SoQt::show(myWindow); // Display main window
SoQt::mainLoop(); // Main Inventor event loop
return 0;
}
时间: 2025-01-21 03:59:57