Original Post
[color=#000000][font=Arial,]writing an fbx converter for our small game engine. I stuck with rendering the Model using the animation. The matrix for each timestamp look allright and when I render just the bones it also looks like the the orginal animation. I made some snapshot to show my problem. I just can't figure out whats wrong. In my opinion the Matrix is correct and so it must be the Bone weights / Indices. Whith PIX i controlled that the data is passed correctly. Maybe someone is able to give me a hind
[/font]
[color=#000000][font=Arial,]For getting the weights and indices I use this methode:[/font]
[color=#000000][font=Arial,]
[color=#000000][font=Arial,]The file I am use for testing is the humanoid.fbx from the FBX-SDK (2012)[/font]
[color=#000000][font=Arial,]The Shader should be ok:[/font]
[color=#000000][font=Arial,]
The "skinTransform = mul(BindShape, skinTransform);" isn't needed because the matrix is allready callculated by FBX.[/font]
I addached one pic with three snapshots,[/font]
[color=#000000][font=Arial,]For getting the weights and indices I use this methode:[/font]
[color=#000000][font=Arial,]
bool BlocoFBXConverter::ParseMeshSkinning( KFbxMesh* pMesh, SkinData* pSkinData )
{
DWORD dwDeformerCount = pMesh->GetDeformerCount( KFbxDeformer::eSKIN );
if( dwDeformerCount == 0 )
return false;[/font]
const DWORD dwVertexCount = pMesh->GetControlPointsCount();
const DWORD dwStride = 4;
pSkinData->Alloc( dwVertexCount, dwStride );
for( DWORD dwDeformerIndex = 0; dwDeformerIndex < dwDeformerCount; ++dwDeformerIndex )
{
KFbxSkin* pSkin = (KFbxSkin*)pMesh->GetDeformer( dwDeformerIndex, KFbxDeformer::eSKIN );
DWORD dwClusterCount = pSkin->GetClusterCount();
for( DWORD dwClusterIndex = 0; dwClusterIndex < dwClusterCount; ++dwClusterIndex )
{
KFbxCluster* pCluster = pSkin->GetCluster( dwClusterIndex );
DWORD dwClusterSize = pCluster->GetControlPointIndicesCount();
if( dwClusterSize == 0 )
continue;
KFbxNode* pLink = pCluster->GetLink();
Bone bone;
bone.pNode = pLink;
bone.sName = pLink->GetName();
bone.iParentIndex = -1;
DWORD dwBoneIndex = pSkinData->GetBoneCount();
pSkinData->AddBone(bone);
KFbxXMatrix matXBindPose;
pCluster->GetTransformLinkMatrix( matXBindPose );
KFbxMatrix matBindPose = matXBindPose;
CaptureBindPoseMatrix( pLink, matBindPose );
INT* pIndices = pCluster->GetControlPointIndices();
DOUBLE* pWeights = pCluster->GetControlPointWeights();
for( DWORD i = 0; i < dwClusterSize; ++i )
{
pSkinData->InsertWeight( pIndices, dwBoneIndex, (FLOAT)pWeights );
}
}
}
//All bones are stored. Now get the hierarchy
pSkinData->SetHierarchy( m_pScene->GetRootNode() );
return true;
}
[color=#000000][font=Arial,]The file I am use for testing is the humanoid.fbx from the FBX-SDK (2012)[/font]
[color=#000000][font=Arial,]The Shader should be ok:[/font]
[color=#000000][font=Arial,]
VS_OUT output = (VS_OUT)0;[/font]
float4x4 skinTransform = 0;
skinTransform += MatrixPallette[input.BoneIndices.x] * input.Weights.x;
skinTransform += MatrixPallette[input.BoneIndices.y] * input.Weights.y;
skinTransform += MatrixPallette[input.BoneIndices.z] * input.Weights.z;
skinTransform += MatrixPallette[input.BoneIndices.w] * input.Weights.w;
//skinTransform = mul(BindShape, skinTransform);
//Transform Position
float4 worldPosition = mul(input.Position, skinTransform);
float4 viewPosition = mul(worldPosition, matView);
output.Position = mul(viewPosition, matProj);
[color=#000000][font=Arial,]The "skinTransform = mul(BindShape, skinTransform);" isn't needed because the matrix is allready callculated by FBX.[/font]
I addached one pic with three snapshots,[/font]