1、首先在vs2008中创建一个win32-》win32 project-》DLL,empty工程
2、编写3维显示部分
#include <Inventor/Win/SoWin.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoCone.h>
#include <Inventor/nodes/SoCoordinate3.h>
#include <Inventor/nodes/SoQuadMesh.h>
#include <Inventor/Win/SoWin.h>
#include <Inventor/Win/viewers/SoWinExaminerViewer.h>
extern "C" __declspec(dllexport) void PassHandle(HWND hwnd);
void PassHandle(HWND hwnd)
{
SoWin::init("");
SoWinExaminerViewer* viewer = new SoWinExaminerViewer(hwnd);
viewer->setDecoration(FALSE);
viewer->setSize(SbVec2s(598,216));
SoSeparator *root = new SoSeparator; // remove me later
root->addChild(new SoCone);
viewer->setSceneGraph(root);
//root->unrefNoDelete();
//cout<<hwnd;
}
3、创建一个C#的form工程 然后在form上添加一个picturebox
4、在form1.designer.cs中添加
using System;
using System.Runtime.InteropServices;
和
[DllImport("DllTest2008.dll", EntryPoint = "PassHandle")]
public static extern void PassHandle(IntPtr hwnd);
public void Disp()
{
IntPtr ptr = pictureBox1.Handle;
PassHandle(ptr);
}
5、在Form()函数中调用Disp();
编译运行就可以在界面上看到用coin 3d 画的一个圆锥了