Platform SDK: DirectX

Defining Vertices for Blending

[C++]

The following user-defined structure could be used for vertices that will be blended between two matrices.

//
// The flexible vertex format descriptor for this vertex would be:
//
//     dwFVF = D3DFVF_XYZB1 | D3DFVF_NORMAL | D3DFVF_TEX1; 
//
struct D3DBLENDVERTEX {
    D3DVECTOR v;
    FLOAT     blend; 
    D3DVECTOR n;
    FLOAT     tu, tv;
};

As described in Blending Weights, the blend weight must appear after the position and RHW data in the flexible vertex format, and before the vertex normal.

Notice that the preceding vertex format contains only one blending weight value. This is because there will be two world matrices, defined in the D3DTRANSFORMSTATE_WORLD and D3DTRANSFORMSTATE_WORLD1 transform states. The system blends each vertex between these two matrices using the single weight value. For three matrices, only two weights are required, and so on.

[Visual Basic]

The following user-defined type could be used for vertices that will be blended between two matrices.

'
' The flexible vertex format descriptor for this vertex would be:
'
'     lFVF = (D3DFVF_XYZB1 Or D3DFVF_NORMAL Or D3DFVF_TEX1)
'
Type D3DBLENDVERTEX
    v As D3DVECTOR
    blend As Single
    n As D3DVECTOR
    tu As Single
    tv As Single
End Type

As described in Blending Weights, the blend weight must appear after the position and RHW data in the flexible vertex format, and before the vertex normal.

Notice that the preceding vertex format contains only one blending weight value. This is because there will be two world matrices, defined in the D3DTRANSFORMSTATE_WORLD and D3DTRANSFORMSTATE_WORLD1 transform states. The system blends each vertex between these two matrices using the single weight value. For three matrices, only two weights are required, and so on.

Note  Defining skin weights is easy. Using a linear function of the distance between joints is good start, but a smoother sigmoid function will look better. Choosing a skin weight distribution function can result in sharp creases at joints if desired (by using a large variation in skin weight over a short distance).

See Also

About Vertex Formats, Flexible Vertex Format Flags