Beispiel #1
0
        /// <summary>
        /// Reads in the clamp settings and mipmap count for each texture.
        /// Textures are often duplicated to have one image with multiple pairs of clamp settings.
        /// </summary>
        /// <param name="reader"></param>
        public void GetTextureSettings(EndianBinaryReader reader)
        {
            // Get the offset of the TexBlock, get the offset of the next section, save the reader's current offset,
            // then go to the TextureSettings section
            int  offset            = reader.ReadInt32();
            int  nextSectionOffset = reader.PeekReadInt32();
            long curOffset         = reader.BaseStream.Position;

            reader.BaseStream.Seek(offset, System.IO.SeekOrigin.Begin);

            // New list to store the images with proper clamp settings
            List <BinaryTextureImage> newImageList = new List <BinaryTextureImage>();

            while ((reader.PeekReadInt32() & 0xFFFF) == 0xFFFF && reader.BaseStream.Position != nextSectionOffset)
            {
                // Create a new texture from the texture at the index provided
                BinaryTextureImage modifiedTex = new BinaryTextureImage(Images[reader.ReadInt16()]);
                reader.SkipInt16(); // Padding, 0xFFFF
                modifiedTex.SetTexSettingsFromBin(reader);
                newImageList.Add(modifiedTex);
                Textures.Add(new Texture(modifiedTex));
            }

            // Replace original list of textures
            Images = newImageList;
            DumpTextures(@"D:\SZS Tools\TextureTest");

            reader.BaseStream.Seek(curOffset, System.IO.SeekOrigin.Begin);
        }