public void UnSerialize(IOReader reader) { this.Width = reader.ReadUShort(); this.Height = reader.ReadUShort(); this.Flags = (VTFFlags)reader.ReadInt(); this.NumFrames = reader.ReadUShort(); this.StartFrame = reader.ReadUShort(); this.Reflectivity.UnSerialize(reader); this.BumpScale = reader.ReadFloat(); this.ImageFormat = (VTFImageFormat)reader.ReadInt(); this.NumMipLevels = reader.ReadByte(); this.LowResImgFmt = (VTFImageFormat)reader.ReadInt(); this.LowResImgWidth = reader.ReadByte(); this.LowResImgHeight = reader.ReadByte(); }
public void UnSerialize(IOReader reader) { // Make sure we are reading big endian reader.ByteOrder = Endian.Big; this.Flags = (VTFFlags)reader.ReadInt(); this.Width = reader.ReadUShort(); this.Height = reader.ReadUShort(); this.Depth = reader.ReadUShort(); this.NumFrames = reader.ReadUShort(); this.PreloadSize = reader.ReadUShort(); this.MipSkipCount = reader.ReadByte(); this.NumResources = reader.ReadByte(); this.Reflectivity.UnSerialize(reader); this.BumpScale = reader.ReadFloat(); this.ImageFormat = (VTFImageFormat)reader.ReadInt(); this.LowResImgSmple = reader.ReadBytes(4); this.CompressedSize = reader.ReadUInt(); }
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(); }