XNA Weird Mesh result


Hello everyone and a happy new year!

I'm having trouble displaying a network on the screen loaded by assimp.

This is how it looks

Enter image description here

Here is my code to load …

interface IMesh
{
    Mesh.MeshEntry() SubMeshes { get; }

    void Render(
        GameWindow gameWindow,
        ITransform transform,
        ICamera camera);
}

public class Mesh : IMesh
{
    internal struct MeshEntry
    {
        internal int materialIndex;
        public VertexPositionNormalTexture() buffer;
        public int() indices;

        public MeshEntry(Assimp.Mesh mesh)
        {
            float() vertices = new float(0);
            float() normals = new float(0);
            float() uvs = new float(0);
            indices = new int(0);

            if (mesh.HasVertices)
            {
                vertices = new float(mesh.VertexCount * 3);
                int i = 0;
                foreach (var vertex in mesh.Vertices)
                {
                    vertices(i) = vertex.X;
                    vertices(i + 1) = vertex.Y;
                    vertices(i + 2) = vertex.Z;
                    i += 3;
                }
            }

            if (mesh.HasTextureCoords(0))
            {
                uvs = new float(mesh.VertexCount * 2);

                int i = 0;
                foreach (Vector3D vertex in mesh.TextureCoordinateChannels(0))
                {
                    uvs(i) = vertex.X;
                    uvs(i + 1) = vertex.Y;
                    i += 2;
                }
            }

            if (mesh.HasNormals)
            {
                normals = new float(mesh.Normals.Count * 3);
                int i = 0;
                foreach (var vertex in mesh.Normals)
                {
                    normals(i) = vertex.X;
                    normals(i + 1) = vertex.Y;
                    normals(i + 2) = vertex.Z;
                    i+= 3;
                }
            }

            if (mesh.HasFaces)
            {
                indices = new int(mesh.FaceCount * 3);
                int i = 0;
                foreach (Face face in mesh.Faces)
                {
                    indices(i) = face.Indices(0);
                    indices(i + 1) = face.Indices(1);
                    indices(i + 2) = face.Indices(2);
                    i += 3;
                }
            }

            materialIndex = mesh.MaterialIndex;
            buffer = new VertexPositionNormalTexture(mesh.VertexCount);

            for (int i = 0, j = 0; i < vertices.Length; i += 3, j++)
                buffer(j).Position = 
                    new Microsoft.Xna.Framework.Vector3(
                        vertices(i),
                        vertices(i + 1), 
                        vertices(i + 2));

            for (int i = 0, j = 0; i < normals.Length; i += 3, j++)
                buffer(j).Normal =
                    new Microsoft.Xna.Framework.Vector3(
                        normals(i), normals(i + 1), normals(i + 2));

            for (int i = 0, j = 0; i < uvs.Length; i += 2, j++)
                buffer(j).TextureCoordinate =
                    new Microsoft.Xna.Framework.Vector2(
                        uvs(i), uvs(i + 1));
        }

        public void Draw(GameWindow gameWindow)
        {
            gameWindow.MeshBatch.Draw(this);
        }
    }

    private MeshEntry() SubMeshes { get; set; }

    Mesh.MeshEntry() IMesh.SubMeshes => SubMeshes;

    Mesh()
    {

    }

    void IMesh.Render(
        GameWindow gameWindow,
        ITransform transform,
        ICamera camera)
    {
        foreach (MeshEntry entry in SubMeshes)
            entry.Draw(gameWindow);
    }

    internal static Mesh FromFile(string filename)
    {
        Mesh mesh = new Mesh();

        Assimp.AssimpContext importer = new AssimpContext();

        Assimp.Scene scene = importer.ImportFile(
            filename,
            PostProcessSteps.Triangulate |
            PostProcessSteps.GenerateNormals |
            PostProcessSteps.CalculateTangentSpace |
            PostProcessSteps.SortByPrimitiveType |
            PostProcessSteps.GenerateUVCoords | 
            PostProcessSteps.OptimizeMeshes |
            PostProcessSteps.OptimizeGraph);

        mesh.SubMeshes = new MeshEntry(scene.MeshCount);
        int i = 0;
        foreach (Assimp.Mesh entry in scene.Meshes)
        {
            mesh.SubMeshes(i) = new MeshEntry(entry);
            i++;
        }

        importer.Dispose();

        return mesh;
    }
}

I am trying to change my code from OpenGL to MonoGame and, oddly enough, it works on OpenGL. I'm not sure what's going on.

I draw the net like this

GraphicsDevice.DrawUserIndexedPrimitives(
            PrimitiveType.TriangleList,
            vertexArray, 0, vertexArray.Length,
            triangles, 0, triangles.Length / 3,
            VertexPositionNormalTexture.VertexDeclaration);