示例#1
0
        public void ExportBntx(string filename)
        {
            FileOutput o = new FileOutput();

            o.endian = Endianness.Little;

            o.Save(filename);
        }
示例#2
0
        public override void Save()
        {
            FileOutput o = new FileOutput();

            byte[] n = lumen.Rebuild();
            o.WriteBytes(n);
            o.Save(lumen.Filename);
            Edited = false;
        }
示例#3
0
        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))));
        }
示例#4
0
        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());
        }
示例#5
0
        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);
                    }
                }
            }
        }
示例#6
0
            public void WriteDescription(FileOutput f)
            {
                // TODO: Calculate Length
                f.WriteInt(type.Length);

                for (int i = 0; i < type.Length; i++)
                {
                    f.WriteInt(type[i]);
                    f.WriteInt(format[i]);
                    f.WriteFloat(scale[i]);
                }
            }
示例#7
0
        public override byte[] Rebuild()
        {
            FileOutput o = new FileOutput();

            o.endian = Endianness.Little;

            o.WriteString(" BWS");
            o.WriteShort(0x05);
            o.WriteShort(0x01);
            o.WriteInt(bones.Count);

            foreach (SBEntry s in bones)
            {
                o.WriteInt((int)s.hash);
                o.WriteFloat(s.param1_1);
                o.WriteInt(s.param1_2);
                o.WriteInt(s.param1_3);
                o.WriteFloat(s.param2_1);
                o.WriteFloat(s.param2_2);
                o.WriteInt(s.param2_3);
                o.WriteFloat(s.rx1);
                o.WriteFloat(s.rx2);
                o.WriteFloat(s.ry1);
                o.WriteFloat(s.ry2);
                o.WriteFloat(s.rz1);
                o.WriteFloat(s.rz2);

                for (int j = 0; j < 8; j++)
                {
                    o.WriteInt((int)s.boneHashes[j]);
                }

                for (int j = 0; j < 4; j++)
                {
                    o.WriteFloat(s.unks1[j]);
                }

                for (int j = 0; j < 6; j++)
                {
                    o.WriteFloat(s.unks2[j]);
                }

                o.WriteFloat(s.factor);

                for (int j = 0; j < 3; j++)
                {
                    o.WriteInt(s.ints[j]);
                }
            }

            return(o.GetBytes());
        }
示例#8
0
                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);
                }
示例#9
0
        public override void Save()
        {
            if (FilePath.Equals(""))
            {
                SaveAs();
                return;
            }
            FileOutput o = new FileOutput();

            byte[] n = mta.Rebuild();
            o.WriteBytes(n);
            o.Save(FilePath);
            Edited = false;
        }
示例#10
0
        public override byte[] Rebuild()
        {
            FileOutput o = new FileOutput();

            o.endian = Endianness.Little;

            FileOutput d = new FileOutput();

            d.endian = Endianness.Little;

            o.WriteString("NUS3");
            o.WriteInt(0);

            o.WriteString("BANKTOC ");
            o.WriteInt(0x3C);
            o.WriteInt(0x07);

            // write each section
            o.WriteString("PROP");
            o.WriteInt(prop.Rebuild(d));

            o.WriteString("BINF");
            o.WriteInt(binf.Rebuild(d));

            o.WriteString("GRP ");
            o.WriteInt(grp.Rebuild(d));

            o.WriteString("DTON");
            o.WriteInt(dton.Rebuild(d));

            o.WriteString("TONE");
            o.WriteInt(tone.Rebuild(d));

            o.WriteString("JUNK");
            o.WriteInt(4);
            //d.writeString("JUNK");
            d.WriteInt(4);
            d.WriteInt(0);

            o.WriteString("PACK");
            o.WriteInt(0);

            o.WriteOutput(d);

            o.WriteIntAt(o.Size(), 4);

            // something extra with bgm??

            return(o.GetBytes());
        }
示例#11
0
        public static byte[] FromIDSP(byte[] idsp)
        {
            File.WriteAllBytes("temp.idsp", idsp);
            IntPtr vgm = VGMStreamNative.InitVGMStream("temp.idsp");

            if (vgm == IntPtr.Zero)
            {
                throw new Exception("Error loading idsp");
            }

            int channelCount = VGMStreamNative.GetVGMStreamChannelCount(vgm);
            int bitsPerFrame = VGMStreamNative.GetVGMStreamFrameSize(vgm);
            int size         = VGMStreamNative.GetVGMStreamTotalSamples(vgm);
            int samplerate   = VGMStreamNative.GetVGMStreamSampleRate(vgm);

            int total = (int)((samplerate * bitsPerFrame * channelCount * (size / 24576000f)) / 8 * 1024);

            short[] buffer = new short[total];
            VGMStreamNative.RenderVGMStream(buffer, buffer.Length / 2, vgm);

            FileOutput o = new FileOutput();

            o.endian = Endianness.Little;

            o.WriteString("RIFF");
            o.WriteInt(0);
            o.WriteString("WAVEfmt ");

            o.WriteInt(0x10);
            o.WriteShort(1);
            o.WriteShort(channelCount);
            o.WriteInt(samplerate);
            o.WriteInt(size);
            o.WriteShort(2);
            o.WriteShort(0x10);

            o.WriteString("data");
            o.WriteInt(buffer.Length);

            for (int i = 0; i < buffer.Length / 2; i++)
            {
                o.WriteShort(buffer[i]);
            }

            o.WriteIntAt(o.Size() - 8, 4);

            VGMStreamNative.CloseVGMStream(vgm);
            File.Delete("temp.idsp");
            return(o.GetBytes());
        }
示例#12
0
        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;
        }
示例#13
0
        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;
        }
示例#14
0
        void writePositions(FileOutput o)
        {
            Console.WriteLine($"Positions = [ // offset=0x{o.Size():X2}");

            o.WriteInt((int)TagType.Positions);
            o.WriteInt(Positions.Count * 2 + 1);
            o.WriteInt(Positions.Count);

            for (int i = 0; i < Positions.Count; i++)
            {
                var position = Positions[i];
                Console.WriteLine($"\t0x{i:X4}: [{position.X}, {position.Y}] // offset=0x{o.Size():X2}");
                o.WriteFloat(position.X);
                o.WriteFloat(position.Y);
            }
            Console.WriteLine("]\n");
        }
示例#15
0
            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);
            }
示例#16
0
        public static void WriteKeyData(Animation.KeyGroup group, FileOutput boneHeader, FileOutput keyData, FileOutput d_Main3, int start, ref int track)
        {
            if (group.keys.Count == 1)
            {
                boneHeader.WriteFloat(group.keys[0].Value);
            }
            else
            if (group.keys.Count == 0)
            {
                boneHeader.WriteInt(0);
            }
            else
            {
                int off = (group.keys.Count * 4);
                boneHeader.WriteOffset(start + keyData.Size(), d_Main3); // bone offset

                keyData.WriteFloat(0);
                keyData.WriteFloat(group.FrameCount);
                keyData.WriteInt(track++ << 16);                     // track
                keyData.WriteInt((group.keys.Count << 16) | 0x0701); // 7 is quantinization and 1 is linear interpolation

                float minv = 999, maxv = -999;
                float minf = 999, maxf = -999;
                foreach (Animation.KeyFrame key in group.keys)
                {
                    minv = Math.Min(key.Value, minv);
                    maxv = Math.Max(key.Value, maxv);
                    minf = Math.Min(key.Frame, minf);
                    maxf = Math.Max(key.Frame, maxf);
                }
                maxv -= minv;
                keyData.WriteFloat(maxv / 0xFFFFF);                       // value scale
                keyData.WriteFloat(minv);                                 // value offset
                keyData.WriteFloat(1f);                                   // frame scale
                keyData.WriteFloat(minf);                                 // frame offset

                keyData.WriteOffset(start + keyData.Size() + 4, d_Main3); // useless flags

                foreach (Animation.KeyFrame key in group.keys)
                {
                    keyData.WriteInt((((int)(((key.Value - minv) / (maxv)) * 0xFFFFF)) << 12) | (((int)(key.Frame - minf)) & 0xFFF));
                }
            }
            //------
        }
示例#17
0
        // 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);
        }
示例#18
0
        public override void Save()
        {
            ShowGtxMipmapWarning(currentNut);

            if (FilePath.Equals(""))
            {
                SaveAs();
                return;
            }

            FileOutput fileOutput = new FileOutput();

            byte[] n = currentNut.Rebuild();

            fileOutput.WriteBytes(n);
            fileOutput.Save(FilePath);
            Edited = false;
        }
示例#19
0
        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") && currentNut != null)
                    {
                        FileOutput o = new FileOutput();
                        o.WriteBytes(FileData.DeflateZlib(currentNut.Rebuild()));
                        o.Save(sfd.FileName);
                    }
                }
            }
        }
示例#20
0
            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;
                }
            }
示例#21
0
                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");
                }
示例#22
0
 public void Write(FileOutput o)
 {
     o.WriteInt(magic);
     o.WriteInt(unk0);
     o.WriteInt(unk1);
     o.WriteInt(unk2);
     o.WriteInt(unk3);
     o.WriteInt(unk4);
     o.WriteInt(unk5);
     o.WriteInt(filesize);
     o.WriteInt(unk6);
     o.WriteInt(unk7);
     o.WriteInt(unk8);
     o.WriteInt(unk9);
     o.WriteInt(unk10);
     o.WriteInt(unk11);
     o.WriteInt(unk12);
     o.WriteInt(unk13);
 }
示例#23
0
 public void WriteOutput(FileOutput d)
 {
     foreach (RelocOffset o in d.offsets)
     {
         o.position += data.Count;
         offsets.Add(o);
     }
     foreach (RelocOffset o in offsets)
     {
         if (o.output == d || o.output == null)
         {
             o.value += data.Count;
         }
     }
     foreach (byte b in d.data)
     {
         data.Add(b);
     }
 }
示例#24
0
        void writeColors(FileOutput o)
        {
            Console.WriteLine($"Colors = [ // offset=0x{o.Size():X2}");

            o.WriteInt((int)TagType.Colors);
            o.WriteInt(Colors.Count * 2 + 1);
            o.WriteInt(Colors.Count);

            for (int i = 0; i < Colors.Count; i++)
            {
                var color = Colors[i];
                Console.WriteLine($"\t0x{i:X3}: #{(byte)(color.X * 255):X2}{(byte)(color.Z * 255):X2}{(byte)(color.Y * 255):X2}, {(byte)(color.W * 255):X2} // offset=0x{o.Size():X2}");
                o.WriteShort((short)(color.X * 256));
                o.WriteShort((short)(color.Y * 256));
                o.WriteShort((short)(color.Z * 256));
                o.WriteShort((short)(color.W * 256));
            }
            Console.WriteLine("]\n");
        }
示例#25
0
                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);
                }
示例#26
0
        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());
        }
示例#27
0
                // NOTE: unlike other tag write functions, this does not include the header
                // so it can be used for both frames and keyframes.
                public void Write(FileOutput o)
                {
                    o.WriteInt(Id);
                    o.WriteInt(Removals.Count + Actions.Count + Placements.Count);

                    foreach (var deletion in Removals)
                    {
                        deletion.Write(o);
                    }

                    foreach (var action in Actions)
                    {
                        action.Write(o);
                    }

                    foreach (var placement in Placements)
                    {
                        placement.Write(o);
                    }
                }
示例#28
0
        void writeBounds(FileOutput o)
        {
            Console.WriteLine($"Bounds = [ // offset=0x{o.Size():X2}");

            o.WriteInt((int)TagType.Bounds);
            o.WriteInt(Bounds.Count * 4 + 1);
            o.WriteInt(Bounds.Count);

            for (int i = 0; i < Bounds.Count; i++)
            {
                var bb = Bounds[i];
                Console.WriteLine($"\t0x{i:X2}: {bb} // offset=0x{o.Size():X2}");

                o.WriteFloat(bb.TopLeft.X);
                o.WriteFloat(bb.TopLeft.Y);
                o.WriteFloat(bb.BottomRight.X);
                o.WriteFloat(bb.BottomRight.Y);
            }

            Console.WriteLine("]\n");
        }
示例#29
0
            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);
            }
示例#30
0
            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((byte)(data / scale));
                    break;

                case 3:
                    d.WriteShort((short)(data / scale));
                    break;
                }
            }