public static Kn5 FromFile(string filename, IKn5TextureLoader textureLoader = null, IKn5MaterialLoader materialLoader = null,
IKn5NodeLoader nodeLoader = null)
{
if (!File.Exists(filename))
{
throw new FileNotFoundException(filename);
}
var kn5 = new Kn5(filename);
(textureLoader = textureLoader ?? DefaultKn5TextureLoader.Instance).OnNewKn5(filename);
(materialLoader = materialLoader ?? DefaultKn5MaterialLoader.Instance).OnNewKn5(filename);
(nodeLoader = nodeLoader ?? DefaultKn5NodeLoader.Instance).OnNewKn5(filename);
using (var reader = new Kn5Reader(filename)) {
kn5.FromFile_Header(reader);
kn5.FromFile_Textures(reader, textureLoader);
if (nodeLoader != SkippingNodeLoader.Instance || materialLoader != SkippingMaterialLoader.Instance)
{
kn5.FromFile_Materials(reader, materialLoader);
kn5.FromFile_Nodes(reader, nodeLoader);
}
}
return(kn5);
}