Пример #1
0
		private void LoadModel(DirEntry DirEntry)
		{
			var statusPrefix = string.Format("Loading '{0}'", DirEntry.Name);
			PushStatusMessage(statusPrefix);
			var data = _resourceLoader.LoadData(DirEntry);

			statusPrefix += ": ";

			PushStatusMessage(statusPrefix + "Decompressing");
			var decompressed = FalcomDecompressor.Decompress(data);

			PushStatusMessage(statusPrefix + "Parsing mesh data");

			Frame frame;
			using (var stream = new MemoryStream(decompressed))
			{
				frame = ModelLoader.Load(stream, DirEntry.Name.EndsWith("_X2") ? 2 : 3);
			}

			var meshes = frame.Children[0].Meshes;

			var modelMeshes = new List<ModelMeshPart>();

			var tasks = new List<Task>();

			var meshesCount = (from m in meshes select m.Materials.Count).Sum();
			foreach (var meshData in meshes)
			{
				tasks.Add(Task.Factory.StartNew(() =>
				{
					ProcessMesh(modelMeshes, statusPrefix, meshData, meshesCount);
				}));
			}

			Task.WaitAll(tasks.ToArray());

			_executionContext.Scene.Meshes = modelMeshes;
		}
Пример #2
0
        static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine("Usage: Unpacker <path/to/sora> <output/path>");
                return;
            }

            try
            {
                var entries = DirProcessor.BuildEntries(args[0]);

                foreach (var pair in entries)
                {
                    Console.WriteLine("Processing '{0}'", pair.Key);

                    foreach (var entry in pair.Value)
                    {
                        if (entry.CompressedSize == 0 || entry.DecompressedSize == 0)
                        {
                            continue;
                        }

                        if (!entry.Name.EndsWith("_X2"))
                        {
                            continue;
                        }

                        var unpack = !entry.Name.EndsWith("_DT") && !entry.Name.EndsWith("_DS") &&
                                     !entry.Name.EndsWith("WAV") && !entry.Name.EndsWith("_VS");
                        if (unpack)
                        {
                            Console.WriteLine("Unpacking '{0}'", entry.Name);
                        }
                        else
                        {
                            Console.WriteLine("Saving '{0}'", entry.Name);
                        }

                        try
                        {
                            byte[] bytes = new byte[entry.CompressedSize];
                            using (var stream = File.OpenRead(pair.Key))
                            {
                                stream.Seek(entry.Offset, SeekOrigin.Begin);
                                stream.Read(bytes, 0, bytes.Length);
                            }
                            if (unpack)
                            {
                                bytes = FalcomDecompressor.Decompress(bytes);
                            }

                            var outputPath = Path.Combine(args[1], entry.Name);
                            File.WriteAllBytes(outputPath, bytes);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Пример #3
0
        static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine("Usage: Unpacker <path/to/sora> <output/path>");
                return;
            }

            try
            {
                var entries = DirProcessor.BuildEntries(args[0]);

                foreach (var pair in entries)
                {
                    Console.WriteLine("Processing '{0}'", pair.Key);

                    foreach (var entry in pair.Value)
                    {
                        if (entry.CompressedSize == 0 || entry.DecompressedSize == 0)
                        {
                            continue;
                        }

                        if (!entry.Name.EndsWith("_SN"))
                        {
                            continue;
                        }

/*						if (!entry.Name.StartsWith("T0310"))
 *                                              {
 *                                                      continue;
 *                                              }*/

                        Console.WriteLine("Processing script '{0}'", entry.Name);

                        try
                        {
                            byte[] bytes = new byte[entry.CompressedSize];
                            using (var stream = File.OpenRead(pair.Key))
                            {
                                stream.Seek(entry.Offset, SeekOrigin.Begin);
                                stream.Read(bytes, 0, bytes.Length);
                            }

                            bytes = FalcomDecompressor.Decompress(bytes);

                            var output = string.Empty;
                            using (var stream = new MemoryStream(bytes))
                            {
                                var scenario = Scenario.FromFCStream(stream);
                                output = scenario.ToString();
                            }

                            var fileName = Path.Combine(args[1], Path.ChangeExtension(entry.Name, "txt"));
                            File.WriteAllText(fileName, output);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }