Game Development Reference
In-Depth Information
'
multiplication. Let
s look at two examples, starting with two matrices you should be
able to visualize:
D3DXMATRIX trans, rotateY;
D3DXMatrixTranslation(&trans, 3,0,0);
D3DXMatrixRotationY(&rotateY, -D3DX_PI / 4.0f);
The translation matrix will push your teapot down the X-axis, or to the lower left in
your current view. The negative angle rotation about the Y-axis you
'
ve already seen.
In DirectX, you can multiply two matrices with a function call. I
m not going to
bother showing you the actual formula for two reasons. First, you can find it for
yourself on the Internet, and second, no one codes this from scratch. There
'
s always
an optimized version of a matrix multiply in any 3D engine you find, including
DirectX:
'
D3DXMATRIX result;
D3DXMatrixMultiply(&result, &trans, &rotateY);
Note the order. This should create a transform matrix that will push the teapot down
the X-axis and rotate it about the Y-axis, in that order. Figure 14.9 shows the results.
Figure 14.9
Translate down X-axis first and then rotate about the origin.
 
Search WWH ::




Custom Search