   How to add tangent element on skinned model
  I want to apply normal mapping on skinned models. For that I need tangents info in the vertex format. On non-skinned models it works fine, but skinned model after reformat won't render. Here's the code:DWORDdwVertexStride = pTempMesh->GetNumBytesPerVertex ();LPD3DXMESHpClonedMesh;D3DVERTEXELEMENT9 meshDeclaration[MAX_FVF_DECL_SIZE];// returns only position, normal and first texture cooordinates... no blend weights or indices!if (SUCCEEDED (pTempMesh->GetDeclaration (meshDeclaration))){DWORD dwNumDeclarations = 0;for (DWORD i=0; (i < MAX_FVF_DECL_SIZE) && (meshDeclaration.Stream != 0xFF); i++)dwNumDeclarations++;// adding tangent elementmeshDeclaration[dwNumDeclarations].Stream = 0;meshDeclaration[dwNumDeclarations].Offset = (WORD)dwVertexStride;meshDeclaration[dwNumDeclarations].Type = D3DDECLTYPE_FLOAT3;meshDeclaration[dwNumDeclarations].Method = D3DDECLMETHOD_DEFAULT;meshDeclaration[dwNumDeclarations].Usage = D3DDECLUSAGE_TANGENT;meshDeclaration[dwNumDeclarations].UsageIndex = 0;// ending elementmemset (&meshDeclaration[dwNumDeclarations+1], 0, sizeof(D3DVERTEXELEMENT9));meshDeclaration[dwNumDeclarations+1].Stream = 0xFF;meshDeclaration[dwNumDeclarations+1].Type = D3DDECLTYPE_UNUSED;if (SUCCEEDED (pTempMesh->CloneMesh (pTempMesh->GetOptions(), meshDeclaration, g_pd3dDevice, &pClonedMesh))){pTempMesh->Release ();pTempMesh = pClonedMesh;}elsegoto e_Exit;}hr = pTempMesh->UpdateSemantics (meshDeclaration);// compute tangentshr = D3DXComputeTangent (pTempMesh, 0, 0, D3DX_DEFAULT, 0, pAdjacency);Mesh->GetDeclaration() returns declaration info only about position, normal and textur coords, no info about blend weights or indices. When I newly set vertex declaration blend weights and blend indices are missing (so I suppose this may be a problem). Or have someone any idea what is wrong with this code? Someone was trying to make normal mapping on skinned models?[Edited by - JokerX on June 10, 2006 3:20:51 PM]
  Are you using software skinning?  If so, the you have the bone weights and indices in the ID3DXSkinInfo interface and use the UpdateSkinnedMesh method to update the vertices in the mesh each frame.  So in that situation, the vertex buffer does not have the bone data.If you are using hardware skinning (done in shader), then you need to use the ConvertToIndexedBlendedMesh or ConvertToBlendedMesh functions to have the bone data added to the vertex buffer.For normal mapping you need to add Tangets and Binormals.  Frank Luna's new book covers how to do normal mapping.  It also has a chapter on skinned meshes using hardware skinning.The MultiAnimation sample in the SDK shows 4 ways to render a skinned mesh with software and hardware emthods.