예제 #1
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);
            }
        }
예제 #2
0
        public DDS(FileData d)
        {
            d.Endian = System.IO.Endianness.Little;

            d.seek(0);
            if (d.readUInt() != magic)
            {
                MessageBox.Show("The file does not appear to be a valid DDS file.");
            }

            header                   = new Header();
            header.size              = d.readUInt();
            header.flags             = d.readUInt();
            header.height            = d.readUInt();
            header.width             = d.readUInt();
            header.pitchOrLinearSize = d.readUInt();
            header.depth             = d.readUInt();
            header.mipmapCount       = d.readUInt();
            header.reserved1         = new uint[11];
            for (int i = 0; i < 11; ++i)
            {
                header.reserved1[i] = d.readUInt();
            }

            header.ddspf.size        = d.readUInt();
            header.ddspf.flags       = d.readUInt();
            header.ddspf.fourCC      = d.readUInt();
            header.ddspf.RGBBitCount = d.readUInt();
            header.ddspf.RBitMask    = d.readUInt();
            header.ddspf.GBitMask    = d.readUInt();
            header.ddspf.BBitMask    = d.readUInt();
            header.ddspf.ABitMask    = d.readUInt();

            header.caps      = d.readUInt();
            header.caps2     = d.readUInt();
            header.caps3     = d.readUInt();
            header.caps4     = d.readUInt();
            header.reserved2 = d.readUInt();

            d.seek((int)(4 + header.size));
            bdata = d.read(d.size() - d.pos());
        }
예제 #3
0
        public override void Read(string filename)
        {
            FileData f = new FileData(filename);

            byte[] magic      = f.read(0xC);;
            int    frameCount = f.readInt();

            for (int i = 0; i < frameCount; i++)
            {
                pathFrame temp;
                temp.qx = f.readFloat();
                temp.qy = f.readFloat();
                temp.qz = f.readFloat();
                temp.qw = f.readFloat();
                temp.x  = f.readFloat();
                temp.y  = f.readFloat();
                temp.z  = f.readFloat();
                Frames.Add(temp);
            }
        }
예제 #4
0
        public override void Read(string filename)
        {
            var offsets = new List <int>();
            var strings = new List <string>();
            var sizes   = new List <int>();

            Files = new Dictionary <string, byte[]>();
            FileData data = new FileData(filename);

            data.Endian = Endianness.Big;

            if (data != null)
            {
                var magic = data.readString();
                if (magic == "PACK")
                {
                    data.Endian = Endianness.Little;
                }
                data.seek(0x08);
                var count = data.readInt();

                for (int i = 0; i < count; i++)
                {
                    data.seek(0x10 + (i * 4));
                    var strOffset = data.readInt();
                    data.seek(strOffset);
                    strings.Add(data.readString());

                    data.seek(0x10 + (count * 4) + (i * 4));
                    offsets.Add(data.readInt());

                    data.seek((count * 4) + (count * 4) + (i * 4) + 0x10);
                    sizes.Add(data.readInt());

                    data.seek(offsets[i]);
                    var b = data.read(sizes[i]);
                    Files.Add(strings[i], b);
                }
            }
        }
예제 #5
0
            private static byte[] YAZ0(byte[] data)
            {
                FileData f = new FileData(data);

                f.Endian = Endianness.Big;
                f.seek(4);
                int uncompressedSize = f.readInt();

                f.seek(0x10);

                byte[] src = f.read(data.Length - 0x10);
                byte[] dst = new byte[uncompressedSize];

                int srcPlace = 0, dstPlace = 0; //current read/write positions

                uint validBitCount = 0;         //number of valid bits left in "code" byte
                byte currCodeByte  = 0;

                while (dstPlace < uncompressedSize)
                {
                    //read new "code" byte if the current one is used up
                    if (validBitCount == 0)
                    {
                        currCodeByte = src[srcPlace];
                        ++srcPlace;
                        validBitCount = 8;
                    }

                    if ((currCodeByte & 0x80) != 0)
                    {
                        //straight copy
                        dst[dstPlace] = src[srcPlace];
                        dstPlace++;
                        srcPlace++;
                    }
                    else
                    {
                        //RLE part
                        byte byte1 = src[srcPlace];
                        byte byte2 = src[srcPlace + 1];
                        srcPlace += 2;

                        uint dist       = (uint)(((byte1 & 0xF) << 8) | byte2);
                        uint copySource = (uint)(dstPlace - (dist + 1));

                        uint numBytes = (uint)(byte1 >> 4);
                        if (numBytes == 0)
                        {
                            numBytes = (uint)(src[srcPlace] + 0x12);
                            srcPlace++;
                        }
                        else
                        {
                            numBytes += 2;
                        }

                        //copy run
                        for (int i = 0; i < numBytes; ++i)
                        {
                            dst[dstPlace] = dst[copySource];
                            copySource++;
                            dstPlace++;
                        }
                    }

                    //use next bit from "code" byte
                    currCodeByte <<= 1;
                    validBitCount -= 1;
                }

                return(dst);
            }
예제 #6
0
파일: LM.cs 프로젝트: nnn1590/Smash-Forge
 public UnhandledTag(FileData f)
 {
     Type = (TagType)f.readInt();
     Size = f.readInt();
     Data = f.read(Size * 4);
 }
예제 #7
0
파일: LM.cs 프로젝트: nnn1590/Smash-Forge
 public UnhandledTag(TagType type, int size, FileData f)
 {
     Type = type;
     Size = size;
     Data = f.read(size * 4);
 }
예제 #8
0
파일: LVD.cs 프로젝트: struz/Smash-Forge
        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(0x40);
            f.skip(1);//Seperation char
            startPos[0] = f.readFloat();
            startPos[1] = f.readFloat();
            startPos[2] = f.readFloat();
            useStartPos = (f.readByte() != 0);
            f.skip(1);//Seperation char
            unk2 = f.readInt();
            f.skip(1);
            unk3 = f.read(0xC);
            f.skip(4); //FF FF FF FF
            f.skip(1); //Seperation char
            unk4 = new char[0x40];
            for (int i = 0; i < 0x40; i++)
            {
                unk4[i] = (char)f.readByte();
            }

            flag1 = Convert.ToBoolean(f.readByte());
            flag2 = Convert.ToBoolean(f.readByte());
            flag3 = Convert.ToBoolean(f.readByte());
            flag4 = Convert.ToBoolean(f.readByte());
            f.skip(1);//Seperation char
            //f.skip(0xAA);
            //Console.WriteLine(f.pos());
            int vertCount = f.readInt();

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

            int normalCount = f.readInt();

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

            int cliffCount = f.readInt(); //CLIFFS tend to be useless

            f.skip(0xFC * cliffCount);    //Standard CLIFFS are 0xFC in length, just skip em all
            f.skip(1);                    //Seperation char

            int materialCount = f.readInt();

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

                materials.Add(temp);
            }
        }