public void Read(EndianBinaryReader r) { if (r.ReadUInt32() != 0x47315447) { MessageBox.Show("This file is not a valid Koei Tecmo G1T.", "Invalid file"); return; } Version = r.ReadUInt32(); if (Version != 0x30303630 && Version != 0x30303631 && Version != 0x30303632) { MessageBox.Show("This version of the G1T format is unsupported.", "Unsupported version"); return; } FileSize = r.ReadUInt32(); if (FileSize != r.Length) { MessageBox.Show("There is a mismatch between the reported file size and the actual one.", "File size mismatch"); return; } uint offsetTableAddress = r.ReadUInt32(); uint texCount = r.ReadUInt32(); UnkValue1 = r.ReadUInt32(); //0x10 or 0xA, no idea what the difference is uint unk2 = r.ReadUInt32(); uint[] normalMapFlags = r.ReadUInt32s((int)texCount); uint[] offsetTable = r.ReadUInt32s((int)texCount); for (int i = 0; i < texCount; i++) { G1Texture texture = new G1Texture(); r.SeekBegin(offsetTableAddress + offsetTable[i]); texture.NormalMapFlags = normalMapFlags[i]; texture.Read(r); Textures.Add(texture); } }
public void Read(byte[] file) { using (var r = new EndianBinaryReader(new MemoryStream(file), Endianness.Little)) { if (r.ReadUInt32() != 0x47315447) { MessageBox.Show("This file is not a valid Koei Tecmo G1T.", "Invalid file"); return; } Version = r.ReadUInt32(); if (Version != 0x30303630 && Version != 0x30303631 && Version != 0x30303632) { MessageBox.Show("This version of the G1T format is unsupported.", "Unsupported version"); return; } FileSize = r.ReadUInt32(); uint offsetTableAddress = r.ReadUInt32(); uint texCount = r.ReadUInt32(); UnkValue1 = r.ReadUInt32(); //0x10 or 0xA, no idea what the difference is uint unk2 = r.ReadUInt32(); uint[] normalMapFlags = r.ReadUInt32s((int)texCount); uint[] offsetTable = r.ReadUInt32s((int)texCount); for (int i = 0; i < texCount; i++) { G1Texture texture = new G1Texture(); r.SeekBegin(offsetTableAddress + offsetTable[i]); texture.NormalMapFlags = normalMapFlags[i]; texture.Read(r); Textures.Add(texture); } } }
public void AddTexture(G1Texture texture) { Textures.Add(texture); }