コード例 #1
0
        public void Read(Stream stream)
        {
            BinaryReader reader = new BinaryReader(stream);
            byte         b      = reader.ReadByte();

            byte[] bytes = reader.ReadBytes(b);

            string str = Encoding.UTF8.GetString(bytes);

            if (str != KBF_HEADER)
            {
                //Invalid File Format
                throw new KBFInvalidFileFormatException("Invalid KBF File format!");
            }

            while (reader.PeekChar() != -1)
            {
                b     = reader.ReadByte();
                bytes = reader.ReadBytes(b);
                if (Encoding.UTF8.GetString(bytes) == "end")
                {
                    break;
                }
                else
                {
                    string name = Encoding.UTF8.GetString(bytes);

                    b     = reader.ReadByte();
                    bytes = reader.ReadBytes(b);
                    string type = Encoding.UTF8.GetString(bytes);

                    b     = reader.ReadByte();
                    bytes = reader.ReadBytes(b);

                    KBFEntry entry = new KBFEntry(name, type, bytes);
                    if (type == "mesh")
                    {
                        meshEntries.Add(entry);
                    }
                    else if (type == "material")
                    {
                        materialEntries.Add(entry);
                    }
                    else if (type == "texture")
                    {
                        textureEntries.Add(entry);
                    }
                }
            }
        }
コード例 #2
0
 public void AddSkeletonEntry(KBFEntry entry)
 {
     skeletonEntries.Add(entry);
 }
コード例 #3
0
 public void AddMaterialEntry(KBFEntry entry)
 {
     materialEntries.Add(entry);
 }
コード例 #4
0
 public void AddTextureEntry(KBFEntry entry)
 {
     textureEntries.Add(entry);
 }
コード例 #5
0
 public void AddMeshEntry(KBFEntry entry)
 {
     meshEntries.Add(entry);
 }