Tutorial: How to get XNA's SkinnedSample working with MonoGame

Question: why is it called Skinned ? And not Animated or Skeletal ? I have never catched the trick. When i started with xna years ago this induced me to error.
Skinned would be a better name if it reproduced skin with all effects and parameters (reflectance, transmittance, etc) implied on a model like the demos on nvidia or ue4 for character faces.

1 Like

Animated is too broad, just rotating or translating sonething is animating as well.
Skeletal is too specific. I can have a car with bones for the wheels and it would be skinned but not have a skeleton

A skinned mesh can have each vertex attached to one or more bones with a specified weight. This means the vertex can be influenced by more than one bone, particularly useful around joints such as knees and shoulders where the mesh can deform more smoothly. The vertex might have 50% influence from one bone, 30% influence from a second bone and 20% influence from a third.

So… has anyone had any luck getting them to import and not be distorted?

Exhibit A:

Exhibit B:


Ok, I’ve kind of figured it out. The origin of each model in the armature has to be 0,0,0. Also, when exporting you need to have the armature be in its resting pose. In addition, parenting a mesh to bone doesn’t work. They all need to be weight painted to work. Oh, and disable “Transparency” from the material or the model will be invisible.

1 Like

I finally can import animated fbx with monogame! but…



that not exactly what I expect… If anyone has ideas that may help ?

There’s a few things you need to make sure of before you import into your game:

  1. When you export, your armature must be in its resting pose in Blender (T-Pose). Aka, no rotation/scale/position can be applied to any bones. What I do is I create a 1 keyframe long animation called initial, and switch to it before exporting.

  2. Every face needs to have a weight applied to it. Non-weighted faces will distort the animation much like you’re seeing here. A really good way to make sure you have this is when you parent your armature, you select “Use Automatic Weights” when it asks you.

  3. I’m not sure about this one, but combining meshes into one tends to fix it if certain parts of the model aren’t visible.

  4. Use the latest version of Blender. I’m not sure how helpful this would be, but my (very similar to yours) problems stopped after I upgraded and did the above steps.

After trialing SkinnedSample for a while now, it seems to me that it’s a bit basic in certain areas (no animation blending or modification of playback speed, plus it does not smoothly animate between keyframes, resulting in jittery animation).

If I manage to get BetterSkinned running, I’ll post my findings here.


I think I make all thing you say correctly, but I can’t get what I want I just give up … I export multiple mesh like anim_0 anim_1 anim_2 and play theme to fake an animation that work and it’s good enough for the moment.

I will continue to follow this thread for any eventual update.

If you want you can upload your .blend file and I’ll have a go at importing it into my project.

Hello, sorry for delay, here my file if you want test: https://www.transfernow.net/40gytaga418q

let me know if you can play an animation with it :slight_smile:

Alright, I’m looking at your file now.

Now I don’t know exactly what most of these advanced things are (like how you got the eyes to “stick” to the mesh), but I’m pretty sure that’s a feature MG won’t support. Some other things I’m noticing is that the hair isn’t weight painted, and neither is most of the face. The shoes also are missing some weight painting, and the ears are parented to the head and not the armature (and are also not weight painted).

Now, I may be wrong about all these things being a problem (I also don’t know a lot about MG animation). However, the only time I’ve gotten good results is when every single part of my mesh has been weight painted, and parented to the armature. I’m afraid that’s the best advice I can give.

that model was made by a professional graphic designer for me and I don’t know how he made it I try to correct it for MG as you can see it’s not a real success so far…

like I say I will export only mesh and play them like an atlased texture, it’s easier like this

I will retry when MG will improve the animation support :unamused:

A bit of an update as to a potential reason for a model to throw errors during importing:

I made a nice, skinned model which imported just fine into MG. However, when I temporarily parented a cylinder to one of the bones on it to test the character holding onto an object, and then deleted that cylinder, the importer started giving errors when importing it (even though I returned the model to how it was before I added the cylinder).

I’ve not been able to recreate this bug with other models I’ve created, and as long as I never attach another mesh to my character model it seems to be fine (as in, I can add more animations/bones/weights and still import it into MonoGame). So if your model refuses to import for seemingly no reason, this could be it.

I tried using both Xna Skinned sample from Microsoft and Better skinned sample from this site but still my characters get distorted as seem below:

Any ideas of what could be the problem?

Have you tried these steps? Step 1 in particular seems to cause this the most (and is the easiest to fix). I just have a 1 frame animation in my project called “Initial” which has every bone un-rotated, un-transitioned and un-scaled, and I always switch to it before I export.

Thanks for the answer.

Tried that but no dice.
But let me ask you:
Must it be the very first animation in the file?
What configuration you leave in the Foward and Up dropboxes?

I’ll try again with a new model tomorrow and see what happens.

I always do “selected”, and have my armature + the mesh which it uses selected.

I don’t know about the “first animation” part, but it does help as Blender can be a bit wonky when it comes to assigning animations to multiple different armatures (this is likely not the problem with yours, as this bug just makes certain animations not export).

As for Forward and Up, I leave those unchanged and it works fine I think.

This could also potentially be the issue: The origin of each mesh in the armature has to be at [0,0,0].

If you’re still having trouble, you can upload the .blend file and I’ll have a look at it.

If you don’t mind taking a look.
There you go:

I’m very grateful for your help.

Forgot the textures: https://1drv.ms/u/s!AtearECqJxyXiuJpFb9eBKLkwIpGHg

edit 2:
After correcting some stuff I noticed that the Y and Z axes are switched in the animation (Rotating the root bone along Y axis makes the model rotate along Z axis in game and vice versa), did I do something wrong?
The code is now exactly the same as delivered by Microsoft

edit 3:
I drawed the bones using getWorldTransforms() and I got the right positions, but the skin transform seems to be broken

Hm… well I won’t be able to test this fully until I get home much later today, but I had a quick look-over your file, and one thing which sticks out to me is that if I move the mesh, it doesn’t warp when moved away from the armature as mine does. Maybe it needs to be parented to it? I’ll check more when I get home.

Just an aside, but how did you go about showing the names of your bones? I’m still using SkinnedSample, but I couldn’t find where, if at all, the names of bones were stored.

Edit: Also, if you want a potential (not the best, and might not work) fix, maybe try setting the scale of your mesh to half before applying the bone transforms to it?

The names are not stored by default, but you can make it do so:

  • In the SkinningData Class add a new property as List to keep the names and set it in the constructor. Decorate the property with [ContentSerializer] attribute.

  • In the file “SkinnedModelProcessor”, around the line 65 theres a loop iterating through the bones, create a list and add bone.Name into the list.

  • In theline where it sets model.Tag = new SkinningData, you include this list.

  • Build the content and the output will have this new data, you can access it at runtime now through the same property.

1 Like

Hey. So I had a look see (I don’t know much about this stuff myself). I didn’t have time to test it, but try parenting the mesh to the armature, selecting “automatic weights” when Blender prompts you, and then seeing how that goes. Also, if you don’t already, try getting the latest Blender just to be safe.

By the way, here are the export settings I use (that I know work). Ignore the “scale” part. I’ve set that to many values and all it does is grow/shrink the model (without causing the issue you’re having).

I did once have a distorting model like you’ve shown. Unfortunately, my solution was to re-make it from scratch (as I didn’t quite like how it was turning out anyway). The most notable thing I did differently when I remade it however was automatically applying weights.

I wish you the best of luck.