您的位置:首页 > 运维架构

Open Inventor练习-SoWin中SoWinExaminerViewer显示三维场景

2011-10-13 15:28 375 查看
#define COIN_DLL    
#define SOWIN_DLL    
// 加载COIN库文件    
#ifdef _DEBUG    
#pragma comment(lib, "SoWin1d.lib")    
#pragma comment(lib, "Coin3d.lib")    
#else    
#pragma comment(lib, "SoWin1.lib")    
#pragma comment(lib, "Coin3.lib")    
#endif    
// 添加COIN头文件-Window操作显示库和节点库
#include <Inventor/Win/SoWin.h>
#include <Inventor/Win/viewers/SoWinExaminerViewer.h>
#include <Inventor/nodes/SoBaseColor.h>
#include <Inventor/nodes/SoCone.h>
#include <Inventor/nodes/SoSeparator.h>

int main(int argc, char ** argv)
{
	// Initializes SoQt library (and implicitly also the Coin and Qt
	// libraries). Returns a top-level / shell Qt window to use.
	HWND mainwin = SoWin::init(argc, argv, argv[0]);

	// Make a dead simple scene graph by using the Coin library, only
	// containing a single yellow cone under the scenegraph root.
	SoSeparator * root = new SoSeparator;
	root->ref();

	SoBaseColor * col = new SoBaseColor;
	col->rgb = SbColor(1, 1, 0);
	root->addChild(col);

	root->addChild(new SoCone);

	// Use one of the convenient SoQt viewer classes.
	SoWinExaminerViewer * eviewer = new SoWinExaminerViewer(mainwin);
	eviewer->setSceneGraph(root);
	eviewer->show();

	// Pop up the main window.
	SoWin::show(mainwin);
	// Loop until exit.
	SoWin::mainLoop();

	// Clean up resources.
	delete eviewer;
	root->unref();

	return 0;
}
SoBaseColor是Open Inventor的颜色节点,与SoMaterial一样可以对三维场景中的问题进行颜色控制,rgb变量就是对需要设定的颜色进行RGB颜色值设定,他是一个SoMFColor变量,可以多值设定,这里设定颜色位***,用来控制下面的圆锥节点。
SoWinExaminerViewer是用来显示场景的,它派生与SoWinViewer,用来对Windows窗口的句柄控制,进而控制OpenGL在窗体上的三维显示。
输出结果如下。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: