Nathaniel Nathaniel - 27 days ago 20
C# Question

Blender animation to XNA distortion bug

I followed the instructions on the following video: www.youtube.com/watch?v=SissgQ0IXvk

I'm using XNA 4.0 and Blender 2.69

I export the model with animation to a .FBX file.

The animation is a man waving

Here is what it looks like in Blender:

i.stack.imgur.com/481r9.jpg

And here is how it renders in XNA:

i.stack.imgur.com/iWk1E.jpg

The arm where the animation occurs is greatly distorted.

I believe the error occurs in the AnimationPlayer class:

/// <summary>
/// Helper used by the Update method to refresh the WorldTransforms data.
/// </summary>
public void UpdateWorldTransforms(Matrix rootTransform)
{
// Root bone.
worldTransforms[0] = boneTransforms[0] * rootTransform;

// Child bones.
for (int bone = 1; bone < worldTransforms.Length; bone++)
{
int parentBone = skinningDataValue.SkeletonHierarchy[bone];

worldTransforms[bone] = boneTransforms[bone] *
worldTransforms[parentBone];
}
}


/// <summary>
/// Helper used by the Update method to refresh the SkinTransforms data.
/// </summary>
public void UpdateSkinTransforms()
{
for (int bone = 0; bone < skinTransforms.Length; bone++)
{
skinTransforms[bone] = skinningDataValue.InverseBindPose[bone] *
worldTransforms[bone];
}
}


I think the bug can be fixed by editing the code above, I just don't know how to do it.
Can somebody help me fix this distortion bug?

Here is a link to the project source code:

www.mediafire.com/download/ps5ocf1nxbfgrru/SkinningSample_4_0.zip

Here is a link to the Blender file:

www.mediafire.com/download/vrt8h1p83vkd76g/wave.blend

Answer

Found the problem. XNA's content pipeline doesn't seem to be able to handle animated FBXs correctly. So XNA has a bug. Luckily Blender 2.68a and older has a "fix" for this. Just check "XNA rotation animation hack" when exporting the FBX.

Comments