public void ExportTEX(string filename) { FileOutput o = new FileOutput(); o.Endian = Endianness.Little; o.writeInt(pictureBox1.Image.Width); o.writeInt(pictureBox1.Image.Height); o.writeByte(formatSelector.SelectedIndex); o.writeByte(1); o.writeShort(0); o.writeString(nameBox.Text); for (int i = 0; i < 0x74 - nameBox.Text.Length; i++) { o.writeByte(0); } pictureBox1.Image.RotateFlip(RotateFlipType.RotateNoneFlipY); o.writeBytes(_3DS.EncodeImage(new Bitmap(pictureBox1.Image), (_3DS.Tex_Formats)formatSelector.SelectedIndex)); pictureBox1.Image.RotateFlip(RotateFlipType.RotateNoneFlipY); o.save(filename); }
public override byte[] Rebuild() { FileOutput buf = new FileOutput(); buf.Endian = Endianness.Little; var flagsOffset = 0x10; var entriesOffset = flagsOffset + (atlases.Count * 4); var stringsOffset = entriesOffset + (textures.Count * 0x20); buf.writeInt(0x544C5354); // TLST buf.writeShort(0); // idk buf.writeShort((short)atlases.Count); buf.writeShort((short)textures.Count); buf.writeShort((short)flagsOffset); buf.writeShort((short)entriesOffset); buf.writeShort((short)stringsOffset); // flags foreach (var flag in atlases) { buf.writeInt((int)flag); } // entries int namePtr = 0; foreach (var texture in textures) { buf.writeInt(namePtr); buf.writeInt(namePtr); namePtr += texture.name.Length + 1; buf.writeFloat(texture.topLeft.X); buf.writeFloat(texture.topLeft.Y); buf.writeFloat(texture.botRight.X); buf.writeFloat(texture.botRight.Y); buf.writeShort(texture.width); buf.writeShort(texture.height); buf.writeShort(texture.atlasId); buf.writeShort(0); // pad } //strings foreach (var texture in textures) { buf.writeString(texture.name); buf.writeByte(0); } buf.writeByte(0); return(buf.getBytes()); }
public int Rebuild(FileOutput o) { int size = o.size(); o.writeInt(hash); o.writeInt(unk1); o.writeByte(name.Length + 1); o.writeString(name); o.writeByte(0); o.align(4); o.writeInt(0); o.writeInt(8); o.writeInt(offset); o.writeInt(this.size); // write data foreach (float f in param) { o.writeFloat(f); } o.writeInt(offsets.Length); foreach (int f in offsets) { o.writeInt(f); } o.writeInt(unkvalues.Length); int v = 0; foreach (float f in unkvalues) { o.writeInt(v++); o.writeFloat(f); } foreach (int f in unkending) { o.writeInt(f); } foreach (int f in end) { o.writeInt(f); } return(o.size() - size); }
public void save(FileOutput f) { base.save(f); f.writeByte(1); f.writeHex("0984000101"); f.writeByte(1); f.writeInt(sections.Count); foreach (Section s in sections) { s.save(f); } }
public void save(FileOutput f) { f.writeByte(1); f.writeHex("03000000040000000000000000000000000000000001"); f.writeByte(1); f.writeInt(points.Count); foreach (Vector2D v in points) { f.writeByte(1); f.writeFloat(v.x); f.writeFloat(v.y); } }
} // Read() #region serialization void writeSymbols(FileOutput o) { FileOutput tag = new FileOutput(); tag.writeInt(Strings.Count); Console.WriteLine($"Strings = [ // offset=0x{o.size():X2}"); for (int i = 0; i < Strings.Count; i++) { var str = Strings[i]; Console.WriteLine($"\t0x{i:X3}: \"{str}\""); var strBytes = Encoding.UTF8.GetBytes(str); tag.writeInt(strBytes.Length); tag.writeBytes(strBytes); int padSize = 4 - (tag.size() % 4); for (int j = 0; j < padSize; j++) { tag.writeByte(0); } } Console.WriteLine("]\n"); o.writeInt((int)TagType.Symbols); o.writeInt(tag.size() / 4); o.writeOutput(tag); }
public void save(FileOutput f) { base.save(f); f.writeByte(1); f.writeInt(type); f.writeFloat(x); f.writeFloat(y); f.writeFloat(z); if (type == 2) { f.writeFloat(radius); f.writeFloat(dx); f.writeFloat(dy); f.writeFloat(dz); } else if (type == 3) { f.writeFloat(dx); f.writeFloat(dy); f.writeFloat(dz); f.writeFloat(radius); } f.writeFloat(unk); f.writeHex("00"); }
public void save(FileOutput f) { base.save(f); f.writeByte(1); f.writeInt(0); }
public void save(FileOutput f) { base.save(f); f.writeByte(1); f.writeFloat(x); f.writeFloat(y); }
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 override void save(FileOutput f) { f.writeHex("010401017735BB750000000201"); f.writeChars(name.PadRight(0x38).ToCharArray()); f.writeByte(1); f.writeChars(subname.PadRight(0x40).ToCharArray()); f.writeHex("0100000000000000000000000000010000000001000000000000000000000000FFFFFFFF010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001014C800203"); f.writeInt(type); f.writeHex("000000000000000000000000000000000101"); f.writeInt(points.Count); foreach (Vector2D point in points) { f.writeByte(1); f.writeFloat(point.x); f.writeFloat(point.y); } }
public void WriteVertex(FileOutput f, ref Vertex v) { switch (type) { case (int)_3DSGPU.VertexAttribute.pos: WriteType(f, v.pos.X); WriteType(f, v.pos.Y); WriteType(f, v.pos.Z); break; case (int)_3DSGPU.VertexAttribute.nrm: WriteType(f, v.nrm.X); WriteType(f, v.nrm.Y); WriteType(f, v.nrm.Z); WriteType(f, 1f); break; case (int)_3DSGPU.VertexAttribute.tx0: WriteType(f, v.tx.X); WriteType(f, v.tx.Y); break; case (int)_3DSGPU.VertexAttribute.col: WriteType(f, v.col.X); WriteType(f, v.col.Y); WriteType(f, v.col.Z); WriteType(f, v.col.W); break; case (int)_3DSGPU.VertexAttribute.bone: f.writeByte((int)v.bone.X); f.writeByte((int)v.bone.Y); break; case (int)_3DSGPU.VertexAttribute.weight: WriteType(f, v.weight.X); WriteType(f, v.weight.Y); break; default: Console.WriteLine("Error"); break; } }
public void save(FileOutput f) { base.save(f); f.writeByte(1); f.writeFloat(left); f.writeFloat(right); f.writeFloat(top); f.writeFloat(bottom); }
public void save(FileOutput f) { base.save(f); f.writeByte(1); f.writeFloat(pos.x); f.writeFloat(pos.y); f.writeFloat(angle.x); f.writeFloat(angle.y); }
public int Rebuild(FileOutput o) { int size = o.size(); o.writeInt(hash); o.writeInt(unk1); o.writeByte(name.Length + 1); o.writeString(name); o.writeByte(0); o.align(4); // write data foreach (float f in data) { o.writeFloat(f); } return(o.size() - size); }
public void save(FileOutput f) { f.writeHex("010401017735BB750000000201"); f.writeChars(name.PadRight(0x38, (char)0).ToCharArray()); f.writeByte(1); f.writeChars(subname.PadRight(0x40, (char)0).ToCharArray()); f.writeHex("0100000000000000000000000000010000000001000000000000000000000000FFFFFFFF010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001098400010101"); f.writeInt(sections.Count); foreach (Section s in sections) { f.writeHex("010300000004000000000000000000000000000000000101"); f.writeInt(s.points.Count); foreach (Vector2D p in s.points) { f.writeByte(1); f.writeFloat(p.x); f.writeFloat(p.y); } } }
public void save(FileOutput f) { base.save(f); f.writeHex("0101"); f.writeInt(sections.Count); foreach (EnmSection temp in sections) { temp.save(f); } f.writeHex("0101"); f.writeInt(sections2.Count); foreach (EnmSection temp in sections2) { temp.save(f); } f.writeHex("0101"); f.writeInt(0); f.writeByte(1); f.writeInt(id); f.writeByte(1); f.writeInt(ids.Count); foreach (int temp in ids) { f.writeByte(1); f.writeInt(temp); } f.writeByte(1); f.writeInt(0); f.writeByte(1); f.writeInt(padCount); for (int i = 0; i < padCount; i++) { f.writeHex("0100000000"); } }
private static void writeType(FileOutput d, float value, int format, float scale) { switch (format) { case 0: d.writeFloat(value / scale); break; case 1: d.writeByte((byte)(value / scale)); break; case 2: d.writeByte((byte)(value / scale)); break; case 3: d.writeShort((short)(value / scale)); break; } }
private void WriteType(FileOutput d, float data) { switch (format) { case 0: d.writeFloat(data / scale); break; case 1: d.writeByte((byte)(data / scale)); break; case 2: d.writeByte((sbyte)(data / scale)); break; case 3: d.writeShort((int)(data / scale)); break; } }
public int Rebuild(FileOutput o) { o.writeString("BINF"); int sizeoff = o.size(); o.writeInt(0); int size = o.size(); o.writeInt(0); o.writeInt(unk1); o.writeByte(name.Length + 1); o.writeString(name); o.writeByte(0); o.align(4); o.writeInt(flag); size = o.size() - size; o.writeIntAt(size, sizeoff); return(size); }
public override void save(FileOutput f) { f.writeHex("010401017735BB750000000201"); f.writeChars(name.PadRight(0x38).ToCharArray()); f.writeByte(1); f.writeChars(subname.PadRight(0x40).ToCharArray()); f.writeHex("0100000000000000000000000000010000000001000000000000000000000000FFFFFFFF010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001014C800203"); f.writeInt(type); f.writeFloat(x); f.writeFloat(y); f.writeHex("0000000000000000010100000000"); }
public void save(FileOutput f) { base.save(f); f.writeByte(1); f.writeInt(type); f.writeFloat(x); f.writeFloat(y); f.writeFloat(z); f.writeHex("00000000000000000000000000000000"); }
public void save(FileOutput f) { f.writeHex(magic); f.writeByte(1); f.writeString(name.PadRight(0x38, (char)0)); f.writeByte(1); f.writeString(subname.PadRight(0x40, (char)0)); f.writeByte(1); for (int i = 0; i < 3; i++) { f.writeFloat(startPos[i]); } f.writeFlag(useStartPos); f.writeByte(1); f.writeInt(unk1); f.writeByte(1); foreach (float i in unk2) { f.writeFloat(i); } f.writeInt(unk3); f.writeByte(1); f.writeChars(boneName); }
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(unknown3); 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[] 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 void save(FileOutput f) { base.save(f); f.writeByte(0x3); f.writeInt(type); f.writeFloat(x1); f.writeFloat(y1); f.writeFloat(x2); f.writeFloat(y2); f.writeByte(1); f.writeByte(1); f.writeInt(points.Count); foreach (Vector2D point in points) { f.writeByte(1); f.writeFloat(point.x); f.writeFloat(point.y); } }
public override byte[] Rebuild() { FileOutput file = new FileOutput(); if (file != null) { if (Endian == Endianness.Little) { file.Endian = Endianness.Little; file.writeString(" NBV"); } if (Endian == Endianness.Big) { file.Endian = Endianness.Big; file.writeString("VBN "); } file.writeShort(0x01); file.writeShort(0x02); file.writeInt(bones.Count); if (boneCountPerType[0] == 0) boneCountPerType[0] = (uint)bones.Count; for (int i = 0; i < 4; i++) file.writeInt((int)boneCountPerType[i]); for (int i = 0; i < bones.Count; i++) { file.writeString(new string(bones[i].boneName)); for (int j = 0; j < 64 - bones[i].boneName.Length; j++) file.writeByte(0); file.writeInt((int)bones[i].boneType); if(bones[i].parentIndex == -1) file.writeInt(0x0FFFFFFF); else file.writeInt(bones[i].parentIndex); file.writeInt((int)bones[i].boneId); } for (int i = 0; i < bones.Count; i++) { file.writeFloat(bones[i].position[0]); file.writeFloat(bones[i].position[1]); file.writeFloat(bones[i].position[2]); file.writeFloat(bones[i].rotation[0]); file.writeFloat(bones[i].rotation[1]); file.writeFloat(bones[i].rotation[2]); file.writeFloat(bones[i].scale[0]); file.writeFloat(bones[i].scale[1]); file.writeFloat(bones[i].scale[2]); } } return file.getBytes(); }
public void ExportTEX(string filename) { FileOutput o = new FileOutput(); o.Endian = Endianness.Little; o.writeInt(pictureBox1.Image.Width); o.writeInt(pictureBox1.Image.Height); o.writeByte(formatSelector.SelectedIndex); o.writeByte(1); o.writeShort(0); o.writeString(nameBox.Text); for (int i = 0; i < 0x74 - nameBox.Text.Length; i++) { o.writeByte(0); } pictureBox1.Image.RotateFlip(RotateFlipType.RotateNoneFlipY); if (formatSelector.SelectedIndex == 0x0C) { o.writeBytes(Pixel.encodeETC(new Bitmap(pictureBox1.Image))); } if (formatSelector.SelectedIndex == 0x0D) { o.writeBytes(Pixel.encodeETCa4(new Bitmap(pictureBox1.Image))); } else { throw new Exception("Unsuppored format"); } pictureBox1.Image.RotateFlip(RotateFlipType.RotateNoneFlipY); o.save(filename); }
public int Rebuild(FileOutput o) { o.writeString("PROP"); int sizeoff = o.size(); o.writeInt(0); int size = o.size(); o.writeInt(0); o.writeInt(unk1); o.writeShort(0); o.writeShort(unk2); o.writeByte(project.Length + 1); o.writeString(project); o.writeByte(0); o.writeByte(0); o.writeByte(0); o.writeByte(0); o.align(4); o.writeShort(unk3); o.align(4); o.writeByte(timestamp.Length + 1); o.writeString(timestamp); o.writeByte(0); o.writeByte(0); o.writeByte(0); o.writeByte(0); o.align(4); size = o.size() - size; o.writeIntAt(size, sizeoff); return(size); }
public void save(FileOutput f) { base.save(f); f.writeFlag(flag1); f.writeFlag(flag2); f.writeFlag(flag3); f.writeFlag(flag4); f.writeByte(1); f.writeInt(verts.Count); foreach (Vector2D v in verts) { f.writeByte(1); f.writeFloat(v.x); f.writeFloat(v.y); } f.writeByte(1); f.writeInt(normals.Count); foreach (Vector2D n in normals) { f.writeByte(1); f.writeFloat(n.x); f.writeFloat(n.y); } f.writeByte(1); f.writeInt(cliffs.Count); foreach (CollisionCliff c in cliffs) { c.save(f); } f.writeByte(1); f.writeInt(materials.Count); foreach (CollisionMat m in materials) { f.writeByte(1); f.writeBytes(m.material); } }