Quantcast
Channel: Community | MonoGame - Latest topics
Viewing all articles
Browse latest Browse all 6821

Skinned Model is not visible

$
0
0

@TheNightglow wrote:

I m currently trying to add animation to my monogame project. Therefor I followed the instructions in http://community.monogame.net/t/tutorial-how-to-get-xnas-skinnedsample-working-with-monogame/7609 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..

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;
        int meshCounter = 0;

        foreach (ModelMesh mesh in _model.Meshes)
        {
            foreach (SkinnedEffect effect in mesh.Effects)
            {
                _world = Matrix.CreateScale(_scale) * Matrix.CreateWorld(_position, _upwards, _direction);
                Vector3 _col = _color * GuiStuff.GuiHandler._option._brightnessFac;
                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|Armature" 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

Posts: 2

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 6821

Trending Articles