2 baidu 29776665 baidu_29776665 于 2015.07.21 14:17 提问

写了一个Qt界面,然后现在想把做好的openinventor显示模块嵌进去

写了一个Qt界面,然后现在想把做好的openinventor显示模块嵌进去,都是基于vs2010做的,怎么办?

2个回答

caozhy
caozhy   Ds   Rxr 2015.07.21 14:18
oyljerry
oyljerry   Ds   Rxr 2015.07.22 19:41

用 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;
}
Csdn user default icon
上传中...
上传图片
插入图片