D3DXMATRIX * D3DXMatrixIdentity(D3DXMATRIX * pOut);
D3DXMATRIX* D3DXMatrixTranslation( D3DXMATRIX *pOut, FLOAT x, FLOAT y, FLOAT z);
D3DXMATRIX * D3DXMatrixRotationX( D3DXMATRIX *pOut, FLOAT Angle);D3DXMATRIX * D3DXMatrixRotationAxis( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle);
D3DXMATRIX * D3DXMatrixScaling( D3DXMATRIX *pOut, FLOAT sx, FLOAT sy, FLOAT sz);
D3DXMatrixIdentity创建一个单位矩阵,也就是
[ 1.00 0.00 0.00 0.00
0.00 1.00 0.00 0.00
0.00 0.00 1.00 0.00
0.00 0.00 0.00 1.00 ]
D3DXMatrixTranslation创建一个平移矩阵
D3DXMatrixTranslation(&g_translation, 1.0f, 2.0f, 3.0f);的运行结果如下
[ 1.00 0.00 0.00 0.00
0.00 1.00 0.00 0.00
0.00 0.00 1.00 0.00
1.00 2.00 3.00 1.00 ]
D3DXMatrixRotationX~Z为绕标准周旋转的矩阵
D3DXMatrixRotationAxis(&g_rotation,&vector3,D3DX_PI);绕任意向量旋转,不过别误会,那个向量还是过圆心的。。。。所以游戏中绕特定人物想旋转一般是先D3DXMatrixRotationY再加平移。
D3DXMatrixScaling生成缩放矩阵。
[x,y,z,1]
转化成矩阵
[ x y z 1
0 0 0 0
0 0 0 0
0 0 0 0 ]
//所以某个点的绕圆心的旋转就可以使用
事实上翻了下sdk,上面的函数有以下更精简的写法: