D3DXComputeTangent question

Slyce

New member
Anyone here ever use the D3DXComputeTangent function in DirectX 9? I'm getting this error all the time...

D3DX: (INFO) Using 3DNow Instructions
D3DX: D3DXComputeTangent: Need a TANGENT or BINORM usage field in output mesh decl.

My D3DVERTEXELEMENT9 declaration looked like this...

D3DVERTEXELEMENT9 decl[] =
{
{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
{ 0, 3*sizeof(float), D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL,0 },
{ 0, 6*sizeof(float), D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD,0 },
{ 0, 8*sizeof(float), D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TANGENT,0 },
D3DDECL_END()
};

then I tried adding a

{ 0, 11*sizeof(float), D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BINORMAL,0 },


but that didn't seem to work.

the code where it fails looks like this

HRESULT hr;
LPD3DXMESH pMeshSysMem = NULL,pMeshSysMem2 = NULL;
LPD3DXBUFFER pAdjacency;
LPD3DXBUFFER pMaterials;
DWORD numMaterials;

if (FAILED (D3DXLoadMeshFromX(name, D3DXMESH_SYSTEMMEM,m_pd3dDevice, &pAdjacency, &pMaterials, NULL, &numMaterials, &pMeshSysMem)))
return E_FAIL;

// reform the mesh to one which will have space for the tangent vectors
// D3DFVF_TEXCOORDSIZE3(1) indicates that a 3D texture is used in the
// second texture stage
// hr = pMeshSysMem->CloneMeshFVF(D3DXMESH_MANAGED, D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX2 | D3DFVF_TEXCOORDSIZE3(1), m_pd3dDevice, &pMeshSysMem2);
hr = pMeshSysMem->CloneMesh(D3DXMESH_MANAGED, decl, m_pd3dDevice, &pMeshSysMem2 );

// hr = pMeshSysMem2->UpdateSemantics( decl );

// compute the normals
hr = D3DXComputeNormals(pMeshSysMem2,NULL);
if(FAILED(hr))
return E_FAIL;

// compute U (tangent)
hr = D3DXComputeTangent(pMeshSysMem2,0,8,-1,1,(DWORD*)pAdjacency->GetBufferPointer());
if(FAILED(hr))
return E_FAIL;

any help would be appreciated.
 
Back
Top