Platform SDK: DirectX

Setting Blending Matrices

[C++]

You set the transformation matrices between which the system blends by calling the IDirect3DDevice7::SetTransform method. Set the first parameter to one of the "D3DTRANSFORMSTATE_WORLD" members from the D3DTRANSFORMSTATETYPE enumerated type, and set the second parameter to the address of the matrix to be set.

The following C++ code fragment sets two world matrices, between which geometry will be blended to create the illusion of a jointed arm.

// For this example, the pd3dDevice variable is assumed to be a 
// valid pointer to an IDirect3DDevice7 interface for an initialized
// 3-D scene.
float     fBendAngle = 3.1415926f / 4.0f; // 45 degrees
D3DMATRIX matUpperArm, matLowerArm;

// The upper arm is immobile, use the identity matrix.
D3DUtil_SetIdentityMatrix( matUpperArm );
pd3dDevice->SetTransform( D3DTRANSFORMSTATE_WORLD,  &matUpperArm );

// The lower arm rotates about the x-axis, attached to the upper arm.
D3DUtil_SetRotateXMatrix( matLowerArm, -fBendAngle ); 
pd3dDevice->SetTransform( D3DTRANSFORMSTATE_WORLD1, &matLowerArm );

Setting a blending matrix merely causes the system to cache the matrix for later use, it doesn't instruct the system to begin blending vertices. For more information, see Enabling Geometry Blending.

[Visual Basic]

You set the transformation matrices between which the system blends by calling the Direct3DDevice7.SetTransform method. Set the first parameter to one of the "D3DTRANSFORMSTATE_WORLD" members from the CONST_D3DTRANSFORMSTATETYPE enumeration, and set the second parameter to the address of the matrix to be set.

The following Visual Basic code fragment sets two world matrices, between which geometry will be blended to create the illusion of a jointed arm.

' For this example, the d3dDevice variable is assumed to be a
' valid reference to a Direct3DDevice7 object for an initialized
' 3-D scene. The dx variable is a valid reference to a DirectX7 object.
Dim nBendAngle As Single
Dim matUpperArm As D3DMATRIX, _
    matLowerArm As D3DMATRIX

nBendAngle = 3.1415926 / 4#  ' 45 degrees

' The upper arm is immobile, use the identity matrix.
Call dx.IdentityMatrix(matUpperArm)
Call d3dDevice.SetTransform(D3DTRANSFORMSTATE_WORLD, matUpperArm)

' The lower arm rotates about the x-axis, attached to the upper arm.
Call dx.RotateXMatrix(matLowerArm, -nBendAngle)
Call d3dDevice.SetTransform(D3DTRANSFORMSTATE_WORLD1, matLowerArm)

Setting a blending matrix merely causes the system to cache the matrix for later use, it doesn't instruct the system to begin blending vertices. For more information, see Enabling Geometry Blending.