예제 #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);
 }