Game Development Reference
In-Depth Information
If you expected the teapot to be sitting on the X-axis, you must remember that any
rotation happens about the origin, not the center of the object! This is a common
mistake, and I
'
ve spent much of my 3D debugging time getting my matrices in the
right order.
Translations Always Come Last
Always translate last. If you want to place an object in a 3D world, you
always perform your rotations first, scale second, and translations third. Use
RST
as a helpful mnemonic, standing for rotate, scale, translate.
Let ' s follow my own best practice and see if you get a better
result. First, you reverse the order of the parameters into the
matrix multiplication API:
D3DXMATRIX result;
D3DXMatrixMultiply(&result, &rotateY, &trans );
Figure 14.10 shows the result.
Figure 14.10
Rotate about the origin first and then translate down the X-axis.
Search WWH ::




Custom Search