Exemplo n.º 1
0
        public void ToData(BinaryWriter writer, GameType gameType)
        {
            writer.Write((byte)Header.Type);
            writer.Write((byte)0);
            writer.Write(Header.Width);
            writer.Write(Header.Height);

            switch (Header.Type)
            {
            case BaseTextureType._2D:
            case BaseTextureType.CubeMap:
                writer.Write((ushort)0);
                break;

            case BaseTextureType._3D:
                writer.Write((byte)BitOperations.Log2(Header.Depth3D));
                writer.Write((byte)0);
                break;

            case BaseTextureType._2DArray:
                writer.Write((ushort)Header.ArraySliceCount);
                break;

            default:
                throw new NotImplementedException("Unknown texture type");
            }

            writer.Write(Header.MipCount);
            writer.Write((byte)Header.PixelFormat);
            writer.Write(Header.Unknown1);
            writer.Write(Header.Unknown2);
            writer.Write(Header.Unknown3);
            writer.Write(Header.Flags);
            writer.Write(Header.Unknown4);
            writer.Write(Header.Unknown5);
            Header.ResourceDataHash.ToData(writer);

            // Raw pixel data handling
            using var ms = new MemoryStream();
            using var bw = new BinaryWriter(ms);

            bw.Write(EmbeddedDataSize);
            bw.Write(StreamHandle?.ResourceSize() ?? 0);
            bw.Write(StreamedMipCount);

            if (gameType == GameType.DS)
            {
                bw.Write(DeathStrandingUnknown);
            }

            StreamHandle?.ToData(bw);

            if (EmbeddedTextureData?.Length > 0)
            {
                bw.Write(EmbeddedTextureData);
            }

            writer.Write((uint)ms.Length);
            ms.WriteTo(writer.BaseStream);
        }
Exemplo n.º 2
0
 public void ToData(BinaryWriter writer)
 {
     if (StreamingMode == BaseRenderDataStreamingMode.Streaming)
     {
         StreamInfo?.ToData(writer);
     }
     else
     {
         writer.Write(Data);
     }
 }
Exemplo n.º 3
0
 public void ToData(BinaryWriter writer)
 {
     if (Streaming)
     {
         StreamInfo?.ToData(writer);
     }
     else
     {
         writer.Write(Data);
     }
 }