Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * TextureHeader
- * Created by: kiwidog
- * With help from: MSDN
- * Copyright (c) kiwidoggie productions 2005-2014
- * Explicit Permission Given to D. Gintalas for use
- * Source, or any product using this class not to be sold or redistributed without direct written permission
- */
- using System.Text;
- using RimeLib.Frostbite.Core;
- using RimeLib.IO;
- namespace RimeLib.Frostbite.Content.Texture
- {
- /// <summary>
- /// TextureHeader class
- /// The structure and some helper functions for the fb::TextureHeader class
- /// </summary>
- public class TextureHeader : IModifiable
- {
- public enum FLAGS : ushort
- {
- Streaming = 0x1,
- SrgbGamma = 0x2,
- CpuResource = 0x4,
- OnDemandLoaded = 0x8,
- Mutable = 0x10,
- NoSkipmip = 0x20,
- XenonPackedMipmaps = 0x100,
- Ps3MemoryCell = 0x100,
- Ps3MemoryRsx = 0x200,
- }
- public uint Version { get; set; }
- public uint Type { get; set; }
- public uint Format { get; set; }
- public uint Flags { get; set; }
- public short Width { get; set; }
- public short Height { get; set; }
- public short Depth { get; set; }
- public short SliceCount { get; set; }
- public short Unused0 { get; set; }
- public byte MipmapCount { get; set; }
- public byte MipmapBaseIndex { get; set; }
- public GUID StreamingChunkId { get; set; }
- public uint[] MipmapSizes { get; set; } // DWORD[15];
- public uint MipmapChainSize { get; set; }
- public uint ResourceNamehash { get; set; }
- public string TextureGroup { get; set; } // Len16
- public TextureHeader()
- {
- }
- /// <summary>
- /// TextureHeader Constructor
- /// This will read out the ITexture structure at an opened stream where the position is at a ITexture structure in the data
- /// </summary>
- /// <param name="reader">Reference to an IceReader class</param>
- public TextureHeader(RimeReader p_Reader)
- {
- Load(p_Reader);
- }
- public void Load(RimeReader p_Reader)
- {
- Version = p_Reader.ReadUInt32();
- Type = p_Reader.ReadUInt32();
- Format = p_Reader.ReadUInt32();
- Flags = p_Reader.ReadUInt32();
- Width = p_Reader.ReadInt16();
- Height = p_Reader.ReadInt16();
- Depth = p_Reader.ReadInt16();
- SliceCount = p_Reader.ReadInt16();
- Unused0 = p_Reader.ReadInt16();
- MipmapCount = p_Reader.ReadByte();
- MipmapBaseIndex = p_Reader.ReadByte();
- StreamingChunkId = new GUID(p_Reader);
- MipmapSizes = new uint[15];
- for (var i = 0; i < 15; ++i)
- MipmapSizes[i] = p_Reader.ReadUInt32();
- MipmapChainSize = p_Reader.ReadUInt32();
- ResourceNamehash = p_Reader.ReadUInt32();
- TextureGroup = Encoding.UTF8.GetString(p_Reader.ReadBytes(16));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement