Microsoft DirectX 8.0 (Visual Basic)

Indexed Vertex Blending Transform and Render States

Transform states 256-511 are reserved to store up to 256 matrices that can be indexed using 8-bit indices. Use the function below to map indices 0-255 to the corresponding transform states.

Function D3DTS_WORLDMATRIX(index as Long) As Long
    D3DTS_WORLDMATRIX=(index + 256)
End Function

The following code example shows how to use the Direct3DDevice8.SetTransform method to set the matrix at transform state number 256 to an identity matrix.

Dim matBlend1 As D3DMATRIX

Call D3DXMatrixIdentity(matBlend1)
Call m_D3DDevice.SetTransform(D3DTS_WORLDMATRIX(0), matBlend)

To enable or disable indexed vertex blending, set the D3DRS_INDEXVERTEXBLENDENABLE render state to True. When the render state is enabled, you must pass matrix indices as packed Longs with every vertex. When this render state is disabled and vertex blending is enabled, it is equivalent to having the matrix indices 0, 1, 2, and 3 in every vertex. The code example below uses the Direct3DDevice8.SetRenderState method to enable indexed vertex blending.

Call m_D3DDevice.SetRenderState(D3DRS_INDEXVERTEXBLENDENABLE, True)

To enable or disable vertex blending, set the D3DRS_VERTEXBLEND render state to a value other than D3DRS_DISABLE from the D3DVERTEXBLENDFLAGS enumerated type. If this render state is not set to D3DRS_DISABLE, then you must pass the required number of weights for each vertex. The following code example uses SetRenderState to enable vertex blending with three weights for each vertex.

Call m_D3DDevice.SetRenderState(D3DRS_VERTEXBLEND, D3DVBF_3WEIGHTS)