首先创建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
未完待续: