Advertisement
kiwidog

FrostbiteTexture

Dec 4th, 2015
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.09 KB | None | 0 0
  1. /*
  2.  * TextureHeader
  3.  * Created by: kiwidog
  4.  * With help from: MSDN
  5.  * Copyright (c) kiwidoggie productions 2005-2014
  6.  * Explicit Permission Given to D. Gintalas for use
  7.  * Source, or any product using this class not to be sold or redistributed without direct written permission
  8. */
  9.  
  10. using System.Text;
  11. using RimeLib.Frostbite.Core;
  12. using RimeLib.IO;
  13.  
  14. namespace RimeLib.Frostbite.Content.Texture
  15. {
  16.     /// <summary>
  17.     /// TextureHeader class
  18.     /// The structure and some helper functions for the fb::TextureHeader class
  19.     /// </summary>
  20.     public class TextureHeader : IModifiable
  21.     {
  22.         public enum FLAGS : ushort
  23.         {
  24.             Streaming = 0x1,
  25.             SrgbGamma = 0x2,
  26.             CpuResource = 0x4,
  27.             OnDemandLoaded = 0x8,
  28.             Mutable = 0x10,
  29.             NoSkipmip = 0x20,
  30.             XenonPackedMipmaps = 0x100,
  31.             Ps3MemoryCell = 0x100,
  32.             Ps3MemoryRsx = 0x200,
  33.         }
  34.  
  35.  
  36.         public uint Version { get; set; }
  37.         public uint Type { get; set; }
  38.         public uint Format { get; set; }
  39.         public uint Flags { get; set; }
  40.         public short Width { get; set; }
  41.         public short Height { get; set; }
  42.         public short Depth { get; set; }
  43.         public short SliceCount { get; set; }
  44.         public short Unused0 { get; set; }
  45.         public byte MipmapCount { get; set; }
  46.         public byte MipmapBaseIndex { get; set; }
  47.         public GUID StreamingChunkId { get; set; }
  48.         public uint[] MipmapSizes { get; set; } // DWORD[15];
  49.         public uint MipmapChainSize { get; set; }
  50.         public uint ResourceNamehash { get; set; }
  51.         public string TextureGroup { get; set; } // Len16
  52.         public TextureHeader()
  53.         {
  54.  
  55.         }
  56.  
  57.         /// <summary>
  58.         /// TextureHeader Constructor
  59.         /// This will read out the ITexture structure at an opened stream where the position is at a ITexture structure in the data
  60.         /// </summary>
  61.         /// <param name="reader">Reference to an IceReader class</param>
  62.         public TextureHeader(RimeReader p_Reader)
  63.         {
  64.             Load(p_Reader);
  65.         }
  66.  
  67.         public void Load(RimeReader p_Reader)
  68.         {
  69.             Version = p_Reader.ReadUInt32();
  70.             Type = p_Reader.ReadUInt32();
  71.             Format = p_Reader.ReadUInt32();
  72.             Flags = p_Reader.ReadUInt32();
  73.             Width = p_Reader.ReadInt16();
  74.             Height = p_Reader.ReadInt16();
  75.             Depth = p_Reader.ReadInt16();
  76.             SliceCount = p_Reader.ReadInt16();
  77.             Unused0 = p_Reader.ReadInt16();
  78.             MipmapCount = p_Reader.ReadByte();
  79.             MipmapBaseIndex = p_Reader.ReadByte();
  80.             StreamingChunkId = new GUID(p_Reader);
  81.            
  82.             MipmapSizes = new uint[15];
  83.             for (var i = 0; i < 15; ++i)
  84.                 MipmapSizes[i] = p_Reader.ReadUInt32();
  85.  
  86.             MipmapChainSize = p_Reader.ReadUInt32();
  87.             ResourceNamehash = p_Reader.ReadUInt32();
  88.             TextureGroup = Encoding.UTF8.GetString(p_Reader.ReadBytes(16));
  89.         }
  90.     }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement