📄 xmatrix.inl
字号:
#ifndef __XMATRIX_INLINE_INCLUDE__
#define __XMATRIX_INLINE_INCLUDE__
#ifndef IN_MATHLIB_NAMESPACE
#error You cann't include this file out the XMathLib namespace
#endif
class _MATH_LIB_EXPORT_ XMatrix
{
public:
XMatrix()
{
memset((void*) data,0,sizeof(float)*16);
}
XMatrix(float i)
{
memset((void*) data,0,sizeof(float)*16);
for(int c = 0 ; c < 4 ; c++)
{
m[c][c] = i;
}
}
void LoadIdentity()
{
memset((void*) data,0,sizeof(float)*16);
for(int c = 0 ; c < 4 ; c++)
{
m[c][c] = 1;
}
}
XMatrix(float m[16])
{
memcpy((char*)data,(char*)data,sizeof(float)*16);
}
XMatrix(XVector vec[4],bool isVertical)
{
if(isVertical)
{
m[0][0] = vec[0].x;
m[1][0] = vec[0].y;
m[2][0] = vec[0].z;
m[3][0] = vec[0].w;
m[0][1] = vec[1].x;
m[1][1] = vec[1].y;
m[2][1] = vec[1].z;
m[3][1] = vec[1].w;
m[0][2] = vec[2].x;
m[1][2] = vec[2].y;
m[2][2] = vec[2].z;
m[3][2] = vec[2].w;
m[0][3] = vec[3].x;
m[1][3] = vec[3].y;
m[2][3] = vec[3].z;
m[3][3] = vec[3].w;
}
else
{
m[0][0] = vec[0].x;
m[0][1] = vec[0].y;
m[0][2] = vec[0].z;
m[0][3] = vec[0].w;
m[1][0] = vec[1].x;
m[1][1] = vec[1].y;
m[1][2] = vec[1].z;
m[1][3] = vec[1].w;
m[2][0] = vec[2].x;
m[2][1] = vec[2].y;
m[2][2] = vec[2].z;
m[2][3] = vec[2].w;
m[3][0] = vec[3].x;
m[3][1] = vec[3].y;
m[3][2] = vec[3].z;
m[3][3] = vec[3].w;
}
}
void Transform(float tx,float ty,float tz)
{
m[3][0] += tx;
m[3][1] += ty;
m[3][2] += tz;
}
void SetTransform(float tx,float ty,float tz)
{
m[3][0] = tx;
m[3][1] = ty;
m[3][2] = tz;
}
void Scale(float sx,float sy,float sz)
{
m[0][0] *= sx ; m[0][1] *= sx ; m[0][2] *= sx ;
m[1][0] *= sy ; m[1][1] *= sy ; m[1][2] *= sy ;
m[2][0] *= sz ; m[2][1] *= sz ; m[2][2] *= sz ;
}
void From(XMatrix3x3& _m);
public :
union
{
struct
{
float m00,m01,m02,m03;
float m10,m11,m12,m13;
float m20,m21,m22,m23;
float m30,m31,m32,m33;
};
float data[16];
float m[4][4];
};
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -