Ejemplo n.º 1
0
        public override bool ExportScene(string absPath, bool bShowDialog)
        {
            string assetProfileOverride = null;

              // if we do not show the dialog, we must use the active profile
              if (!bShowDialog)
              {
            assetProfileOverride = EditorManager.ProfileManager.GetActiveProfile()._name;
              }

              if (bShowDialog)
              {
            // Open export dialog
            ExportDialog dlg = new ExportDialog();
            using (dlg)
            {
              CurrentExportProfile.ExportedLayersFromScene(); // retrieve current status
              dlg.Settings = CurrentExportProfile; // clones the settings
              dlg.AutoSaveExportProfile = Settings.AutoSaveExportProfile;

              // Show dialog
              if (dlg.ShowDialog() != DialogResult.OK)
            return true;

              // Get back settings
              SceneExportProfile newProfile = dlg.Settings;
              if (!CurrentExportProfile.Equals(newProfile))
            Dirty = true;
              _currentProfile = newProfile;
              Settings.ExportProfileName = CurrentExportProfile.ProfileName;
              Settings.AutoSaveExportProfile = dlg.AutoSaveExportProfile;

              if (dlg.ExportActiveProfileOnly)
              {
            assetProfileOverride = EditorManager.ProfileManager.GetActiveProfile()._name;
              }

              EditorManager.EngineManager.CheckLightGridDataExists();
            }
              }

              // Deactivate isolate selection mode temporarily
              EditorManager.ActiveView.IsolateSelection(false, true);

              // Ensure that scene script file is set in script manager
              // This is e.g. required if the script was broken when the scene was loaded but it was corrected in the meantime
              // then the exporter scene will have the proper script
              string sceneScriptFile = ((V3DLayer)EditorManager.Scene.MainLayer).SceneScriptFile;
              if (sceneScriptFile != null && sceneScriptFile.Length > 0)
              {
            ScriptManager.SetSceneScriptFile(sceneScriptFile);
              }

              // Export
              bool bSuccess = ExportScene(absPath, assetProfileOverride);
              string absExportPath = absPath;
              if (absExportPath == null)
            absExportPath = AbsoluteExportPath;

              // Reactivate isolate selection mode
              EditorManager.ActiveView.IsolateSelection(true, true);

              // now launch the viewer
              if (bSuccess && CurrentExportProfile.RunAfterExport)
              {
            // Try to find the optimal profile to run:
            string profileToRun = null;
            if (assetProfileOverride != null)
            {
              // If exporting for one specific profile, use that one
              profileToRun = assetProfileOverride;
            }
            else if (CurrentExportProfile.SelectedAssetProfiles.IsActiveProfileSet)
            {
              // If the current profile is among the selected profiles, use that one
              profileToRun = EditorManager.ProfileManager.GetActiveProfile()._name;
            }
            else
            {
              // Otherwise, use the first profile we can find.
              foreach (IProfileManager.Profile profile in EditorManager.ProfileManager.GetProfiles())
              {
            if (CurrentExportProfile.SelectedAssetProfiles.IsProfileSet(profile._name))
            {
              profileToRun = profile._name;
              break;
            }
              }
            }

            // If there is a profile we can run, start the scene viewer.
            if (profileToRun != null)
            {
              string sceneToRun = absExportPath;
              string oldExtension = Path.GetExtension(sceneToRun);
              sceneToRun = Path.ChangeExtension(sceneToRun, profileToRun) + oldExtension;

              string path = Path.GetDirectoryName(Application.ExecutablePath);
              string absSceneViewerPath = Path.Combine(path, "vSceneViewer.exe");
              FileHelper.RunExternalTool("Scene Viewer", absSceneViewerPath, "\"" + sceneToRun + "\"", false);
            }
              }
              return bSuccess;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Exports all found scene files
        /// </summary>
        private void DoExport()
        {
            // Enter the testing mode (since we don't want any user dialogs etc.)
              TestManager.IsRunning = true;

              while (_scenesToProcess.Count > 0 && _state != State_e.Cancelling)
              {
            // Get one scene from the queue
            _currentScene = _scenesToProcess[0];
            _scenesToProcess.RemoveAt(0);

            textBoxLog.Text += string.Format("Processing {0}: ", _currentScene);

            // Load the scene
            TestManager.Helpers.OpenSceneFromFile(_currentScene);
            TestManager.Helpers.ProcessEvents();

            // Force the folder type to version controlled, since we didn't have a chance to when loading the scene
            EditorManager.Project.FolderType = IProject.FolderType_e.RCS;
            EditorManager.Project.UpdateRCSStatus(true);
            TestManager.Helpers.ProcessEvents();

            // Actual export unless cancel has been clicked while loading
            if (_state != State_e.Cancelling)
            {
              // Check if the exported scene file name is correct
              string exportedSceneFile = Path.GetFileName(EditorManager.Scene.CurrentExportProfile.ExportPath);
              string defaultExportName = Path.GetFileName(Path.ChangeExtension(_currentScene, CSharpFramework.Scene.SceneExportProfile.FILE_EXTENSION_EXPORT));

              bool showExportDialog = false;

              if (exportedSceneFile != defaultExportName)
              {
            textBoxLog.Text += string.Format("\r\nScene name mismatch: {0} instead of {1}: ", exportedSceneFile, defaultExportName);

            if (radioMismatch_Dialog.Checked)
            {
              showExportDialog = true;
            }
            else if (radioMismatch_Revert.Checked)
            {
              string subDir = Path.GetDirectoryName(EditorManager.Scene.CurrentExportProfile.ExportPath);
              EditorManager.Scene.CurrentExportProfile.ExportPath = Path.Combine(subDir, defaultExportName);
              textBoxLog.Text += string.Format("Reverted.\r\n");
            }
            else
            {
              textBoxLog.Text += string.Format("Ignoring.\r\n");
            }
              }

              EditorScene scene = EditorManager.Scene as EditorScene;

              if (showExportDialog)
              {
            // Open export dialog
            using (ExportDialog dlg = new ExportDialog())
            {
              scene.CurrentExportProfile.ExportedLayersFromScene(); // retrieve current status
              dlg.Settings = scene.CurrentExportProfile; // clones the settings
              dlg.AutoSaveExportProfile = scene.Settings.AutoSaveExportProfile;

              // Show dialog
              if (dlg.ShowDialog() != DialogResult.OK)
              {
                continue;
              }

              // Get back settings
              scene.CurrentExportProfile = dlg.Settings;

              scene.Settings.ExportProfileName = scene.CurrentExportProfile.ProfileName;
              scene.Settings.AutoSaveExportProfile = dlg.AutoSaveExportProfile;
            }
              }

              // Always export all zones
              foreach (Zone zone in EditorManager.Scene.Zones)
              {
            zone.Export = true;
              }

              if (checkBoxMoveToCamera.Checked)
              {
            // TODO: Move camera to a sensible position
              }

              EditorManager.Progress.Percentage = 0;

              // Export all profiles
              List<string> assetProfiles = new List<string>();
              foreach (IProfileManager.Profile profile in EditorManager.ProfileManager.GetProfiles())
              {
            assetProfiles.Add(profile.ToString());
              }

              // Export the scene
              EditorManager.GUI.UIUpdateLock++;
              EditorManager.Scene.ExportScene(null, assetProfiles);
              EditorManager.GUI.UIUpdateLock--;

              if (showExportDialog)
            textBoxLog.Text += string.Format("Manually set to {0}.\r\n", Path.GetFileName(EditorManager.Scene.CurrentExportProfile.ExportPath));
              textBoxLog.Text += string.Format("Export done. ");
              TestManager.Helpers.ProcessEvents();

              // Resave scene
              if (checkBoxResaveScene.Checked)
              {
            EditorManager.Scene.Save();
            textBoxLog.Text += string.Format("Scene file resaved. ");
            TestManager.Helpers.ProcessEvents();
              }

              textBoxLog.Text += string.Format("\r\n");
            }

            // Close the project
            TestManager.Helpers.CloseActiveProject();
            TestManager.Helpers.ProcessEvents();

            _scenesProcessed++;
              }

              if (State == State_e.Cancelling)
              {
            textBoxLog.Text += string.Format("\r\nAborted.\r\n");
              }

              // Reset state
              _currentScene = null;
              State = State_e.None;
              EditorManager.Progress.StatusString = "";
              EditorManager.Progress.Percentage = 0;
              EditorManager.Progress.ProgressDialogEnabled = true;

              // Go back to normal operation mode
              TestManager.IsRunning = false;
        }
Ejemplo n.º 3
0
        // Export the scene
        private void Menu_File_ExportScene_Click(object sender, System.EventArgs e)
        {
            EditorScene scene = EditorManager.Scene as EditorScene;

              if (scene == null)
              {
            return;
              }

              List<string> assetProfiles = new List<string>();

              // Open export dialog
              using(ExportDialog dlg = new ExportDialog())
              {
            EditorManager.Scene.CurrentExportProfile.ExportedLayersFromScene(); // retrieve current status
            dlg.Settings = EditorManager.Scene.CurrentExportProfile; // clones the settings
            dlg.AutoSaveExportProfile = scene.Settings.AutoSaveExportProfile;

            // Show dialog
            if (dlg.ShowDialog() != DialogResult.OK)
            {
              return;
            }

            // Get back settings
            scene.CurrentExportProfile = dlg.Settings;

            scene.Settings.ExportProfileName = EditorManager.Scene.CurrentExportProfile.ProfileName;
            scene.Settings.AutoSaveExportProfile = dlg.AutoSaveExportProfile;

            if (dlg.ExportActiveProfileOnly)
            {
              assetProfiles.Add(EditorManager.ProfileManager.GetActiveProfile().ToString());
            }
            else
            {
              foreach (IProfileManager.Profile profile in EditorManager.ProfileManager.GetProfiles())
              {
            if (scene.CurrentExportProfile.SelectedAssetProfiles.IsProfileSet(profile.ToString()))
            {
              assetProfiles.Add(profile.ToString());
            }
              }
            }
              }

              EditorManager.EngineManager.CheckLightGridDataExists();

              EditorManager.GUI.UIUpdateLock++; //lock the UI, so there will be no updates during export
              scene.ExportScene(null, assetProfiles);
              EditorManager.GUI.UIUpdateLock--; //unlock the UI again
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Exports all found scene files
        /// </summary>
        private void DoExport()
        {
            // Enter the testing mode (since we don't want any user dialogs etc.)
            TestManager.IsRunning = true;

            while (_scenesToProcess.Count > 0 && _state != State_e.Cancelling)
            {
                // Get one scene from the queue
                _currentScene = _scenesToProcess[0];
                _scenesToProcess.RemoveAt(0);

                textBoxLog.Text += string.Format("Processing {0}: ", _currentScene);

                // Load the scene
                TestManager.Helpers.OpenSceneFromFile(_currentScene);
                TestManager.Helpers.ProcessEvents();

                // Force the folder type to version controlled, since we didn't have a chance to when loading the scene
                EditorManager.Project.FolderType = IProject.FolderType_e.RCS;
                EditorManager.Project.UpdateRCSStatus(true);
                TestManager.Helpers.ProcessEvents();

                // Actual export unless cancel has been clicked while loading
                if (_state != State_e.Cancelling)
                {
                    // Check if the exported scene file name is correct
                    string exportedSceneFile = Path.GetFileName(EditorManager.Scene.CurrentExportProfile.ExportPath);
                    string defaultExportName = Path.GetFileName(Path.ChangeExtension(_currentScene, CSharpFramework.Scene.SceneExportProfile.FILE_EXTENSION_EXPORT));

                    bool showExportDialog = false;

                    if (exportedSceneFile != defaultExportName)
                    {
                        textBoxLog.Text += string.Format("\r\nScene name mismatch: {0} instead of {1}: ", exportedSceneFile, defaultExportName);

                        if (radioMismatch_Dialog.Checked)
                        {
                            showExportDialog = true;
                        }
                        else if (radioMismatch_Revert.Checked)
                        {
                            string subDir = Path.GetDirectoryName(EditorManager.Scene.CurrentExportProfile.ExportPath);
                            EditorManager.Scene.CurrentExportProfile.ExportPath = Path.Combine(subDir, defaultExportName);
                            textBoxLog.Text += string.Format("Reverted.\r\n");
                        }
                        else
                        {
                            textBoxLog.Text += string.Format("Ignoring.\r\n");
                        }
                    }

                    EditorScene scene = EditorManager.Scene as EditorScene;

                    if (showExportDialog)
                    {
                        // Open export dialog
                        using (ExportDialog dlg = new ExportDialog())
                        {
                            scene.CurrentExportProfile.ExportedLayersFromScene(); // retrieve current status
                            dlg.Settings = scene.CurrentExportProfile;            // clones the settings
                            dlg.AutoSaveExportProfile = scene.Settings.AutoSaveExportProfile;

                            // Show dialog
                            if (dlg.ShowDialog() != DialogResult.OK)
                            {
                                continue;
                            }

                            // Get back settings
                            scene.CurrentExportProfile = dlg.Settings;

                            scene.Settings.ExportProfileName     = scene.CurrentExportProfile.ProfileName;
                            scene.Settings.AutoSaveExportProfile = dlg.AutoSaveExportProfile;
                        }
                    }

                    // Always export all zones
                    foreach (Zone zone in EditorManager.Scene.Zones)
                    {
                        zone.Export = true;
                    }

                    if (checkBoxMoveToCamera.Checked)
                    {
                        // TODO: Move camera to a sensible position
                    }

                    EditorManager.Progress.Percentage = 0;

                    // Export all profiles
                    List <string> assetProfiles = new List <string>();
                    foreach (IProfileManager.Profile profile in EditorManager.ProfileManager.GetProfiles())
                    {
                        assetProfiles.Add(profile.ToString());
                    }

                    // Export the scene
                    EditorManager.GUI.UIUpdateLock++;
                    EditorManager.Scene.ExportScene(null, assetProfiles);
                    EditorManager.GUI.UIUpdateLock--;

                    if (showExportDialog)
                    {
                        textBoxLog.Text += string.Format("Manually set to {0}.\r\n", Path.GetFileName(EditorManager.Scene.CurrentExportProfile.ExportPath));
                    }
                    textBoxLog.Text += string.Format("Export done. ");
                    TestManager.Helpers.ProcessEvents();

                    // Resave scene
                    if (checkBoxResaveScene.Checked)
                    {
                        EditorManager.Scene.Save();
                        textBoxLog.Text += string.Format("Scene file resaved. ");
                        TestManager.Helpers.ProcessEvents();
                    }

                    textBoxLog.Text += string.Format("\r\n");
                }

                // Close the project
                TestManager.Helpers.CloseActiveProject();
                TestManager.Helpers.ProcessEvents();

                _scenesProcessed++;
            }

            if (State == State_e.Cancelling)
            {
                textBoxLog.Text += string.Format("\r\nAborted.\r\n");
            }

            // Reset state
            _currentScene = null;
            State         = State_e.None;
            EditorManager.Progress.StatusString          = "";
            EditorManager.Progress.Percentage            = 0;
            EditorManager.Progress.ProgressDialogEnabled = true;

            // Go back to normal operation mode
            TestManager.IsRunning = false;
        }