ID3DXTextureGutterHelper::ResampleTex

Resamples a texture into this gutterhelper's parameterization.

HRESULT ResampleTex(
  LPDIRECT3DTEXTURE9 pTextureIn,
  LPD3DXMESH pMeshIn,
  D3DDECLUSAGE Usage,
  UINT UsageIndex,
  LPDIRECT3DTEXTURE9 pTextureOut
);

Parameters

pTextureIn
[in] Texture that corresponds to the original parameterization in pMeshIn. This texture will be used to create pTextureOut.
pMeshIn
[in] Mesh containing the original and new parameterizations. It is required to store the new parameterization in D3DDECLUSAGE_TEXCOORD index 0.
Usage
[in] Vertex data usage (used in combination with UsageIndex) which identifies the component of the vertex declaration that contains the original parameterization in pMeshIn. See D3DDECLUSAGE.
UsageIndex
[in] Zero-based index (used in combination with Usage), which identifies the component of the vertex declaration that contains the original parameterization in pMeshIn. The combination of D3DDECLUSAGE_TEXCOORD and index 0 is required for the new parameterization; any other usage/index combination may be used.
pTextureOut
[out] Resampled texture.

Return Values

If the method succeeds, the return value is D3D_OK. If the method fails, the return value can be one of the following: D3DERR_INVALIDCALL, E_OUTOFMEMORY.

Remarks

A parameterization in the case of this function is a set of texture coordinates that maps the triangles of a mesh to the triangles on a texture. The new parameterization is the set of texture coordinates contained in the gutter helper interface, and the original parameterization is the set of texture coordinates contained within the input mesh.

It is assumed that texture coordinates are between 0 and 1, inclusive, and the new parameterization must be declared in the vertex declaration as texture coordinate index 0. The original texture and the resampled texture must have the same width and height.

For example, to prepare for resampling a texture:

// Given:
// pMesh points to a mesh that contains the original and new texture coordinates
ID3DXTextureGutterHelper * pGutterHelper;
    
// Mesh vertex declaration
D3DVERTEXELEMENT9 decl[] = {
    {0,  0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
    {0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0},
    // contains new set of texcoords
    {0, 24, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0}, 
    // contains original set of texcoords
    {0, 32, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1}, 
    D3DDECL_END()
};
    
// Create a gutter helper with the new parameterization
hr = D3DXCreateTextureGutterHelper(width, height, pMesh, 1, &pGutterHelper);  
    
// Resample the texture
hr = pGutterHelper->ResampleTex(pOriginalTex, pMesh, D3DDECLUSAGE_TEXCOORD, 
           1, pResampledTex); 
    
// Release the gutter helper interface when done with it

One common scenario might be to use UVAtlas to create a texture atlas and then use ResampleTex to resample the texture into the new parameterization. For more information about atlases, see Using UVAtlas.

Requirements

Header: Declared in D3dx9mesh.h.

See Also

D3DXUVAtlasCreate