D3DXMATRIX是一个4X4的矩阵,而且它包含了一些方法和运算符重载的东西。
语法:
typedef struct D3DXMATRIX {
FLOAT _ij;
} D3DXMATRIX, *LPD3DXMATRIX;
成员:
_ij FLOAT
这里个矩阵是由(i,j)组成的,i代表的是行,j代表的是列。
备注:
c语言是不能使用这个D3DXMATRIX结构的,它要使用D3DMATRIX的。字面上就是少了一个X而已,但是却比c++少了
一些方法。例如:多个不同格式的构造函数,一元,二元运算符等.
在D3DX的_34(第三行第四列元素)不能是负数。如果要是负数,请使用scale方法去代替-1.
D3DXMATRIX 扩展
D3DXMATRIX有如下的c++扩展:
#ifdef __cplusplus
typedef struct D3DXMATRIX : public D3DMATRIX
{
public:
D3DXMATRIX() {};
D3DXMATRIX( CONST FLOAT * );
D3DXMATRIX( CONST D3DMATRIX& );
D3DXMATRIX( CONST D3DXFLOAT16 * );
D3DXMATRIX( FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14,
FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24,
FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34,
FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 );
// access grants
FLOAT& operator () ( UINT Row, UINT Col );
FLOAT operator () ( UINT Row, UINT Col ) const;
// casting operators
operator FLOAT* ();
operator CONST FLOAT* () const;
// assignment operators
D3DXMATRIX& operator *= ( CONST D3DXMATRIX& );
D3DXMATRIX& operator += ( CONST D3DXMATRIX& );
D3DXMATRIX& operator -= ( CONST D3DXMATRIX& );
D3DXMATRIX& operator *= ( FLOAT );
D3DXMATRIX& operator /= ( FLOAT );
// unary operators
D3DXMATRIX operator + () const;
D3DXMATRIX operator - () const;
// binary operators
D3DXMATRIX operator * ( CONST D3DXMATRIX& ) const;
D3DXMATRIX operator + ( CONST D3DXMATRIX& ) const;
D3DXMATRIX operator - ( CONST D3DXMATRIX& ) const;
D3DXMATRIX operator * ( FLOAT ) const;
D3DXMATRIX operator / ( FLOAT ) const;
friend D3DXMATRIX operator * ( FLOAT, CONST D3DXMATRIX& );
BOOL operator == ( CONST D3DXMATRIX& ) const;
BOOL operator != ( CONST D3DXMATRIX& ) const;
} D3DXMATRIX, *LPD3DXMATRIX;
#else //!__cplusplus
typedef struct _D3DMATRIX D3DXMATRIX, *LPD3DXMATRIX;
#endif //!__cplusplus
相信聪明的读者看了如上代码应该知道上面的D3DXMATRIX为什么比D3DMATRIX多了一些功能了吧,因为是
D3DXMATRIX是继承自D3DMATRIX的。