Sign in to follow this  

Bone animation with FBX

This topic is 2061 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

[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 [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img][/font][/color]
[color=#000000][font=Arial,]For getting the weights and indices I use this methode:[/font][/color]
[color=#000000][font=Arial,][CODE]
bool BlocoFBXConverter::ParseMeshSkinning( KFbxMesh* pMesh, SkinData* pSkinData )
{
DWORD dwDeformerCount = pMesh->GetDeformerCount( KFbxDeformer::eSKIN );
if( dwDeformerCount == 0 )
return false;[/font][/color]
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[i], dwBoneIndex, (FLOAT)pWeights[i] );
}
}
}
//All bones are stored. Now get the hierarchy
pSkinData->SetHierarchy( m_pScene->GetRootNode() );
return true;
}
[/CODE]

[color=#000000][font=Arial,]The file I am use for testing is the humanoid.fbx from the FBX-SDK (2012)[/font][/color]
[color=#000000][font=Arial,]The Shader should be ok:[/font][/color]
[color=#000000][font=Arial,][CODE]
VS_OUT output = (VS_OUT)0;[/font][/color]
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);
[/CODE][color=#000000][font=Arial,]
The "skinTransform = mul(BindShape, skinTransform);" isn't needed because the matrix is allready callculated by FBX.[/font][/color]
I addached one pic with three snapshots,[/font][/color]

Share this post


Link to post
Share on other sites

This topic is 2061 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this