Пример #1
0
        public void SaveFromModel(STGenericModel model, string FileName, List <STGenericTexture> Textures, STSkeleton skeleton = null, List <int> NodeArray = null)
        {
            ExtractedTextures.Clear();

            Scene scene = new Scene();

            scene.RootNode = new Node("RootNode");

            progressBar               = new STProgressBar();
            progressBar.Task          = "Exorting Skeleton...";
            progressBar.Value         = 0;
            progressBar.StartPosition = FormStartPosition.CenterScreen;
            progressBar.Show();
            progressBar.Refresh();

            SaveSkeleton(skeleton, scene.RootNode);
            SaveMaterials(scene, model, FileName, Textures);

            progressBar.Task  = "Exorting Meshes...";
            progressBar.Value = 50;

            SaveMeshes(scene, model, skeleton, FileName, NodeArray);

            progressBar.Task  = "Saving File...";
            progressBar.Value = 80;

            SaveScene(FileName, scene, model.GetObjects());

            progressBar.Value = 100;
            progressBar.Close();
            progressBar.Dispose();
        }
        public static void ExtractAllFiles(string ParentPath, TreeNodeCollection Nodes)
        {
            FolderSelectDialog folderDialog = new FolderSelectDialog();

            if (folderDialog.ShowDialog() == DialogResult.OK)
            {
                STProgressBar progressBar = new STProgressBar();
                progressBar.Task = "Extracing Files...";
                progressBar.Refresh();
                progressBar.Value         = 0;
                progressBar.StartPosition = FormStartPosition.CenterScreen;
                progressBar.Show();

                var Collection = TreeViewExtensions.Collect(Nodes);

                int Curfile = 0;
                foreach (TreeNode file in Collection)
                {
                    if (file is ArchiveFileWrapper)
                    {
                        string FilePath      = ((ArchiveFileWrapper)file).ArchiveFileInfo.FileName;
                        string FolderPath    = Path.GetDirectoryName(FilePath.RemoveIllegaleFolderNameCharacters());
                        string FolderPathDir = Path.Combine(folderDialog.SelectedPath, FolderPath);

                        if (!Directory.Exists(FolderPathDir))
                        {
                            Directory.CreateDirectory(FolderPathDir);
                        }

                        string FileName = file.Text.RemoveIllegaleFileNameCharacters();

                        FilePath = Path.Combine(FolderPath, FileName);

                        if (ParentPath != string.Empty)
                        {
                            FilePath = FilePath.Replace(ParentPath, string.Empty);
                        }

                        var path = Path.Combine(folderDialog.SelectedPath, FilePath);

                        progressBar.Task  = $"Extracting File {file}";
                        progressBar.Value = (Curfile++ *100) / Collection.Count();
                        progressBar.Refresh();
                        CreateDirectoryIfExists($"{path}");

                        if (file is ArchiveFileWrapper)
                        {
                            File.WriteAllBytes($"{path}",
                                               ((ArchiveFileWrapper)file).ArchiveFileInfo.FileData);
                        }
                    }
                }

                progressBar.Value = 100;
                progressBar.Refresh();
                progressBar.Close();
            }
        }
        public void SaveBitMap(string FileName, int SurfaceLevel = 0, int MipLevel = 0)
        {
            STProgressBar progressBar = new STProgressBar();

            progressBar.Task          = "Exporting Image Data...";
            progressBar.Value         = 0;
            progressBar.StartPosition = FormStartPosition.CenterScreen;
            progressBar.Show();
            progressBar.Refresh();

            if (ArrayCount > 1)
            {
                progressBar.Task = "Select dialog option... ";

                var result = MessageBox.Show("Multiple image surfaces found! Would you like to export them all?", "Image Exporter",
                                             MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                if (result == DialogResult.Yes)
                {
                    string ext = Path.GetExtension(FileName);

                    int    index = FileName.LastIndexOf('.');
                    string name  = index == -1 ? FileName : FileName.Substring(0, index);

                    for (int i = 0; i < ArrayCount; i++)
                    {
                        progressBar.Task  = $"Decoding Surface [{i}] for image {Text}... ";
                        progressBar.Value = (i * 100) / (int)ArrayCount;
                        progressBar.Refresh();

                        Bitmap arrayBitMap = GetBitmap(i, 0);
                        arrayBitMap.Save($"{name}_Slice_{i}_{ext}");
                        arrayBitMap.Dispose();
                    }

                    progressBar.Value = 100;
                    progressBar.Close();

                    return;
                }
            }

            progressBar.Task  = $"Decoding image {Text}... ";
            progressBar.Value = 20;
            progressBar.Refresh();

            Bitmap bitMap = GetBitmap(SurfaceLevel, MipLevel);

            bitMap.Save(FileName);
            bitMap.Dispose();

            progressBar.Value = 100;
            progressBar.Close();
        }