Irrlicht游戏引擎(V0.1)源码学习系列之一

首先创建DLL工程,然后编辑文件:

#include "Irrlicht.h"
#include <Windows.h>

#ifdef _DEBUG
#include <crtdbg.h>
#endif

#pragma comment(exestr, "Irrlicht Engine")


BOOL APIENTRY DllMain( HANDLE hModule,
						DWORD ul_reason_for_call,
						LPVOID lpReserved
					)
{
	switch( ul_reason_for_call )
	{
	case DLL_PROCESS_ATTACH:
		#ifdef _DEBUG
				_CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF | _CRTDBG_ALLOC_MEM_DF);
		#endif
		break;
	case DLL_THREAD_ATTACH:
	case DLL_THREAD_DETACH:
	case DLL_PROCESS_DETACH:
		break;
	}
	return true;
}

再编辑文件:

 

#ifndef _IRRLICHT_H_INCLUDE_
#define _IRRLICHT_H_INCLUDE_

#include "aabbox3d.h"

#endif

再编辑文件:

#ifndef _IRR_AABBOX_3D_H_INCLUDE_
#define _IRR_AABBOX_3D_H_INCLUDE_

#include "irrTypes.h"
#include "plane3dex.h"

#endif

再编辑文件:
#ifndef _IRR_TYPES_H_INCLUDE_
#define _IRR_TYPES_H_INCLUDE_

namespace irr
{

typedef unsigned char u8;
typedef signed char s8;
typedef char c8;

typedef unsigned short u16;
typedef signed short s16;

typedef unsigned int u32;
typedef signed int s32;
<pre name="code" class="cpp">#ifndef _IRR_PLANE_3D_H_INCLUDE
#define _IRR_PLANE_3D_H_INCLUDE

#include "irrmath.h"
#include "vector3d.h"

namespace irr
{
namespace core
{
enum EInterSectionRelation3D
{
	ISREL3D_FRONT = 0,
	ISREL3D_BACK,
	ISREL3D_PLANAR,
	ISREL3D_SPANNING,
	ISREL3D_CLIPPED
};
	
template<typename T>
class plane3d
{
public:
	//plane3d():MPoint(0,0,0),Normal(0,1,0){};

	//vector3d<T> MPoint;
	//vector3d<T> Normal;
};
}
}

#endif

 

再编辑文件: 

#ifndef _IRR_PLANE_3D_EX_H_INCLUDE_
#define _IRR_PLANE_3D_EX_H_INCLUDE_

#include "irrTypes.h"
#include "plane3d.h"

#endif

再编辑文件: 

#ifndef _IRR_PLANE_3D_H_INCLUDE
#define _IRR_PLANE_3D_H_INCLUDE

#include "irrmath.h"
#include "vector3d.h"

namespace irr
{
namespace core
{
enum EInterSectionRelation3D
{
	ISREL3D_FRONT = 0,
	ISREL3D_BACK,
	ISREL3D_PLANAR,
	ISREL3D_SPANNING,
	ISREL3D_CLIPPED
};
	
template<typename T>
class plane3d
{
public:
	//plane3d():MPoint(0,0,0),Normal(0,1,0){};

	//vector3d<T> MPoint;
	//vector3d<T> Normal;
};
}
}

#endif

再编辑文件:

/****************************
 * 2015年5月24 星期日 零点
 *(周六一天写了仿真的代码,晚上闲余来敲一敲IRRLICHT引擎的代码,不知不觉已经到了周日凌晨了。)
 *(要学习Irrlicht的编码方式和各种编程方法。以提高自己用C++编码以及思考的能力。) 
 ***************************/
#ifndef _IRR_POINT_3D_H_INCLUDE_
#define _IRR_POINT_3D_H_INCLUDE_

#include <math.h>
#include "irrTypes.h"

namespace irr
{
namespace core
{
	template<typename T>
	class vector3d
	{
	public:
		vector3d():X(0), Y(0), Z(0){};
		vector3d( T nx, T ny, T nz) : X(nx), Y(ny), Z(nz){};
		vector3d(const vector3d<T>& other ) :X(other.X), Y(other.Y), Z(other.Z){};

		// 操作符
		vector3d<T>& operator=(const vector3d<T>& other)	{ X = other.X; Y = other.Y; Z = other.Z; return *this; }
		vector3d<T>& operator+(const vector3d<T>& other) const { return vector3d<T>(X + other.X, Y + other.Y, Z + other.Z); }


		// 成员变量
		T X, Y, Z;
	};

}
}

#endif

未完待续:



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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值