I m currently trying to add animation to my monogame project. Therefor I followed the instructions in Tutorial: How to get XNA's SkinnedSample working with MonoGame which are for monogame 3.5…
Hoping they also work for 3.6, otherwise that might already be the problem, since I m working with 3.6…
well anyway, it all builds fine though I can not see the Model at all, however the draw function is executed…
I created that Pipeline extension project like in that tutorial, referenced it in the content pipeline and referenced the SkinnedModel in the main project
here is what I have done, maybe somebody sees my mistake:
Code in the projekt:
public override void Load()
{
base.Load();
_model = Global.ContentManager.Load<Model>("GameAssets/Enemies/Family/2/model2");
// Look up our custom skinning information.
SkinnedModel.SkinningData skinningData = _model.Tag as SkinnedModel.SkinningData;
if (skinningData == null)
throw new InvalidOperationException
("This model does not contain a SkinningData tag.");
// Create an animation player, and start decoding an animation clip.
_aniPlayer = new SkinnedModel.AnimationPlayer(skinningData);
SkinnedModel.AnimationClip clip = skinningData.AnimationClips["skeleton|ArmatureAction"];
_aniPlayer.StartClip(clip);
}
public override void Update(GameTime gameTime)
{
_aniPlayer.Update(gameTime.ElapsedGameTime, true, Matrix.Identity);
…
}
public override void Draw(GameTime gameTime)
{
Matrix[] bones = _aniPlayer.GetSkinTransforms();
// Look up the absolute bone transforms for this model.
Matrix[] boneTransforms = new Matrix[_model.Bones.Count];
_model.CopyAbsoluteBoneTransformsTo(boneTransforms);
Global.graphics.GraphicsDevice.DepthStencilState = DepthStencilState.Default;
foreach (ModelMesh mesh in _model.Meshes)
{
foreach (SkinnedEffect effect in mesh.Effects)
{
_world = Matrix.CreateScale(_scale) * Matrix.CreateWorld(_position, _upwards, _direction);
effect.SetBoneTransforms(bones);
effect.World = boneTransforms[mesh.ParentBone.Index] * _world;
effect.View = Global.GameCamera._viewMatrix;
effect.Projection = Global.GameCamera._projectionMatrix;
effect.EnableDefaultLighting();
effect.SpecularColor = new Vector3(0.25f);
effect.SpecularPower = 16;
effect.Techniques[0].Passes[0].Apply();
}
mesh.Draw();
}
}
most from the load function is copied from the skinnedSample from the link, the model loaded above is an fbx with animation, builded with Skinned Model Processor
“skeleton|ArmatureAction” appears to be the name of the animation clip, I got it while debugging… seems to be the name of my model armature | the name of the action
I tried a varierty of things in the draw method, I m not sure if I use the bones or boneTransforms matrix wrong… I already tryed switching them around or calculating world without another transformation matrix…
when I comment out everything related to the SkinnedModel and change SkinnedEffect to BasicEffect and rebuild the model with the normal Model processor, than it is displayed, but not with animation
it might aswell be a problem with the model:
I added armature to a model of a friend of mine, and added an very basic animation, just to test it in monogame
I used the default settings to export it to fbx, just that I changed Apply Scaling from All local to All fbx