Mesh ConvertMesh(AssimpMesh M, Material[] Materials)
{
Mesh Msh = new Mesh();
Vector3[] Verts = M.Vertices.Select((V) => new Vector3(V.X, V.Y, V.Z)).ToArray();
Msh.SetVertices(Verts);
Vector2[] UVs = M.TextureCoordinateChannels[0].Select((V) => new Vector2(V.X, V.Y)).ToArray();
if (UVs.Length > 0)
{
Msh.SetUVs(UVs);
}
Vector4[] Colors = M.VertexColorChannels[0].Select((C) => new Vector4(C.R, C.G, C.B, C.A)).ToArray();
if (Colors.Length > 0)
{
Msh.SetColors(Colors);
}
uint[] Indices = M.GetUnsignedIndices();
if (Indices.Length > 0)
{
Msh.SetElements(Indices);
}
if (Materials != null)
{
Msh.Material = Materials[M.MaterialIndex];
}
return(Msh);
}