public override void FromFragment(ErpFragment fragment)
        {
            using (var memData = fragment.GetDataStream(true))
                using (ErpBinaryReader reader = new ErpBinaryReader(memData))
                {
                    Unknown     = reader.ReadInt32();
                    Unknown2    = reader.ReadInt32();
                    ImageType   = (ErpGfxSurfaceFormat)reader.ReadInt32();
                    Width       = reader.ReadUInt32();
                    Height      = reader.ReadUInt32();
                    Unknown3    = reader.ReadInt32();
                    MipMapCount = reader.ReadUInt32();
                    ArraySize   = reader.ReadUInt32();
                    Unknown4    = reader.ReadInt32();

                    _leftoverBytes = reader.BaseStream.Length - reader.BaseStream.Position;
                    if (_leftoverBytes == 4)
                    {
                        // noticed this extra field in F1 2020, not sure if in earlier ones
                        Unknown5 = reader.ReadInt32();
                    }
                    else if (_leftoverBytes > 0)
                    {
                        throw new NotSupportedException("The GfxSurfaceRes0 data is not supported.");
                    }
                }
        }
        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. 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.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. 4
0
 public override void FromFragment(ErpFragment fragment)
 {
     using var memData   = fragment.GetDataStream(true);
     using var reader    = new ErpBinaryReader(memData);
     Unknown             = reader.ReadInt32();
     ImageType           = (ErpGfxSurfaceFormat)reader.ReadInt32();
     Unknown2            = reader.ReadInt32();
     MipMapCount         = reader.ReadUInt32();
     Unknown3            = reader.ReadInt32();
     Unknown4            = reader.ReadInt32();
     SurfaceResourceName = reader.ReadString();
 }
Esempio n. 5
0
 public override void FromFragment(ErpFragment fragment)
 {
     using (var memData = fragment.GetDataStream(true))
         using (ErpBinaryReader reader = new ErpBinaryReader(memData))
         {
             Unknown     = reader.ReadInt32();
             Unknown2    = reader.ReadInt32();
             ImageType   = (ErpGfxSurfaceFormat)reader.ReadInt32();
             Width       = reader.ReadUInt32();
             Height      = reader.ReadUInt32();
             Unknown3    = reader.ReadInt32();
             MipMapCount = reader.ReadUInt32();
             ArraySize   = reader.ReadUInt32();
             Unknown4    = reader.ReadInt32();
         }
 }
Esempio n. 6
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);
                    }
                }
        }