public static FtexFileMipMapInfo ReadFtexFileMipMapInfo(Stream inputStream) { FtexFileMipMapInfo result = new FtexFileMipMapInfo(); result.Read(inputStream); return(result); }
private void Read(Stream inputStream) { BinaryReader reader = new BinaryReader(inputStream, Encoding.Default, true); reader.Assert(MagicNumber1); PixelFormatType = reader.ReadInt16(); Width = reader.ReadInt16(); Height = reader.ReadInt16(); Depth = reader.ReadInt16(); MipMapCount = reader.ReadByte(); NrtFlag = reader.ReadByte(); UnknownFlags = (FtexUnknownFlags)reader.ReadInt16(); reader.Assert(OneInt32); reader.Assert(ZeroInt32); TextureType = (FtexTextureType)reader.ReadInt32(); FtexsFileCount = reader.ReadByte(); AdditionalFtexsFileCount = reader.ReadByte(); reader.Assert(ZeroByte); reader.Assert(ZeroByte); reader.Assert(ZeroInt32); reader.Assert(ZeroInt32); reader.Assert(ZeroInt32); Hash = reader.ReadBytes(16); for (int i = 0; i < MipMapCount; i++) { FtexFileMipMapInfo fileMipMapInfo = FtexFileMipMapInfo.ReadFtexFileMipMapInfo(inputStream); AddMipMapInfo(fileMipMapInfo); } }
public void UpdateOffsets() { int mipMapIndex = 0; foreach (var ftexsFile in FtexsFiles) { foreach (var ftexsFileMipMap in ftexsFile.MipMaps) { FtexFileMipMapInfo ftexMipMapInfo = MipMapInfos.ElementAt(mipMapIndex); ftexMipMapInfo.Size = ftexsFileMipMap.BlockSize; ftexMipMapInfo.ChunkCount = Convert.ToInt16(ftexsFileMipMap.Chunks.Count()); ftexMipMapInfo.Offset = (int)ftexsFileMipMap.BaseOffset; ++mipMapIndex; } } }
private void AddMipMapInfo(FtexFileMipMapInfo fileMipMapInfo) { _mipMapInfos.Add(fileMipMapInfo); }
public static FtexFileMipMapInfo ReadFtexFileMipMapInfo(X360Reader reader) { FtexFileMipMapInfo result = new FtexFileMipMapInfo(); result.Read(reader); return result; }
private static List<FtexFileMipMapInfo> GetMipMapInfos(List<byte[]> levelData) { List<FtexFileMipMapInfo> mipMapsInfos = new List<FtexFileMipMapInfo>(); for (int i = 0; i < levelData.Count; i++) { FtexFileMipMapInfo mipMapInfo = new FtexFileMipMapInfo(); int fileSize = levelData[i].Length; mipMapInfo.DecompressedFileSize = fileSize; mipMapInfo.Index = Convert.ToByte(i); mipMapsInfos.Add(mipMapInfo); } SetMipMapFileNumber(mipMapsInfos); return mipMapsInfos; }
private static List<FtexsFileChunk> GetFtexsChunks(FtexFileMipMapInfo mipMapInfo, byte[] mipMapData) { List<FtexsFileChunk> ftexsFileChunks = new List<FtexsFileChunk>(); const int maxChunkSize = short.MaxValue; int requiredChunks = (int)Math.Ceiling((double)mipMapData.Length / maxChunkSize); int mipMapDataOffset = 0; for (int i = 0; i < requiredChunks; i++) { FtexsFileChunk chunk = new FtexsFileChunk(); int chunkSize = Math.Min(mipMapData.Length - mipMapDataOffset, maxChunkSize); byte[] chunkData = new byte[chunkSize]; Array.Copy(mipMapData, mipMapDataOffset, chunkData, 0, chunkSize); chunk.SetData(chunkData, false, chunkSize); ftexsFileChunks.Add(chunk); mipMapDataOffset += chunkSize; } return ftexsFileChunks; }
public static FtexFileMipMapInfo ReadFtexFileMipMapInfo(Stream inputStream) { FtexFileMipMapInfo result = new FtexFileMipMapInfo(); result.Read(inputStream); return result; }