private void SaveMaterialToFile(string fileName) { FileOutput m = new FileOutput(); FileOutput s = new FileOutput(); int[] c = NUD.WriteMaterial(m, currentMaterialList, s); FileOutput fin = new FileOutput(); fin.writeInt(0); fin.writeInt(20 + c[0]); for (int i = 1; i < 4; i++) { fin.writeInt(c[i] == c[i - 1] ? 0 : 20 + c[i]); } for (int i = 0; i < 4 - c.Length; i++) { fin.writeInt(0); } fin.writeOutput(m); fin.align(32, 0xFF); fin.writeIntAt(fin.size(), 0); fin.writeOutput(s); fin.save(fileName); }
public override void Save() { FileOutput o = new FileOutput(); byte[] n = Lumen.Rebuild(); o.writeBytes(n); o.save(Lumen.Filename); }
public void ExportBNTX(string filename) { FileOutput o = new FileOutput(); o.Endian = Endianness.Little; o.save(filename); }
public DRP(string fname) { Text = Path.GetFileNameWithoutExtension(fname); var o = new FileOutput(); o.writeBytes(Decrypt(new FileData(fname))); o.save(fname + "_dec"); Read(new FileData(Decrypt(new FileData(fname)))); }
public void SaveAs(object sender, EventArgs args) { if (Runtime.TargetVBN == null) { MessageBox.Show("You must have a bone-set (VBN) selected to save animations."); return; } using (var sfd = new SaveFileDialog()) { sfd.Filter = "Supported Files (.omo, .anim, .smd)|*.omo;*.anim;*.smd|" + "Maya Anim (.anim)|*.anim|" + "Object Motion (.omo)|*.omo|" + "Source Animation (.smd)|*.smd|" + "All Files (*.*)|*.*"; sfd.DefaultExt = "smd"; //Set a default extension to prevent crashing if not specified by user if (sfd.ShowDialog() == DialogResult.OK) { sfd.FileName = sfd.FileName; if (sfd.FileName.EndsWith(".anim")) { if (Tag is AnimTrack) { ((AnimTrack)Tag).createANIM(sfd.FileName, Runtime.TargetVBN); } else { ANIM.CreateANIM(sfd.FileName, this, Runtime.TargetVBN); } } if (sfd.FileName.EndsWith(".omo")) { if (Tag is FileData) { FileOutput o = new FileOutput(); o.writeBytes(((FileData)Tag).getSection(0, ((FileData)Tag).size())); o.save(sfd.FileName); } else { File.WriteAllBytes(sfd.FileName, OMOOld.CreateOMOFromAnimation(this, Runtime.TargetVBN)); } } if (sfd.FileName.EndsWith(".smd")) { SMD.Save(this, Runtime.TargetVBN, sfd.FileName); } } } }
public void SaveAs(object sender, EventArgs args) { if (Runtime.TargetVBN == null) { MessageBox.Show("You must have a bone set (VBN) open before saving animations"); return; } using (var sfd = new SaveFileDialog()) { sfd.Filter = "Supported Files (.omo, .anim, .smd)|*.omo;*.anim;*.smd|" + "Maya Anim (.anim)|*.anim|" + "Object Motion (.omo)|*.omo|" + "Source Animation (.smd)|*.smd|" + "All Files (*.*)|*.*"; if (sfd.ShowDialog() == DialogResult.OK) { sfd.FileName = sfd.FileName; if (sfd.FileName.EndsWith(".anim")) { if (Tag is AnimTrack) { ((AnimTrack)Tag).createANIM(sfd.FileName, Runtime.TargetVBN); } else { ANIM.CreateANIM(sfd.FileName, this, Runtime.TargetVBN); } } if (sfd.FileName.EndsWith(".omo")) { if (Tag is FileData) { FileOutput o = new FileOutput(); o.writeBytes(((FileData)Tag).getSection(0, ((FileData)Tag).size())); o.save(sfd.FileName); } else { OMOOld.CreateOMOFromAnimation(this, Runtime.TargetVBN); } } if (sfd.FileName.EndsWith(".smd")) { SMD.Save(this, Runtime.TargetVBN, sfd.FileName); } } } }
public override void Save() { if (FilePath.Equals("")) { SaveAs(); return; } FileOutput o = new FileOutput(); byte[] n = VBN.Rebuild(); o.writeBytes(n); o.save(FilePath); Edited = false; }
public override void Save() { if (String.IsNullOrEmpty(FilePath)) { SaveAs(); return; } FileOutput o = new FileOutput(); byte[] n = swag.Rebuild(); o.writeBytes(n); o.save(FilePath); Edited = false; }
public override void Save() { if (FilePath.Equals("")) { SaveAs(); return; } FileOutput o = new FileOutput(); mta.Compile(new List <string>(richTextBox1.Text.Split('\n'))); byte[] n = mta.Rebuild(); o.writeBytes(n); o.save(FilePath); Edited = false; }
public override void Save() { if (FilePath.Equals("")) { SaveAs(); return; } FileOutput fileOutput = new FileOutput(); byte[] n = currentNut.Rebuild(); fileOutput.writeBytes(n); fileOutput.save(FilePath); Edited = false; }
public void ExportBNTX(string filename) { FileOutput o = new FileOutput(); o.Endian = Endianness.Little; // pictureBox1.Image.RotateFlip(RotateFlipType.RotateNoneFlipY); // pictureBox1.Image.RotateFlip(RotateFlipType.RotateNoneFlipY); o.save(filename); }
public override void Save() { if (FilePath.Equals("")) { SaveAs(); return; } PromptUserToConfirmMipRegenIfGtx(currentNut); FileOutput fileOutput = new FileOutput(); byte[] n = currentNut.Rebuild(); fileOutput.writeBytes(n); fileOutput.save(FilePath); Edited = false; }
//Saving Mat private void savePresetButton_Click(object sender, EventArgs e) { using (var sfd = new SaveFileDialog()) { sfd.Filter = "Namco Material (NMT)|*.nmt|" + "All files(*.*)|*.*"; sfd.InitialDirectory = Path.Combine(MainForm.executableDir, "materials\\"); Console.WriteLine(sfd.InitialDirectory); if (sfd.ShowDialog() == DialogResult.OK) { sfd.FileName = sfd.FileName; sfd.RestoreDirectory = true; if (sfd.FileName.EndsWith(".nmt")) { FileOutput m = new FileOutput(); FileOutput s = new FileOutput(); int[] c = NUD.WriteMaterial(m, currentMaterialList, s); FileOutput fin = new FileOutput(); fin.writeInt(0); fin.writeInt(20 + c[0]); for (int i = 1; i < 4; i++) { fin.writeInt(c[i] == c[i - 1] ? 0 : 20 + c[i]); } for (int i = 0; i < 4 - c.Length; i++) { fin.writeInt(0); } fin.writeOutput(m); fin.align(32, 0xFF); fin.writeIntAt(fin.size(), 0); fin.writeOutput(s); fin.save(sfd.FileName); } } } }
private void saveNUTZLIBToolStripMenuItem_Click(object sender, EventArgs e) { using (var sfd = new SaveFileDialog()) { sfd.Filter = "Namco Universal Texture (.nut)|*.nut|" + "All Files (*.*)|*.*"; if (sfd.ShowDialog() == DialogResult.OK) { if (sfd.FileName.EndsWith(".nut") && NUT != null) { FileOutput o = new FileOutput(); o.writeBytes(FileData.DeflateZLIB(NUT.Rebuild())); o.save(sfd.FileName); } } } }
// Writing public void Save(string fname) { FileOutput f = new FileOutput(); f.Endian = System.IO.Endianness.Big; // header FileOutput header = new FileOutput(); header.Endian = System.IO.Endianness.Big; FileOutput data = new FileOutput(); data.Endian = System.IO.Endianness.Big; f.save(fname); }
public void Play() { // this cannot be very fast .-. // if anyone know how to pass the file via a byte array then that would be great... File.WriteAllBytes("temp.idsp", idsp); Console.WriteLine("here"); IntPtr vgm = VGMStreamNative.InitVGMStream("temp.idsp"); if (vgm == IntPtr.Zero) { throw new Exception("Error loading idsp"); } Console.WriteLine("here"); int channelCount = VGMStreamNative.GetVGMStreamChannelCount(vgm); int bitsPerFrame = VGMStreamNative.GetVGMStreamFrameSize(vgm); int size = VGMStreamNative.GetVGMStreamTotalSamples(vgm); int samplerate = VGMStreamNative.GetVGMStreamSampleRate(vgm); Console.WriteLine("here"); int total = (int)((samplerate * bitsPerFrame * channelCount * (size / 24576000f)) / 8 * 1024); //Console.WriteLine(channelCount + " " + bitsPerFrame + " " + size + " " + samplerate + " " + total.ToString("x")); short[] buffer = new short[total]; VGMStreamNative.RenderVGMStream(buffer, buffer.Length / 2, vgm); Console.WriteLine("here"); FileOutput o = new FileOutput(); o.Endian = Endianness.Little; for (int i = 0; i < buffer.Length / 2; i++) { o.writeShort(buffer[i]); } o.save("test.wav"); Console.WriteLine("here"); WAVE.Play(o.getBytes(), VGMStreamNative.GetVGMStreamChannelCount(vgm), VGMStreamNative.GetVGMStreamSamplesPerFrame(vgm), VGMStreamNative.GetVGMStreamSampleRate(vgm)); VGMStreamNative.CloseVGMStream(vgm); File.Delete("temp.idsp"); }
public override void Save() { if (FilePath.Equals("")) { SaveAs(); return; } FileOutput fileOutput = new FileOutput(); byte[] n = NUT.Rebuild(); //Temporarily disabling this prompt until zlib works properly /*DialogResult dialogResult = MessageBox.Show("Would you like to compress this NUT file with zlib?\nIf you are unsure, select \"No\".", "zlib Compression", MessageBoxButtons.YesNo); * if (dialogResult == DialogResult.Yes) * n = FileData.DeflateZLIB(n);*/ fileOutput.writeBytes(n); fileOutput.save(FilePath); Edited = false; }
public override void Save() { if (FilePath.Equals("")) { SaveAs(); return; } FileOutput o = new FileOutput(); byte[] n = NUT.Rebuild(); DialogResult dialogResult = MessageBox.Show("Would you like to compress this NUT file with zlib?\nIf you are unsure, select \"No\".", "zlib Compression", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { n = FileData.DeflateZLIB(n); } o.writeBytes(n); o.save(FilePath); Edited = false; }
public void Save(string filename) { FileOutput f = new FileOutput(); f.Endian = System.IO.Endianness.Big; f.writeChars("ATKD".ToCharArray()); f.writeInt(entries.Count); f.writeUInt(commonSubactions); f.writeUInt(uniqueSubactions); foreach (Entry e in entries) { f.writeUShort(e.subaction); f.writeUShort(0); f.writeUShort(e.startFrame); f.writeUShort(e.lastFrame); f.writeFloat(e.xmin); f.writeFloat(e.xmax); f.writeFloat(e.ymin); f.writeFloat(e.ymax); } f.save(filename); }
public void Save(string fname) { FileOutput f = new FileOutput(); f.Endian = System.IO.Endianness.Little; f.writeUInt(magic); f.writeUInt(header.size); f.writeUInt(header.flags); f.writeUInt(header.height); f.writeUInt(header.width); f.writeUInt(header.pitchOrLinearSize); f.writeUInt(header.depth); f.writeUInt(header.mipmapCount); for (int i = 0; i < 11; ++i) { f.writeUInt(header.reserved1[i]); } f.writeUInt(header.ddspf.size); f.writeUInt(header.ddspf.flags); f.writeUInt(header.ddspf.fourCC); f.writeUInt(header.ddspf.RGBBitCount); f.writeUInt(header.ddspf.RBitMask); f.writeUInt(header.ddspf.GBitMask); f.writeUInt(header.ddspf.BBitMask); f.writeUInt(header.ddspf.ABitMask); f.writeUInt(header.caps); f.writeUInt(header.caps2); f.writeUInt(header.caps3); f.writeUInt(header.caps4); f.writeUInt(header.reserved2); f.writeBytes(bdata); f.save(fname); }
public void Save(string fname) { FileOutput f = new FileOutput(); f.Endian = System.IO.Endianness.Little; f.writeString("DDS "); f.writeInt(header.size); f.writeInt(header.flags); f.writeInt(header.height); f.writeInt(header.width); f.writeInt(header.pitchOrLinear); f.writeInt(header.depth); f.writeInt(header.mipmapCount); for (int i = 0; i < 11; i++) { f.writeInt(0); } f.writeInt(header.dwSize); f.writeInt(header.dwFlags); f.writeInt(header.dwFourCC); f.writeInt(header.dwBitmask); f.writeInt((int)header.dwCaps); f.writeInt((int)header.dwCaps2); f.writeInt((int)header.dwCaps3); f.writeInt((int)header.dwCaps4); f.writeInt((int)header.reserve); for (int i = 0; i < 4; i++) { f.writeInt(0); } f.writeBytes(data); f.save(fname); }
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); }
private void extractRom(object sender, EventArgs e) { using (OpenFileDialog ofd = new OpenFileDialog()) { ofd.Title = "Select NES ROM"; if (ofd.ShowDialog() == DialogResult.OK) { using (SaveFileDialog sfd = new SaveFileDialog()) { sfd.Title = "Select Save Location"; if (sfd.ShowDialog() == DialogResult.OK) { byte[] rom = File.ReadAllBytes(ofd.FileName); FileOutput f = new FileOutput(); for (int i = 0x30; i < rom.Length; i++) { f.writeByte(rom[i]); } f.save(sfd.FileName); } } } } }
public void SaveAsMBN(string fname) { int format = 6; FileOutput o = new FileOutput(); o.Endian = Endianness.Little; o.writeShort(format); o.writeShort(0xFFFF); o.writeInt(0); //flags o.writeInt(1); //mode o.writeInt(Nodes.Count); // Write Vertex Attributes { o.writeInt(Attributes.Count); foreach (VertexAttribute va in Attributes) { o.writeInt(va.type); o.writeInt(va.format); o.writeFloat(va.scale); } } //Vertex Buffer FileOutput vertexBuffer = new FileOutput(); vertexBuffer.Endian = Endianness.Little; for (int i = 0; i < Vertices.Length; i++) { foreach (VertexAttribute va in Attributes) { //Write Data va.WriteVertex(vertexBuffer, ref Vertices[i]); } } o.writeInt(vertexBuffer.size()); // Vertex Buffer Size //Mesh Information FileOutput indexBuffer = new FileOutput(); indexBuffer.Endian = Endianness.Little; foreach (BCH_Mesh mesh in Nodes) { o.writeInt(mesh.Nodes.Count); foreach (BCH_PolyGroup pg in mesh.Nodes) { // Node List o.writeInt(pg.BoneList.Length); foreach (int b in pg.BoneList) { o.writeInt(b); } // Triangle Count o.writeInt(pg.Faces.Length); // o.writeInt(0); something if format == 4 // Index Buffer foreach (int i in pg.Faces) { indexBuffer.writeShort(i); } indexBuffer.align(0x20, 0xFF); } } if (format != 4) { o.align(0x20, 0xFF); } o.writeOutput(vertexBuffer); o.align(0x20, 0xFF); o.writeOutput(indexBuffer); o.save(fname); }
private void exportToolStripMenuItem_Click(object sender, EventArgs e) { /*if (Runtime.TargetVBN == null) * { * return; * }*/ using (var sfd = new SaveFileDialog()) { sfd.Filter = "Supported Files (.omo, .anim, .pac, .mta)|*.omo;*.anim;*.pac;*.mta|" + "Object Motion (.omo)|*.omo|" + "Material Animation (.mta)|*.mta|" + "Maya Anim (.anim)|*.anim|" + "OMO Pack (.pac)|*.pac|" + "All Files (*.*)|*.*"; if (sfd.ShowDialog() == DialogResult.OK) { sfd.FileName = sfd.FileName; if (sfd.FileName.EndsWith(".anim")) { if (Runtime.TargetAnim.Tag is AnimTrack) { ((AnimTrack)Runtime.TargetAnim.Tag).createANIM(sfd.FileName, Runtime.TargetVBN); } else { ANIM.createANIM(sfd.FileName, Runtime.TargetAnim, Runtime.TargetVBN); } } if (sfd.FileName.EndsWith(".omo")) { if (Runtime.TargetAnim.Tag is FileData) { FileOutput o = new FileOutput(); o.writeBytes(((FileData)Runtime.TargetAnim.Tag).getSection(0, ((FileData)Runtime.TargetAnim.Tag).size())); o.save(sfd.FileName); } else { OMO.createOMO(Runtime.TargetAnim, Runtime.TargetVBN, sfd.FileName); } } if (sfd.FileName.EndsWith(".pac")) { var pac = new PAC(); foreach (var anim in Runtime.Animations) { var bytes = OMO.createOMO(anim.Value, Runtime.TargetVBN); if (Runtime.TargetAnim.Tag is FileData) { bytes = ((FileData)Runtime.TargetAnim.Tag).getSection(0, ((FileData)Runtime.TargetAnim.Tag).size()); } pac.Files.Add(anim.Key, bytes); } pac.Save(sfd.FileName); } if (sfd.FileName.EndsWith(".mta")) { FileOutput f = new FileOutput(); f.writeBytes(Runtime.TargetMTA.Rebuild()); f.save(sfd.FileName); } } } }
public byte[] Rebuild(bool dump = false) { FileOutput o = new FileOutput(); TextWriter oldOut = Console.Out; MemoryStream ostrm = new MemoryStream(0xA00000); StreamWriter writer = new StreamWriter(ostrm); Console.SetOut(writer); // TODO: write correct filesize in header. // It isn't checked by the game, but what the hell, right? header.Write(o); writeSymbols(o); writeColors(o); writeTransforms(o); writePositions(o); writeBounds(o); Actionscript.Write(o); if (Actionscript2 != null) { Actionscript2.Write(o); } writeAtlases(o); unkF008.Write(o); unkF009.Write(o); unkF00A.Write(o); unk000A.Write(o); unkF00B.Write(o); properties.Write(o); Defines.numShapes = (uint)Shapes.Count; Defines.numSprites = (uint)Sprites.Count; Defines.numTexts = (uint)Texts.Count; Defines.Write(o); writeShapes(o); writeSprites(o); writeTexts(o); o.writeInt((int)TagType.End); o.writeInt(0); int padSize = (4 - (o.size() % 4)) % 4; for (int i = 0; i < padSize; i++) { o.writeByte(0); } if (dump) { writer.Flush(); using (var filestream = new FileStream("dump.txt", FileMode.Create)) ostrm.WriteTo(filestream); } Console.SetOut(oldOut); o.save(Filename); return(o.getBytes()); }
public static void Rebuild(string fname, List <Animation> animations) { // poopity doo da // headery deadery FileOutput o = new FileOutput(); o.writeString("BCH"); o.align(4); o.writeByte(0x21); // version stuffs o.writeByte(0x21); // version stuffs o.Endian = System.IO.Endianness.Little; o.writeShort(0xA755); // version FileOutput d_Main = new FileOutput(); d_Main.Endian = System.IO.Endianness.Little; FileOutput d_Main2 = new FileOutput(); d_Main2.Endian = System.IO.Endianness.Little; FileOutput d_Main3 = new FileOutput(); d_Main3.Endian = System.IO.Endianness.Little; FileOutput d_String = new FileOutput(); d_String.Endian = System.IO.Endianness.Little; FileOutput d_GPU = new FileOutput(); d_GPU.Endian = System.IO.Endianness.Little; FileOutput d_Data = new FileOutput(); d_Data.Endian = System.IO.Endianness.Little; FileOutput Reloc = new FileOutput(); Reloc.Endian = System.IO.Endianness.Little; //Offsets o.writeInt(0); //main o.writeInt(0); //string o.writeInt(0); //gpu o.writeInt(0); //data o.writeInt(0); //dataext o.writeInt(0); //relocationtable //Length o.writeInt(0); //main o.writeInt(0); //string o.writeInt(0); //gpu o.writeInt(0); //data o.writeInt(0); //dataext o.writeInt(0); //relocationtable o.writeInt(0); //datasection o.writeInt(0); // o.writeShort(1); //flag o.writeShort(0); //addcount //Contents in the main header...... d_Main.writeInt(0); // Model d_Main.writeInt(0); // d_Main.WriteOffset(0xB4 + d_Main2.size(), d_Main); // d_Main2.writeInt(0); d_Main2.writeInt(0); d_Main2.writeInt(0); d_Main.writeInt(0); // Material d_Main.writeInt(0); // d_Main.WriteOffset(0xB4 + d_Main2.size(), d_Main); // d_Main2.writeInt(0); d_Main2.writeInt(0); d_Main2.writeInt(0); d_Main.writeInt(0); // Shader d_Main.writeInt(0); // d_Main.WriteOffset(0xB4 + d_Main2.size(), d_Main); // d_Main2.writeInt(0); d_Main2.writeInt(0); d_Main2.writeInt(0); d_Main.writeInt(0); // Texture d_Main.writeInt(0); // d_Main.WriteOffset(0xB4 + d_Main2.size(), d_Main); // d_Main2.writeInt(0); d_Main2.writeInt(0); d_Main2.writeInt(0); d_Main.writeInt(0); // MaterialLUT d_Main.writeInt(0); // d_Main.WriteOffset(0xB4 + d_Main2.size(), d_Main); // d_Main2.writeInt(0); d_Main2.writeInt(0); d_Main2.writeInt(0); d_Main.writeInt(0); // Lights d_Main.writeInt(0); // d_Main.WriteOffset(0xB4 + d_Main2.size(), d_Main); // d_Main2.writeInt(0); d_Main2.writeInt(0); d_Main2.writeInt(0); d_Main.writeInt(0); // Camera d_Main.writeInt(0); // d_Main.WriteOffset(0xB4 + d_Main2.size(), d_Main); // d_Main2.writeInt(0); d_Main2.writeInt(0); d_Main2.writeInt(0); d_Main.writeInt(0); // Fog d_Main.writeInt(0); // d_Main.WriteOffset(0xB4 + d_Main2.size(), d_Main); // d_Main2.writeInt(0); d_Main2.writeInt(0); d_Main2.writeInt(0); // SkeAnim { // Names need to be in patricia tree....... Dictionary <string, int> NameBank = new Dictionary <string, int>(); NameBank.Add("BustN", d_String.size()); d_String.writeString("BustN"); d_String.writeByte(0); List <PatriciaTree.PatriciaTreeNode> Nodes = new List <PatriciaTree.PatriciaTreeNode>(); int maxlength = 0; foreach (Animation a in animations) { maxlength = Math.Max(maxlength, a.Text.Length); } Nodes.Add(new PatriciaTree.PatriciaTreeNode() { ReferenceBit = uint.MaxValue }); foreach (Animation a in animations) { PatriciaTree.Insert(Nodes, new PatriciaTree.PatriciaTreeNode() { Name = a.Text }, maxlength); } int nameOff = 0xb4 + d_Main2.size(); foreach (PatriciaTree.PatriciaTreeNode node in Nodes) { d_Main2.writeInt((int)node.ReferenceBit); d_Main2.writeShort(node.LeftNodeIndex); d_Main2.writeShort(node.RightNodeIndex); if (node.Name.Equals("")) { d_Main2.writeInt(0); } else { NameBank.Add(node.Name, d_String.size()); d_Main2.WriteOffset(d_String.size(), d_String); d_String.writeString(node.Name); d_String.writeByte(0); } } // bones // Okay, first create the animation data then create the table pointng to it side by side int dataOff = 0xb4 + d_Main2.size(); foreach (Animation a in animations) { d_Main2.WriteOffset(d_Main3.size(), d_Main2); // now create the actual animation data I guess d_Main3.WriteOffset(NameBank[a.Text], d_String); // name offset d_Main3.writeInt(0x2); // Flags TODO: What are these d_Main3.writeFloat(a.FrameCount + 1); d_Main3.WriteOffset(d_Main3.size() + 12, d_Main3); // bone offset d_Main3.writeInt(a.Bones.Count); // bonecount d_Main3.writeInt(0); // metadata nonsense FileOutput boneHeader = new FileOutput(); boneHeader.Endian = System.IO.Endianness.Little; FileOutput keyData = new FileOutput(); keyData.Endian = System.IO.Endianness.Little; int start = d_Main3.size() + (a.Bones.Count * 4); int track = 0; foreach (Animation.KeyNode node in a.Bones) { d_Main3.WriteOffset(start + boneHeader.size(), d_Main3); // bone offset // name type and flags if (!NameBank.ContainsKey(node.Text)) { NameBank.Add(node.Text, d_String.size()); d_String.writeString(node.Text); d_String.writeByte(0); } boneHeader.WriteOffset(NameBank[node.Text], d_String); // name offset boneHeader.writeInt(0x040000); // animation type flags, default is just simply transform // Actual Flags int flags = 0; flags |= (((node.XSCA.Keys.Count > 0) ? 0 : 1) << (16 + 0)); flags |= (((node.YSCA.Keys.Count > 0) ? 0 : 1) << (16 + 1)); flags |= (((node.ZSCA.Keys.Count > 0) ? 0 : 1) << (16 + 2)); flags |= (((node.XROT.Keys.Count > 0) ? 0 : 1) << (16 + 3)); flags |= (((node.YROT.Keys.Count > 0) ? 0 : 1) << (16 + 4)); flags |= (((node.ZROT.Keys.Count > 0) ? 0 : 1) << (16 + 5)); flags |= (((node.XPOS.Keys.Count > 0) ? 0 : 1) << (16 + 6)); flags |= (((node.YPOS.Keys.Count > 0) ? 0 : 1) << (16 + 7)); flags |= (((node.ZPOS.Keys.Count > 0) ? 0 : 1) << (16 + 8)); flags |= (((node.XSCA.Keys.Count == 1) ? 1 : 0) << (6 + 0)); flags |= (((node.YSCA.Keys.Count == 1) ? 1 : 0) << (6 + 1)); flags |= (((node.ZSCA.Keys.Count == 1) ? 1 : 0) << (6 + 2)); flags |= (((node.XROT.Keys.Count == 1) ? 1 : 0) << (6 + 3)); flags |= (((node.YROT.Keys.Count == 1) ? 1 : 0) << (6 + 4)); flags |= (((node.ZROT.Keys.Count == 1) ? 1 : 0) << (6 + 5)); flags |= (((node.XPOS.Keys.Count == 1) ? 1 : 0) << (6 + 7)); flags |= (((node.YPOS.Keys.Count == 1) ? 1 : 0) << (6 + 8)); flags |= (((node.ZPOS.Keys.Count == 1) ? 1 : 0) << (6 + 9)); boneHeader.writeInt(flags); // Create KeyFrame Data int sta = start + (a.Bones.Count * 12 * 4); WriteKeyData(node.XSCA, boneHeader, keyData, d_Main3, sta, ref track); WriteKeyData(node.YSCA, boneHeader, keyData, d_Main3, sta, ref track); WriteKeyData(node.ZSCA, boneHeader, keyData, d_Main3, sta, ref track); WriteKeyData(node.XROT, boneHeader, keyData, d_Main3, sta, ref track); WriteKeyData(node.YROT, boneHeader, keyData, d_Main3, sta, ref track); WriteKeyData(node.ZROT, boneHeader, keyData, d_Main3, sta, ref track); WriteKeyData(node.XPOS, boneHeader, keyData, d_Main3, sta, ref track); WriteKeyData(node.YPOS, boneHeader, keyData, d_Main3, sta, ref track); WriteKeyData(node.ZPOS, boneHeader, keyData, d_Main3, sta, ref track); } d_Main3.writeOutput(boneHeader); d_Main3.writeOutput(keyData); } d_Main.WriteOffset(dataOff, d_Main); d_Main.writeInt(animations.Count); // d_Main.WriteOffset(nameOff, d_Main); // } d_Main.writeInt(0); // MaterialAnim d_Main.writeInt(0); // d_Main.WriteOffset(0xB4 + d_Main2.size(), d_Main); // d_Main2.writeInt(0); d_Main2.writeInt(0); d_Main2.writeInt(0); d_Main.writeInt(0); // VisAnim d_Main.writeInt(0); // d_Main.WriteOffset(0xB4 + d_Main2.size(), d_Main); // d_Main2.writeInt(0); d_Main2.writeInt(0); d_Main2.writeInt(0); d_Main.writeInt(0); // LightAnim d_Main.writeInt(0); // d_Main.WriteOffset(0xB4 + d_Main2.size(), d_Main); // d_Main2.writeInt(0); d_Main2.writeInt(0); d_Main2.writeInt(0); d_Main.writeInt(0); // CameraAnim d_Main.writeInt(0); // d_Main.WriteOffset(0xB4 + d_Main2.size(), d_Main); // d_Main2.writeInt(0); d_Main2.writeInt(0); d_Main2.writeInt(0); d_Main.writeInt(0); // FogAnim d_Main.writeInt(0); // d_Main.WriteOffset(0xB4 + d_Main2.size(), d_Main); // d_Main2.writeInt(0); d_Main2.writeInt(0); d_Main2.writeInt(0); d_Main.writeInt(0); // Scene d_Main.writeInt(0); // d_Main.WriteOffset(0xB4 + d_Main2.size(), d_Main); // d_Main2.writeInt(0); d_Main2.writeInt(0); d_Main2.writeInt(0); d_Main.writeOutput(d_Main2); d_Main.writeOutput(d_Main3); int headSize = o.size(); o.writeIntAt(headSize, 0x08); o.writeIntAt(d_Main.size(), 0x20); o.writeOutput(d_Main); o.align(4); int stringSize = o.size(); o.writeIntAt(stringSize, 0x0C); o.writeIntAt(d_String.size(), 0x24); o.writeOutput(d_String); o.align(4); int gpuSize = o.size(); o.writeIntAt(d_GPU.size() > 0 ? gpuSize : 0, 0x10); o.writeIntAt(d_GPU.size(), 0x28); o.writeOutput(d_GPU); o.align(0x100); int dataSize = o.size(); o.writeIntAt(dataSize, 0x14); o.writeIntAt(dataSize, 0x18); o.writeIntAt(d_Data.size(), 0x2C); o.writeIntAt(d_Data.size(), 0x30); o.writeOutput(d_Data); //Create Relocation Table // Flag is 7 bits // 0 - main 1 - string 2 - gpu 3 - data foreach (FileOutput.RelocOffset off in o.Offsets) { int size = 0; int code = 0; int div = 4; if (off.output == d_Main || off.output == d_Main2 || off.output == d_Main3) { size = headSize; code = 0; if (off.output == d_Main3) { off.Value += headSize; } if (off.output == d_Main2) { off.Value += d_Main2.size() + headSize; } } if (off.output == d_String) { size = stringSize; code = 1; div = 1; } if (off.output == d_GPU) { size = gpuSize; code = 2; } if (off.output == d_Data) { size = dataSize; code = 3; } o.writeIntAt(off.Value - size, off.Position); int reloc = (code << 25) | (((off.Position - headSize) / div) & 0x1FFFFFF); Reloc.writeInt(reloc); } int relocSize = o.size(); o.writeIntAt(relocSize, 0x1C); o.writeIntAt(Reloc.size(), 0x34); o.writeOutput(Reloc); o.save(fname); }