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); } } } }
public void AddSkeletonEntry(KBFEntry entry) { skeletonEntries.Add(entry); }
public void AddMaterialEntry(KBFEntry entry) { materialEntries.Add(entry); }
public void AddTextureEntry(KBFEntry entry) { textureEntries.Add(entry); }
public void AddMeshEntry(KBFEntry entry) { meshEntries.Add(entry); }