Beispiel #1
0
        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);
        }
Beispiel #2
0
        public static Kn5 FromStream(Stream entry, IKn5TextureLoader textureLoader = null, IKn5MaterialLoader materialLoader = null,
                                     IKn5NodeLoader nodeLoader = null)
        {
            var kn5 = new Kn5(string.Empty);

            using (var reader = new Kn5Reader(entry)) {
                kn5.FromFile_Header(reader);
                kn5.FromFile_Textures(reader, textureLoader ?? DefaultKn5TextureLoader.Instance);
                if (nodeLoader != SkippingNodeLoader.Instance || materialLoader != SkippingMaterialLoader.Instance)
                {
                    kn5.FromFile_Materials(reader, materialLoader ?? DefaultKn5MaterialLoader.Instance);
                    kn5.FromFile_Nodes(reader, nodeLoader ?? DefaultKn5NodeLoader.Instance);
                }
            }

            return(kn5);
        }
Beispiel #3
0
 public static IKn5 FromStream(Stream entry, IKn5TextureLoader textureLoader = null, IKn5MaterialLoader materialLoader = null,
                               IKn5NodeLoader nodeLoader = null)
 {
     return(Factory.FromStream(entry, textureLoader, materialLoader, nodeLoader));
 }
Beispiel #4
0
 public static IKn5 FromFile(string filename, IKn5TextureLoader textureLoader = null, IKn5MaterialLoader materialLoader = null,
                             IKn5NodeLoader nodeLoader = null)
 {
     return(Factory.FromFile(filename, textureLoader, materialLoader, nodeLoader));
 }
Beispiel #5
0
 private void FromFile_Nodes(Kn5Reader reader, [NotNull] IKn5NodeLoader nodeLoader)
 {
     NodeLoader = nodeLoader;
     RootNode   = nodeLoader.LoadNode(reader);
 }