?/TD>
Microsoft DirectX 9.0

Using Vertex Tweening


This topic shows how to use vertex tweening

Determining Support for Vertex Tweening

To determine if Microsoft?Direct3D?supports vertex tweening, check for the D3DVTXPCAPS_TWEENING flag in the VertexProcessingCaps member of the D3DCAPS9 structure. The following code example uses the IDirect3DDevice9::GetDeviceCaps method to determine if tweening is supported.

//
// This example assumes that m_d3dDevice is 
// a valid pointer to a IDirect3DDevice9 interface.
//

D3DCAPS9 d3dCaps;

m_d3dDevice->GetDeviceCaps( &d3dCaps );
if( 0 != (d3dCaps.VertexProcessingCaps & D3DVTXPCAPS_TWEENING) )
    //Vertex tweening is supported.

Setting Vertex Declaration

To use vector tweening, you must first set up a custom vertex type that uses a second normal or a second position. The following code example shows a sample declaration that includes both a second point and a second position.

struct TEX_VERTEX
{
    D3DVECTOR position;
    D3DVECTOR normal;
    D3DVECTOR position2;
    D3DVECTOR normal2;
};

//Create a vertex buffer with the type TEX_VERTEX.

The next step is to set the current declaration. The code example below shows how to do this.

// Create the shader declaration.
D3DVERTEXELEMENT9 decl[] = 
{
	{ 0, 0,  D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
	{ 0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 },
	{ 0, 24, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
	{ 0, 36, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 },
	D3DDECL_END()
};

For more information about creating a custom vertex type and a vertex buffer, see Creating a Vertex Buffer.

Note  When vertex tweening is enabled, a second position or a second normal must be present in the current declaration.


© 2002 Microsoft Corporation. All rights reserved.