Beispiel #1
0
        internal Texture(TextureInfo info)
        {
            Name = info.Name;
            Width = info.Width;
            Height = info.Height;

            switch (info.Format)
            {
                case D3DFormat.DXT1:
                    TextureType = TextureType.DXT1;
                    break;
                case D3DFormat.DXT3:
                    TextureType = TextureType.DXT3;
                    break;
                case D3DFormat.DXT5:
                    TextureType = TextureType.DXT5;
                    break;
                case D3DFormat.A8R8G8B8:
                    TextureType = TextureType.A8R8G8B8;
                    break;
                case D3DFormat.L8:
                    TextureType = TextureType.L8;
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            Levels = info.Levels;
            Info = info;
        }
Beispiel #2
0
        public void Open(Stream systemMemory, Stream graphicsMemory)
        {
            // Sys

            var ms = systemMemory;
            var br = new BinaryReader(ms);

            Header = new Header();
            Header.Read(br);

            TexturesByHash = new Dictionary<uint, TextureInfo>(Header.TextureCount);
            Textures = new List<TextureInfo>(Header.TextureCount);

            var textureHashes = new uint[Header.TextureCount];
            var infoOffsets = new uint[Header.TextureCount];

            ms.Seek(Header.HashTableOffset, SeekOrigin.Begin);
            for (int i = 0; i < Header.TextureCount; i++)
            {
                textureHashes[i] = br.ReadUInt32();
            }

            ms.Seek(Header.TextureListOffset, SeekOrigin.Begin);
            for (int i = 0; i < Header.TextureCount; i++)
            {
                infoOffsets[i] = ResourceUtil.ReadOffset(br);
            }

            for (int i = 0; i < Header.TextureCount; i++)
            {
                ms.Seek(infoOffsets[i], SeekOrigin.Begin);

                var info = new TextureInfo { File = this };
                info.Read(br);

                Textures.Add(info);
                TexturesByHash.Add(textureHashes[i], info);
            }

            // Gfx

            ms = graphicsMemory;
            br = new BinaryReader(ms);

            for (int i = 0; i < Header.TextureCount; i++)
            {
                Textures[i].ReadData(br);
            }
        }