public int Rebuild(FileOutput o) { o.WriteString("GRP "); int sizeoff = o.Size(); o.WriteInt(0); int size = o.Size(); o.WriteInt(names.Count); int start = names.Count * 8 + 4; FileOutput name = new FileOutput(); name.endian = Endianness.Little; int c = 0; foreach (string na in names) { o.WriteInt(start + name.Size()); int ns = name.Pos(); name.WriteInt(1); name.WriteByte(na.Length == 0 ? 0xFF : na.Length + 1); name.WriteString(na); name.WriteByte(0); name.Align(4); if (c != names.Count - 1) { name.WriteInt(0); // padding } else { ns -= 4; } c++; o.WriteInt(name.Pos() - ns); } o.WriteInt(0); o.WriteOutput(name); size = o.Size() - size; o.WriteIntAt(size, sizeoff); return(size); }
public byte[] Rebuild(int pos) { FileOutput f = new FileOutput(); f.endian = Endianness.Big; f.WriteInt(pos + f.Pos() + 0x20); f.WriteInt(Convert.ToInt32(unk1)); int offset = pos + f.Pos() + 0x18; offset += name.Length + 1; while (offset % 16 != 0) { offset++; } offset += 0x10; f.WriteInt(offset); f.WriteBytes(new byte[0x14]); f.WriteString(name); f.WriteByte(0); while ((pos + f.Pos()) % 16 != 0) { f.WriteByte(0); } f.WriteBytes(new byte[0x10]); f.WriteInt(frameCount); f.WriteShort(Convert.ToInt32(unk2)); f.WriteShort(frames.Count); f.WriteInt(pos + f.Pos() + 0x18); f.WriteBytes(new byte[0x14]); foreach (frame keyframe in frames) { f.WriteShort(keyframe.frameNum); f.WriteByte(keyframe.state); f.WriteByte(keyframe.unknown); } return(f.GetBytes()); }
public byte[] Rebuild(int pos) { FileOutput f = new FileOutput(); f.endian = Endianness.Big; f.WriteInt(pos + f.Pos() + 0x8); f.WriteInt(0); f.WriteInt(defaultTexId); f.WriteInt(keyframes.Count); f.WriteInt(pos + f.Pos() + 0x1C); f.WriteInt(frameCount - 1); f.WriteInt(unknown); f.WriteBytes(new byte[0x10]); foreach (keyframe k in keyframes) { f.WriteInt(k.texId); f.WriteInt(k.frameNum); } return(f.GetBytes()); }
public byte[] Rebuild(int pos) { FileOutput f = new FileOutput(); f.endian = Endianness.Big; f.WriteInt(pos + f.Pos() + 0x20); f.WriteInt(unknown); f.WriteInt(valueCount); f.WriteInt(frames.Count); f.WriteShort(unknown2); f.WriteShort(animType); int position = pos + f.Pos() + 0xC + name.Length + 1; while (position % 0x10 != 0) { position++; } f.WriteInt(position); f.WriteBytes(new byte[8]); f.WriteString(name); f.WriteByte(0); while ((pos + f.Pos()) % 0x10 != 0) { f.WriteByte(0); } foreach (frame fr in frames) { for (int i = 0; i < valueCount; i++) { f.WriteFloat(fr.values[i]); } } f.WriteBytes(new byte[0x10]); return(f.GetBytes()); }
public byte[] RebuildEntries(FileOutput f) { List <int> nameOffsets = new List <int>(); int nameTableOffset = 0x30 + (0x20 * entries.Count); FileOutput nameTable = new FileOutput() { endian = Endianness.Big }; foreach (Entry entry in entries) { nameOffsets.Add(nameTableOffset + nameTable.Pos()); nameTable.WriteString(entry.name); nameTable.WriteBytes(new byte[4 - (entry.name.Length % 4)]); //Pad to next word } while (nameTable.Pos() % 0x10 != 0) { nameTable.WriteByte(0); } for (int i = 0; i < entries.Count; i++) { entries[i].values[0] = nameOffsets[i]; } foreach (Entry entry in entries) { foreach (int value in entry.values) { f.WriteInt(value); } } f.WriteBytes(nameTable.GetBytes()); return(f.GetBytes()); }
public override byte[] Rebuild() { FileOutput f = new FileOutput(); f.endian = endianess; f.WriteInt(entries.Count); f.WriteInt(otherEntries.Count); f.WriteInt(0x30); f.WriteInt(0x20); f.WriteInt(0x8); f.WriteInt(0x30); byte[] entryData = RebuildEntries(new FileOutput()); f.WriteInt(entryData.Length + 0x30); f.WriteBytes(new byte[0x14]); f.WriteBytes(entryData); f.WriteBytes(RebuildOtherEntries(new FileOutput(), f.Pos())); return(f.GetBytes()); }
public override byte[] Rebuild() { FileOutput f = new FileOutput(); f.endian = Endianness.Big; f.WriteString("MTA4"); f.WriteUInt(unknown); f.WriteUInt(frameCount); f.WriteUInt(startFrame); f.WriteUInt(endFrame); f.WriteUInt(frameRate); f.WriteInt(matEntries.Count); if (matEntries.Count > 0) { f.WriteInt(0x38); } else { f.WriteInt(0); } f.WriteInt(visEntries.Count); if (visEntries.Count > 0) { f.WriteInt(0x38 + 4 * matEntries.Count); } else { f.WriteInt(0); } for (int i = 0; i < 0x10; i++) { f.WriteByte(0); } List <byte[]> matEntriesBuilt = new List <byte[]>(); List <byte[]> visEntriesBuilt = new List <byte[]>(); int position = 0x38 + matEntries.Count + visEntries.Count; while (position % 0x10 != 0) { position++; } foreach (MatEntry m in matEntries) { byte[] b = m.Rebuild(position); matEntriesBuilt.Add(b); f.WriteInt(position); position += b.Length; while (position % 0x10 != 0) { position++; } } foreach (VisEntry v in visEntries) { byte[] b = v.Rebuild(position); matEntriesBuilt.Add(b); f.WriteInt(position); position += b.Length; while (position % 0x10 != 0) { position++; } } while (f.Pos() % 0x10 != 0) { f.WriteByte(0); } foreach (byte[] b in matEntriesBuilt) { f.WriteBytes(b); while (f.Pos() % 0x10 != 0) { f.WriteByte(0); } } foreach (byte[] b in visEntriesBuilt) { f.WriteBytes(b); while (f.Pos() % 0x10 != 0) { f.WriteByte(0); } } return(f.GetBytes()); }
public byte[] Rebuild(int pos) { FileOutput f = new FileOutput(); f.endian = Endianness.Big; f.WriteInt(pos + f.Pos() + 0x20); f.WriteInt(matHash); f.WriteInt(properties.Count); int nameOffset = pos + f.Pos() + 0x15 + name.Length; while (nameOffset % 4 != 0) { nameOffset++; } f.WriteInt(nameOffset); f.WriteFlag(hasPat); f.WriteBytes(new byte[3]); //Write all the mat data into a buffer (g) then write pat offset int pos2 = pos + f.Pos() + 4; FileOutput g = new FileOutput(); g.endian = Endianness.Big; if (matHash2 != 0) { g.WriteInt(pos2 + g.Pos() + 0x8); g.WriteInt(matHash); } else { g.WriteBytes(new byte[8]); } g.WriteString(name); g.WriteByte(0); while ((pos2 + g.Pos()) % 0x10 != 0) { g.WriteByte(0); } int position = pos2 + g.Pos() + properties.Count * 4; while (position % 16 != 0) { position++; } List <byte[]> builtProperties = new List <byte[]>(); foreach (MatData prop in properties) { g.WriteInt(position); byte[] b = prop.Rebuild(position); builtProperties.Add(b); position += b.Length; while (position % 16 != 0) { position++; } } while ((pos2 + g.Pos()) % 16 != 0) { g.WriteByte(0); } foreach (byte[] b in builtProperties) { g.WriteBytes(b); while ((pos2 + g.Pos()) % 16 != 0) { g.WriteByte(0); } } f.WriteInt(pos2 + g.Pos()); f.WriteBytes(g.GetBytes()); if (hasPat) { f.WriteBytes(pat0.Rebuild(f.Pos())); } return(f.GetBytes()); }