Microsoft DirectX 8.1 (Visual Basic) |
The world transformation matrix defines how to translate, scale, and rotate geometry in 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.
Dim matWorld As D3DMATRIX D3DXMatrixRotationY matWorld, Timer * 4 g_D3DDevice.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 D3DMATRIX type that contains the returned matrix. The second parameter is the angle of rotation in radians.
The next step is to call Direct3DDevice8.SetTransform to set the current world transformation for the Direct3D device. The first parameter accepted by SetTransform tells which transformation to set. This sample uses the D3DTS_WORLD flag 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 on 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.