Exemplo n.º 1
0
            public void Read(FileData d)
            {
                names.Clear();
                d.skip(8);// magic and section size
                int c1 = d.readInt();

                int start = d.pos();

                for (int i = 0; i < c1; i++)
                {
                    int offset = d.readInt();
                    int size   = d.readInt();

                    int temp = d.pos();
                    d.seek(start + offset);

                    d.readInt();
                    int s = (sbyte)d.readByte();
                    names.Add(d.readString(d.pos(), -1));
                    d.skip(s);
                    d.align(4);


                    d.seek(temp);
                }
            }
Exemplo n.º 2
0
        public void read(FileData f)
        {
            base.read(f);

            f.skip(1);
            type = f.readInt(); //2 = sphere, 3 = capsule
            if ((type != 2) && (type != 3))
            {
                throw new NotImplementedException($"Unknown damage shape type {type} at offset {f.pos()-4}");
            }

            x = f.readFloat();
            y = f.readFloat();
            z = f.readFloat();
            if (type == 2)
            {
                radius = f.readFloat();
                dx     = f.readFloat();
                dy     = f.readFloat();
                dz     = f.readFloat();
            }
            else if (type == 3)
            {
                dx     = f.readFloat();
                dy     = f.readFloat();
                dz     = f.readFloat();
                radius = f.readFloat();
            }
            unk = f.readFloat();
            f.skip(0x1);
        }
Exemplo n.º 3
0
        public void read(FileData f)
        {
            base.read(f);

            f.readByte();
            type = f.readInt(); //3 = rect, 4 = path
            if ((type != 3) && (type != 4))
            {
                throw new NotImplementedException($"Unknown general shape type {type} at offset {f.pos()-4}");
            }

            x1 = f.readFloat();
            y1 = f.readFloat();
            x2 = f.readFloat();
            y2 = f.readFloat();

            f.skip(1);
            f.skip(1);
            int pointCount = f.readInt();

            for (int i = 0; i < pointCount; i++)
            {
                f.skip(1);
                points.Add(new Vector2D()
                {
                    x = f.readFloat(), y = f.readFloat()
                });
            }
        }
Exemplo n.º 4
0
        public void Read(string fname)
        {
            FileData d = new FileData(fname);

            d.Endian = System.IO.Endianness.Little;

            d.skip(4); // RIFF
            int riffsize = d.readInt();

            d.skip(4); //WAVE

            d.skip(4); //fmt
            int formatsize   = d.readInt();
            int audio_format = d.readShort();
            int channelCount = d.readShort();
            int sampleRate   = d.readInt();
            int byte_rate    = d.readInt();
            int blockalign   = d.readShort();
            int bps          = d.readShort();

            d.skip(4); // data
            int datasize = d.readInt();


            byte[] data = d.getSection(d.pos(), datasize);

            Play(data, channelCount, bps, sampleRate);
        }
Exemplo n.º 5
0
                public void Read(FileData d)
                {
                    hash = d.readInt();
                    unk1 = d.readInt();

                    int s = d.readByte();

                    name = d.readString(d.pos(), -1);
                    d.skip(s);
                    d.align(4);

                    d.skip(8);

                    offset = d.readInt();
                    size   = d.readInt();

                    for (int i = 0; i < param.Length; i++)
                    {
                        param[i] = d.readFloat();
                    }

                    offsets = new int[d.readInt()];
                    for (int i = 0; i < offsets.Length; i++)
                    {
                        offsets[i] = d.readInt();
                    }

                    unkvalues = new float[d.readInt()];
                    for (int i = 0; i < unkvalues.Length; i++)
                    {
                        unkvalues[d.readInt()] = d.readFloat();
                    }

                    List <int> une = new List <int>();

                    while (true)
                    {
                        int i = d.readInt();
                        une.Add(i);
                        if (i == -1)
                        {
                            break;
                        }
                    }
                    unkending = une.ToArray();

                    end = new int[3 + (int)Math.Ceiling((double)((unk1 >> 8) & 0xFF) / 4)];

                    for (int i = 0; i < end.Length; i++)
                    {
                        end[i] = d.readInt();
                    }

                    //Console.WriteLine(id + " " + name + " " + offset.ToString("x"));
                }
Exemplo n.º 6
0
        public override void Read(string filename)
        {
            FileData d = new FileData(filename);

            d.Endian = Endianness.Little;

            if (d.Magic().Equals("3SUN"))
            {
                throw new Exception("Not a valid nus3bank");
            }

            d.seek(4);
            int filesize = d.readInt();

            d.skip(8); // BANKTOC
            int headerSize = 0x14 + d.readInt();
            int secCount   = d.readInt();

            for (int i = 0; i < secCount; i++)
            {
                string magic = d.readString(d.pos(), 4);
                d.skip(4);
                int size = d.readInt();

                int temp = d.pos();
                d.seek(headerSize);
                Console.WriteLine(magic + " " + d.pos().ToString("x"));
                if (magic.Equals("PROP"))
                {
                    prop.Read(d);
                }
                if (magic.Equals("BINF"))
                {
                    binf.Read(d);
                }
                if (magic.Equals("GRP "))
                {
                    grp.Read(d);
                }
                if (magic.Equals("DTON"))
                {
                    dton.Read(d);
                }
                if (magic.Equals("TONE"))
                {
                    tone.Read(d);
                }
                if (magic.Equals("PACK"))
                {
                    tone.ReadPACK(d);
                }
                headerSize += size + 8;
                d.seek(temp);
            }
        }
Exemplo n.º 7
0
        public void Read(FileData d)
        {
            d.Endian = Endianness.Big;

            d.seek(0x16);
            int count = d.readShort();

            d.seek(0x60);

            for (int i = 0; i < count; i++)
            {
                string name = d.readString(d.pos(), -1);
                d.skip(0x40);
                int unk      = d.readInt();
                int nextFile = d.readInt();
                int c2       = d.readShort();
                int c1       = d.readShort();
                d.skip(4); // padding?

                int[] partsizes = new int[4];
                for (int j = 0; j < 4; j++)
                {
                    partsizes[j] = d.readInt();
                }

                TreeNode part = new TreeNode();
                part.Text = name;
                Nodes.Add(part);

                int off = 0;
                for (int j = 0; j < c1; j++)
                {
                    TreeNode t = new TreeNode();
                    part.Nodes.Add(t);
                    int    decompressedSize = d.readInt();
                    byte[] dat = FileData.InflateZLIB(d.getSection(d.pos(), partsizes[j] - 4 - off));
                    d.skip(partsizes[j] - 4);
                    off += partsizes[j];
                    string mag = new FileData(dat).Magic();
                    t.Text = name + "." + mag;

                    if (mag.Equals("NTWD"))
                    {
                        Runtime.TextureContainers.Add(new NUT(new FileData(dat)));
                    }

                    if (mag.Equals("OMO "))
                    {
                        Runtime.Animations.Add(t.Text, OMOOld.read(new FileData(dat)));
                        MainForm.Instance.animList.treeView1.Nodes.Add(t.Text);
                    }
                }
            }
        }
Exemplo n.º 8
0
        public void read(FileData f)
        {
            base.read(f);

            f.skip(1);
            type = f.readInt(); //always 4?

            x = f.readFloat();
            y = f.readFloat();
            z = f.readFloat();
            f.skip(0x10);
        }
Exemplo n.º 9
0
            public void Read(FileData d)
            {
                d.skip(12);
                unk1 = d.readInt();

                int s = d.readByte();

                name = d.readString(d.pos(), s - 1);
                d.skip(s);
                d.align(4);
                flag = d.readInt();
            }
Exemplo n.º 10
0
        public void read(FileData f)
        {
            f.skip(0x2);        //x01 03

            type = f.readInt(); //First set of sections = type 1, second set = type 3. No difference in structure but type 3 seems to have non-zero for z and unk
            x    = f.readFloat();
            y    = f.readFloat();
            z    = f.readFloat(); //0 unless type 3
            unk  = f.readFloat(); //0 unless type 3

            f.skip(0x2);          //x01 01
            f.readInt();          //Only seen this as 0, probably a count
        }
Exemplo n.º 11
0
        public override void Read(FileData f)
        {
            f.skip(0x12);
            int pointCount = f.readInt();

            for (int i = 0; i < pointCount; i++)
            {
                f.skip(1);//seperator char
                points.Add(new Vector2D()
                {
                    x = f.readFloat(), y = f.readFloat()
                });
            }
        }
Exemplo n.º 12
0
        public void ReadBNTX(FileData f)
        {
            textures.Clear();

            BFRES b = new BFRES();

            temp = f.pos();

            f.skip(8); //Magic
            int Version        = f.readInt();
            int ByteOrderMark  = f.readShort();
            int FormatRevision = f.readShort();

            Text = f.readString(f.readInt() + temp, -1);
            f.skip(2);
            int strOffset   = f.readShort();
            int relocOffset = f.readInt();
            int FileSize    = f.readInt();

            f.skip(4); //NX Magic
            int TexturesCount   = f.readInt();
            int InfoPtrsOffset  = f.readInt();
            int DataBlockOffset = f.readInt();
            int DictOffset      = f.readInt();
            int strDictSize     = f.readInt();

            Text = Text + ".bntx";

            BNTXFile = f.getSection(temp, FileSize);

            for (int i = 0; i < TexturesCount; i++)
            {
                f.seek(InfoPtrsOffset + temp + i * 8);
                BRTIOffset = f.readInt();


                f.seek(BRTIOffset + temp);

                //  textures.Add(new BRTI(f));
                BRTI texture = new BRTI(f);

                if (!textured.ContainsKey(texture.Text))
                {
                    textured.Add(texture.Text, texture);
                }

                textures.Add(texture);
            }
            Nodes.AddRange(textures.ToArray());
        }
Exemplo n.º 13
0
        public void read(FileData f)
        {
            base.read(f);

            f.skip(0x2); //x01 01
            int sectionCount = f.readInt();

            for (int i = 0; i < sectionCount; i++)
            {
                EnmSection temp = new EnmSection();
                temp.read(f);
                sections.Add(temp);
            }

            f.skip(0x2); //x01 01
            int sectionCount2 = f.readInt();

            for (int i = 0; i < sectionCount2; i++)
            {
                EnmSection temp = new EnmSection();
                temp.read(f);
                sections2.Add(temp);
            }

            f.skip(0x2); //x01 01
            int unkCount = f.readInt();

            for (int i = 0; i < unkCount; i++)
            {
                //Only seen this count as 0
            }

            f.skip(1); //x01
            id = f.readInt();

            f.skip(1); //x01
            int idCount = f.readInt();

            for (int i = 0; i < idCount; i++)
            {
                f.skip(1);
                ids.Add(f.readInt());
            }

            f.skip(1);              //x01
            f.readInt();            //Only seen as 0
            f.skip(1);              //x01
            padCount = f.readInt(); //Don't know the purpose of this, it just seems to be 1 if there's the extra 5 bytes thrown on the end
            for (int i = 0; i < padCount; i++)
            {
                f.skip(0x5); //x01 00 00 00 00
            }
        }
Exemplo n.º 14
0
        public void read(FileData f)
        {
            base.read(f);

            f.skip(1);
            f.readInt(); //unknown
        }
Exemplo n.º 15
0
            public void Read(FileData f)
            {
                AtlasId  = f.readInt();
                FillType = (FillType)f.readShort();

                int numVerts   = f.readShort();
                int numIndices = f.readInt();

                Verts   = new Vertex[numVerts];
                Indices = new ushort[numIndices];

                for (int i = 0; i < numVerts; i++)
                {
                    Verts[i]   = new Vertex();
                    Verts[i].X = f.readFloat();
                    Verts[i].Y = f.readFloat();
                    Verts[i].U = f.readFloat();
                    Verts[i].V = f.readFloat();
                }

                for (int i = 0; i < numIndices; i++)
                {
                    Indices[i] = (ushort)f.readShort();
                }

                // indices are padded to word boundaries
                if ((numIndices % 2) != 0)
                {
                    f.skip(0x02);
                }
            }
Exemplo n.º 16
0
        public void Read(FileData file)
        {
            file.Endian = Endianness.Little;

            file.skip(0x4);

            unk1 = file.readShort();
            unk2 = file.readShort();

            int sequenceCount      = file.readInt();
            int sequenceDataOffset = file.readInt();

            List <int> sequenceOffsets = new List <int>();

            for (int i = 0; i < sequenceCount; ++i)
            {
                sequenceOffsets.Add(file.readInt());
            }

            sequences = new List <SoundSequence>();
            for (int i = 0; i < sequenceCount; ++i)
            {
                if (sequenceOffsets[i] == -1)
                {
                    sequences.Add(new SoundSequence()
                    {
                        empty = true
                    });
                    continue;
                }
                file.seek(0x10 + sequenceDataOffset + sequenceOffsets[i]);
                sequences.Add(new SoundSequence(file));
            }
        }
Exemplo n.º 17
0
        public void read(FileData f)
        {
            base.read(f);

            f.skip(1);
            f.skip(0x5);// unknown

            f.skip(1);
            int sectionCount = f.readInt();

            for (int i = 0; i < sectionCount; i++)
            {
                Section temp = new Section();
                temp.read(f);
                sections.Add(temp);
            }
        }
Exemplo n.º 18
0
 public override void Read(FileData f)
 {
     x1 = f.readFloat();
     y1 = f.readFloat();
     x2 = f.readFloat();
     y2 = f.readFloat();
     f.skip(0x6);
 }
Exemplo n.º 19
0
        public void read(FileData f)
        {
            base.read(f);

            f.skip(1);
            x = f.readFloat();
            y = f.readFloat();
        }
Exemplo n.º 20
0
        public override void Read(string filename)
        {
            FileData file = new FileData(filename);
            if (file != null)
            {
                file.Endian = Endianness.Little;
                Endian = Endianness.Little;
                string magic = file.readString(0, 4);
                if (magic == "VBN ")
                {
                    file.Endian = Endianness.Big;
                    Endian = Endianness.Big;
                }

                file.seek(4);

                unk_1 = (short)file.readShort();
                unk_2 = (short)file.readShort();
                totalBoneCount = (UInt32)file.readInt();
                boneCountPerType[0] = (UInt32)file.readInt();
                boneCountPerType[1] = (UInt32)file.readInt();
                boneCountPerType[2] = (UInt32)file.readInt();
                boneCountPerType[3] = (UInt32)file.readInt();

                for (int i = 0; i < totalBoneCount; i++)
                {
                    Bone temp = new Bone(this);
                    temp.boneName = file.readString(file.pos(), -1).ToCharArray();
                    file.skip(64);
                    temp.boneType = (UInt32)file.readInt();
                    temp.parentIndex = file.readInt();
                    temp.boneId = (UInt32)file.readInt();
                    temp.position = new float[3];
                    temp.rotation = new float[3];
                    temp.scale = new float[3];
                    bones.Add(temp);
                }

                for (int i = 0; i < bones.Count; i++)
                {
                    bones[i].position[0] = file.readFloat();
                    bones[i].position[1] = file.readFloat();
                    bones[i].position[2] = file.readFloat();
                    bones[i].rotation[0] = file.readFloat();
                    bones[i].rotation[1] = file.readFloat();
                    bones[i].rotation[2] = file.readFloat();
                    bones[i].scale[0] = file.readFloat();
                    bones[i].scale[1] = file.readFloat();
                    bones[i].scale[2] = file.readFloat();
                    Bone temp = bones[i];
                    //Debug.Write(temp.parentIndex);
                    //if (temp.parentIndex != 0x0FFFFFFF && temp.parentIndex > -1)
                    //    bones[temp.parentIndex].children.Add(i);
                    bones[i] = temp;
                }
                reset();
            }
        }
Exemplo n.º 21
0
        public void read(FileData f)
        {
            f.skip(1);
            f.skip(0x16);// unknown data

            f.skip(1);
            points = new List <Vector2D>();
            int vertCount = f.readInt();

            for (int j = 0; j < vertCount; j++)
            {
                f.skip(1);
                Vector2D point = new Vector2D();
                point.x = f.readFloat();
                point.y = f.readFloat();
                points.Add(point);
            }
        }
Exemplo n.º 22
0
        public void ReadBNTX(FileData f)
        {
            ImageKey         = "UVPattern";
            SelectedImageKey = "UVPattern";

            textures.Clear();
            textured.Clear();

            temp = f.pos();

            f.skip(8); //Magic
            int Version        = f.readInt();
            int ByteOrderMark  = f.readShort();
            int FormatRevision = f.readShort();

            Text = f.readString(f.readInt() + temp, -1);
            f.skip(2);
            int strOffset   = f.readShort();
            int relocOffset = f.readInt();
            int FileSize    = f.readInt();

            f.skip(4); //NX Magic
            int TexturesCount   = f.readInt();
            int InfoPtrsOffset  = f.readInt();
            int DataBlockOffset = f.readInt();
            int DictOffset      = f.readInt();
            int strDictSize     = f.readInt();

            for (int i = 0; i < TexturesCount; i++)
            {
                f.seek(InfoPtrsOffset + temp + i * 8);
                BRTIOffset = f.readInt();


                f.seek(BRTIOffset + temp);

                //  textures.Add(new BRTI(f));
                BRTI texture = new BRTI(f);

                textured.Add(texture.Text, texture);
                textures.Add(texture);
            }
            Nodes.AddRange(textures.ToArray());
        }
Exemplo n.º 23
0
        public void read(FileData f)
        {
            base.read(f);

            f.skip(1);
            left   = f.readFloat();
            right  = f.readFloat();
            top    = f.readFloat();
            bottom = f.readFloat();
        }
Exemplo n.º 24
0
        public Vector2D angle; //Someone figure out what these angles do

        public void read(FileData f)
        {
            base.read(f);

            f.skip(1);
            pos     = new Vector2D();
            pos.x   = f.readFloat();
            pos.y   = f.readFloat();
            angle   = new Vector2D();
            angle.x = f.readFloat();
            angle.y = f.readFloat();
        }
Exemplo n.º 25
0
        public void read(FileData f)
        {
            f.skip(0xD);
            name = f.readString(f.pos(), 0x38);
            f.skip(0x38);
            f.skip(1);//Seperation char
            subname = f.readString(f.pos(), 0x40);
            f.skip(0xAC);
            int sectionCount = f.readInt();

            for (int i = 0; i < sectionCount; i++)
            {
                f.skip(0x18);// unknown data
                Section temp = new Section();
                temp.points = new List <Vector2D>();
                int vertCount = f.readInt();
                for (int j = 0; j < vertCount; j++)
                {
                    f.skip(1);//Seperation char
                    Vector2D point = new Vector2D();
                    point.x = f.readFloat();
                    point.y = f.readFloat();
                    temp.points.Add(point);
                }
                sections.Add(temp);
            }
        }
Exemplo n.º 26
0
            public void Read(FileData f)
            {
                CharacterId = f.readInt();
                unk1        = f.readInt();
                unk2        = f.readInt();

                int numLabels    = f.readInt();
                int numFrames    = f.readInt();
                int numKeyframes = f.readInt();

                unk3 = f.readInt();

                for (int i = 0; i < numLabels; i++)
                {
                    f.skip(0x08);

                    var label = new Label(f);
                    label.KeyframeId = i;
                    labels.Add(label);
                }

                int totalFrames = numFrames + numKeyframes;

                for (int frameId = 0; frameId < totalFrames; frameId++)
                {
                    TagType frameType = (TagType)f.readInt();
                    f.skip(0x04); // size

                    Frame frame = new Frame(f);

                    if (frameType == TagType.Keyframe)
                    {
                        Keyframes.Add(frame);
                    }
                    else
                    {
                        Frames.Add(frame);
                    }
                }
            }
Exemplo n.º 27
0
        public void read(FileData f)
        {
            base.read(f);

            flag1 = Convert.ToBoolean(f.readByte());
            flag2 = Convert.ToBoolean(f.readByte());
            flag3 = Convert.ToBoolean(f.readByte());
            flag4 = Convert.ToBoolean(f.readByte());

            f.skip(1);
            int vertCount = f.readInt();

            for (int i = 0; i < vertCount; i++)
            {
                f.skip(1);
                Vector2D temp = new Vector2D();
                temp.x = f.readFloat();
                temp.y = f.readFloat();
                verts.Add(temp);
            }

            f.skip(1);
            int normalCount = f.readInt();

            for (int i = 0; i < normalCount; i++)
            {
                f.skip(1);
                Vector2D temp = new Vector2D();
                temp.x = f.readFloat();
                temp.y = f.readFloat();
                normals.Add(temp);
            }

            f.skip(1);
            int cliffCount = f.readInt();

            for (int i = 0; i < cliffCount; i++)
            {
                CollisionCliff temp = new CollisionCliff();
                temp.read(f);
                cliffs.Add(temp);
            }

            f.skip(1);
            int materialCount = f.readInt();

            for (int i = 0; i < materialCount; i++)
            {
                f.skip(1);
                CollisionMat temp = new CollisionMat();
                temp.material = f.read(0xC);//Temporary, will work on fleshing out material more later

                materials.Add(temp);
            }
        }
Exemplo n.º 28
0
        public ATKD Read(FileData f)
        {
            f.skip(4);
            int entryCount = f.readInt();

            commonSubactions = (uint)f.readInt();
            uniqueSubactions = (uint)f.readInt();
            for (int i = 0; i < entryCount; i++)
            {
                entries.Add(new Entry().Read(f));
            }
            return(this);
        }
Exemplo n.º 29
0
        public ATKD Read(FileData f)
        {
            f.skip(4);
            int entryCount = f.readInt();

            unknown1 = (uint)f.readInt();
            unknown2 = (uint)f.readInt();
            for (int i = 0; i < entryCount; i++)
            {
                entries.Add((new Entry()).Read(f));
            }
            return(this);
        }
Exemplo n.º 30
0
        public void Read(FileData d)
        {
            d.Endian = Endianness.Big;

            d.skip(4);

            header = new OMOHeader()
            {
                verHi       = d.readUShort(),
                verLow      = d.readUShort(),
                flags       = d.readInt(),
                unk1        = d.readUShort(),
                boneCount   = d.readUShort(),
                frameCount  = d.readUShort(),
                frameSize   = d.readUShort(),
                nodeOffset  = d.readInt(),
                interOffset = d.readInt(),
                keyOffset   = d.readInt()
            };

            d.seek(header.nodeOffset);
            for (int i = 0; i < header.boneCount; i++)
            {
                OMONode node = new OMONode()
                {
                    flags       = d.readInt(),
                    hash        = (uint)d.readInt(),
                    interOffset = d.readInt(),
                    keyOffset   = d.readInt()
                };
                int temp = d.pos();
                d.seek(header.interOffset + node.interOffset);
                Console.WriteLine(node.hash.ToString("x") + " " + (header.interOffset + node.interOffset).ToString("x"));
                node.Read(d);
                d.seek(temp);
                Nodes.Add(node);
            }

            d.seek(header.keyOffset);
            for (int i = 0; i < header.frameCount; i++)
            {
                OMOFrame frame = new OMOFrame();
                // /2 because size of short
                for (int j = 0; j < header.frameSize / 2; j++)
                {
                    frame.keys.Add(d.readUShort());
                }
                Frames.Add(frame);
            }
        }