public override void FromFragment(ErpFragment fragment)
        {
            using (var memData = fragment.GetDataStream(true))
                using (ErpBinaryReader reader = new ErpBinaryReader(memData))
                {
                    MipMapFileName = reader.ReadString(reader.ReadByte());
                    UInt32 mipMapCount = reader.ReadUInt32();

                    Mips = new List <ErpGfxSurfaceRes2Mips>((int)mipMapCount);
                    for (int i = 0; i < mipMapCount; ++i)
                    {
                        ErpGfxSurfaceRes2Mips mip = new ErpGfxSurfaceRes2Mips();
                        mip.Compression = (ErpCompressionAlgorithm)reader.ReadByte();
                        mip.Offset      = reader.ReadUInt64();
                        mip.PackedSize  = reader.ReadUInt64();
                        mip.Size        = reader.ReadUInt64();
                        Mips.Add(mip);
                    }

                    long leftoverBytes = reader.BaseStream.Length - reader.BaseStream.Position;
                    if (leftoverBytes == 8)
                    {
                        // This part was introduced in F1 2017
                        hasTwoUnknowns = true;
                        Unknown        = reader.ReadSingle();
                        Unknown2       = reader.ReadSingle();
                    }
                    else if (leftoverBytes > 0)
                    {
                        throw new NotSupportedException("The GfxSurfaceRes2 data is not supported.");
                    }
                }
        }
Esempio n. 2
0
        public override void FromFragment(ErpFragment fragment)
        {
            using (var memData = fragment.GetDataStream(true))
                using (ErpBinaryReader reader = new ErpBinaryReader(memData))
                {
                    MipMapFileName = reader.ReadString(reader.ReadByte());
                    UInt32 mipMapCount = reader.ReadUInt32();

                    Mips = new List <ErpGfxSurfaceRes2Mips>((int)mipMapCount);
                    for (int i = 0; i < mipMapCount; ++i)
                    {
                        ErpGfxSurfaceRes2Mips mip = new ErpGfxSurfaceRes2Mips();
                        mip.Compression = (ErpCompressionAlgorithm)reader.ReadByte();
                        mip.Offset      = reader.ReadUInt64();
                        mip.PackedSize  = reader.ReadUInt64();
                        mip.Size        = reader.ReadUInt64();
                        Mips.Add(mip);
                    }

                    // This part was introduces in F1 2017
                    if (reader.BaseStream.Length - reader.BaseStream.Position == 8)
                    {
                        hasTwoUnknowns = true;
                        Unknown        = reader.ReadSingle();
                        Unknown2       = reader.ReadSingle();
                    }
                }
        }
Esempio n. 3
0
        public override void FromFragment(ErpFragment fragment)
        {
            using (var memData = fragment.GetDataStream(true))
                using (ErpBinaryReader reader = new ErpBinaryReader(memData))
                {
                    MipMapFileName = reader.ReadString(reader.ReadByte());
                    UInt32 mipMapCount = reader.ReadUInt32();

                    Mips = new List <ErpGfxSurfaceRes2Mips>((int)mipMapCount);
                    for (int i = 0; i < mipMapCount; ++i)
                    {
                        ErpGfxSurfaceRes2Mips mip = new ErpGfxSurfaceRes2Mips();
                        mip.Unknown = reader.ReadByte();
                        mip.Offset  = reader.ReadUInt64();
                        mip.Width   = reader.ReadUInt64();
                        mip.Height  = reader.ReadUInt64();
                        Mips.Add(mip);
                    }
                }
        }