AcTools.Kn5File.Kn5.FromFile_Nodes C# (CSharp) Method

FromFile_Nodes() private method

private FromFile_Nodes ( Kn5Reader reader ) : void
reader Kn5Reader
return void
        private void FromFile_Nodes(Kn5Reader reader) {
            var nodesStart = reader.BaseStream.Position;
            var nodesLength = reader.BaseStream.Length - nodesStart;
            NodesBytes = reader.ReadBytes((int)nodesLength);
            reader.BaseStream.Seek(nodesStart, SeekOrigin.Begin);

            try {
                RootNode = FromFile_Node(reader);
            } catch (NotImplementedException) {
                RootNode = null;
            }
        }

Usage Example

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);
        }
All Usage Examples Of AcTools.Kn5File.Kn5::FromFile_Nodes