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

#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在窗体上的三维显示。

输出结果如下。



评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值