I’ve made a model in Blender and imported it to Monogame with Aether.Extras CPU_AnimatedModel.
Then I’m drawing the model through this method:
public void DrawModelCameraFromList(FirstPersonCamera camera, IEnumerable<Entity> entities)
{
foreach (Entity entity in entities)
{
Matrix[] transforms = new Matrix[entity.Model.Bones.Count];
entity.Model.CopyAbsoluteBoneTransformsTo(transforms);
foreach (ModelMesh mesh in entity.Model.Meshes)
{
foreach (ModelMeshPart part in mesh.MeshParts)
{
((BasicEffect)part.Effect).SpecularColor = Vector3.Zero;
ConfigureEffectMatrices((IEffectMatrices)part.Effect, Matrix.CreateRotationY(entity.Rotation.Y) * entity.RenderCollisionPositionMatrix, camera.View, camera.Projection);
ConfigureEffectLightning((IEffectLights)part.Effect);
if (entity is AnimatedEntity animatedEntity)
part.UpdateVertices(animatedEntity.Animations.AnimationTransforms);
}
mesh.Draw();
}
}
}
The models are drawn, and the animation are looping, but the models different parts overlap each other, and the eyes and nose are shown from behind.
From front:
From behind:
I am also running this code every Update:
graphicsDevice.BlendState = BlendState.Opaque;
graphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;
graphicsDevice.DepthStencilState = DepthStencilState.Default;
graphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;
Need some tips how to fix this problem.