Beispiel #1
0
        private void UnSerialize(Stream input)
        {
            m_vtfReader = new IOReader(input);
            int ident = this.m_vtfReader.ReadInt();
            if (ident == "VTF\0".MakeID())
                this.m_bIs360 = false;
            else if (ident == "VTFX".MakeID())
            {
                this.m_bIs360 = true;
                this.m_vtfReader.ByteOrder = Endian.Big;
            }
            else
                throw new BadImageFormatException();
            // rewind stream
            m_vtfReader.Seek(-4);
            VTFFileHeader vtfHDR = new VTFFileHeader();
            vtfHDR.UnSerialize(this.m_vtfReader);
            this.m_dwVersionMajor = (int)vtfHDR.VersionMajor;
            this.m_dwVersionMinor = (int)vtfHDR.VersionMinor;

            VTFHeader_PC hdr = new VTFHeader_PC();
            hdr.UnSerialize(this.m_vtfReader);
            this.m_dwResourceCount = (int)hdr.NumResources;
            this.m_dwHeight = hdr.Height;
            this.m_dwWidth = hdr.Width;
            this.m_Format = hdr.ImageFormat;
            this.m_dwFlags = hdr.Flags;
            this.m_dwFrameCount = hdr.NumFrames;
            this.m_dwDepth = hdr.Depth;
            // Envmaps only have 1 face, if its not then it must be a cubemap with 7 sides
            if (m_dwFlags.IsFlagSet<VTFFlags>(VTFFlags.TEXTUREFLAGS_ENVMAP))
                this.m_dwFaceCount = 1;
            else
                this.m_dwFaceCount = 7;
            this.m_vecReflectivity = hdr.Reflectivity;
            this.m_flBumpScale = hdr.BumpScale;
            this.m_dwLowResImageWidth = hdr.LowResImgWidth;
            this.m_dwLowResImageHeight = hdr.LowResImgHeight;
            this.m_LowResImageFormat = hdr.LowResImgFmt;
            this.m_dwMipCount = ComputeMipCount();
        }