Irrlicht例程03:载入3D角色模型

首先你得准备一个3D模型,下面是用3ds max导出的人物模型


导出为*.obj格式,同时把贴图也一起导出

下面是完整的代码

#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace video;
using namespace scene;

#pragma comment(lib,"irrlicht.lib")

int main(void)
{
	//设置控制台窗口的标题与窗口颜色
	system("TITLE Irrlicht Demo - StaticMesh");
	system("COLOR E0");

	//用3ds max等导出的*.obj格式模型文件
	const char* meshFile = "Assets/DivineWalk.obj";
	try
	{
		IrrlichtDevice* device = createDevice(EDT_DIRECT3D9, dimension2d<u32>(800, 600), 32U);
		device->setWindowCaption(L"Divine Walk");
		
		if (device == NULL)
		{
			//抛出异常(字符串型, char*)
			throw("An error occurred in function \'createDevice\'");
		}
		IVideoDriver* driver = device->getVideoDriver();
		ISceneManager* smgr = device->getSceneManager();

		//载入模型
		IMesh* mesh = smgr->getMesh(meshFile);
		IMeshSceneNode* node = smgr->addMeshSceneNode(mesh);
		node->setMaterialFlag(EMF_LIGHTING, false);
		node->setPosition(vector3df(0, 0, 0));

		//添加摄像机,设置观察点
		smgr->addCameraSceneNode(0, vector3df(20, 50, 50),vector3df(10, 30, 20));

		//渲染循环
		while (device->run())
		{
			driver->beginScene(true, true, SColor(255, 0, 0, 0));
			smgr->drawAll();
			driver->endScene();
		}
		device->drop();
	}
	catch (char* pszError)
	{
		puts(pszError);
	}

	return 0;
}

运行结果



没怎么接触过3ds max,想自己做模型但是又做不了,所以就去网上找了一个然后自己导出为obj格式,发现能用。

我的能力也是有限的,写到这里已经是挖掘了自己的潜能,每次都想写一些比较深刻的东西但是碍于自身能力有限

也只能倾囊而出,自己学到的都倾倒出来与大家共享。有分享,一份快乐就会变成很多,成为大家的快乐。


点此领取楼主

http://blog.csdn.net/fengyhack/article/details/38300399


转载于:https://www.cnblogs.com/fengyhack/p/10603738.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值