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,上面的函數有以下更精簡的寫法: