Пример #1
0
        private static FtexFile GetFtexFile(string filePath)
        {
            string fileDirectory = Path.GetDirectoryName(filePath);
            string fileName = Path.GetFileNameWithoutExtension(filePath);

            FtexFile ftexFile;
            using (FileStream ftexStream = new FileStream(filePath, FileMode.Open))
            {
                ftexFile = FtexFile.ReadFtexFile(ftexStream);
            }

            for (byte fileNumber = 1; fileNumber <= ftexFile.FtexsFileCount; fileNumber++)
            {
                FtexsFile ftexsFile = new FtexsFile
                {
                    FileNumber = fileNumber
                };
                ftexFile.AddFtexsFile(ftexsFile);
            }

            foreach (var mipMapInfo in ftexFile.MipMapInfos)
            {
                string ftexsName = String.Format("{0}.{1}.ftexs", fileName, mipMapInfo.FtexsFileNumber);
                string ftexsFilePath = Path.Combine(fileDirectory, ftexsName);

                try
                {
                    using (FileStream ftexsStream = new FileStream(ftexsFilePath, FileMode.Open))
                    {
                        ftexsStream.Position = mipMapInfo.Offset;
                        FtexsFile ftexsFile;
                        ftexFile.TryGetFtexsFile(mipMapInfo.FtexsFileNumber, out ftexsFile);
                        ftexsFile.Read(ftexsStream, mipMapInfo.ChunkCount);
                    }
                }
                catch (FileNotFoundException e)
                {
                    throw new MissingFtexsFileException("The ftexs file " + ftexsName + " could not be found.", e);
                }
            }
            return ftexFile;
        }
Пример #2
0
 public bool TryGetFtexsFile(int fileNumber, out FtexsFile ftexsFile)
 {
     return _ftexsFiles.TryGetValue(fileNumber, out ftexsFile);
 }
Пример #3
0
 public void AddFtexsFile(FtexsFile ftexsFile)
 {
     _ftexsFiles.Add(ftexsFile.FileNumber, ftexsFile);
 }
Пример #4
0
        private static List<FtexsFile> GetFtexsFiles(List<FtexFileMipMapInfo> mipMapInfos, List<byte[]> mipMapDatas)
        {
            Dictionary<byte, FtexsFile> ftexsFiles = new Dictionary<byte, FtexsFile>();

            foreach (var mipMapInfo in mipMapInfos)
            {
                if (ftexsFiles.ContainsKey(mipMapInfo.FtexsFileNumber) == false)
                {
                    FtexsFile ftexsFile = new FtexsFile
                    {
                        FileNumber = mipMapInfo.FtexsFileNumber
                    };
                    ftexsFiles.Add(mipMapInfo.FtexsFileNumber, ftexsFile);
                }
            }

            for (int i = 0; i < mipMapInfos.Count; i++)
            {
                FtexFileMipMapInfo mipMapInfo = mipMapInfos[i];
                FtexsFile ftexsFile = ftexsFiles[mipMapInfo.FtexsFileNumber];
                byte[] mipMapData = mipMapDatas[i];
                FtexsFileMipMap ftexsFileMipMap = new FtexsFileMipMap();
                List<FtexsFileChunk> chunks = GetFtexsChunks(mipMapInfo, mipMapData);
                ftexsFileMipMap.AddChunks(chunks);
                ftexsFile.AddMipMap(ftexsFileMipMap);
            }
            return ftexsFiles.Values.ToList();
        }