|Microsoft DirectX 9.0|
The world transformation matrix defines how to translate, scale, and rotate the geometry in the 3-D model space.
The following code fragment rotates the triangle on the y-axis and then sets the current world transformation for the Microsoft?Direct3D?device.
D3DXMATRIX matWorld; D3DXMatrixRotationY( &matWorld, timeGetTime()/150.0f ); g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
The first step is to rotate the triangle around the Y-axis by calling the D3DXMatrixRotationY method. The first parameter is a pointer to a D3DXMATRIX structure that is the result of the operation. The second parameter is the angle of rotation in radians.
The next step is to call IDirect3DDevice9::SetTransform to set the world transformation for the Direct3D device. The first parameter accepted by IDirect3DDevice9::SetTransform tells Direct3D which transformation to set. This sample uses the D3DTS_WORLD macro to specify that the world transformation should be set. The second parameter is a pointer to a matrix that is set as the current transformation.
For more information about world transformations, see World Transformation.
After defining the world transformation for the scene, you can prepare the view transformation matrix. Again, note that the order in which transformations are defined is not critical. However, Direct3D applies the matrices to the scene in the following order: (1) World ,(2) View, (3) Projection.
Defining the view transformation matrix is described in Step 2: Defining the View Transformation Matrix.