コード例 #1
0
        internal void DoExportHeights()
        {
            var fileDlg = new SaveFileDialog();

            fileDlg.Filter = "Tiff files|*.tiff;*.tif";
            if (fileDlg.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    Unload();
                    using (var progress = new ControlsLibrary.ProgressDialog.ProgressInterface())
                    {
                        GUILayer.EditorInterfaceUtils.ExecuteTerrainExport(
                            fileDlg.FileName,
                            BuildEngineConfig(),
                            UberSurfaceDirectory.LocalPath,
                            1, progress);
                    }
                    Reload();
                }
                catch (Exception e)
                {
                    Show(e, "Terrain export to tiff");
                }
            }
        }
コード例 #2
0
ファイル: XLETerrainGob.cs プロジェクト: coreafive/XLE
        internal void DoExport(XLETerrainGob terrain)
        {
            if (terrain == null)
            {
                return;
            }

            var fileDlg = new SaveFileDialog();

            fileDlg.Filter = "Tiff files|*.tiff;*.tif";
            if (fileDlg.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    terrain.Unload();
                    using (var progress = new ControlsLibrary.ProgressDialog.ProgressInterface())
                    {
                        GUILayer.EditorInterfaceUtils.ExecuteTerrainExport(
                            fileDlg.FileName,
                            terrain.BuildEngineConfig(),
                            terrain.UberSurfaceDirectory,
                            LayerId, progress);
                    }
                    terrain.Reload();
                }
                catch
                {
                    MessageBox.Show(
                        "Export operation failed", "Terrain coverage export",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
            }
        }
コード例 #3
0
ファイル: XLETerrainGob.cs プロジェクト: coreafive/XLE
 void DoFlushToDisk()
 {
     using (var progress = new ControlsLibrary.ProgressDialog.ProgressInterface())
     {
         GUILayer.EditorInterfaceUtils.FlushTerrainToDisk(this.GetSceneManager(), progress);
     }
 }
コード例 #4
0
        void DoGenerateShadows()
        {
            Unload();

            try
            {
                using (var progress = new ControlsLibrary.ProgressDialog.ProgressInterface())
                {
                    GUILayer.EditorInterfaceUtils.GenerateShadowsSurface(
                        BuildEngineConfig(), UberSurfaceDirectory.LocalPath,
                        progress);
                }

                using (var progress = new ControlsLibrary.ProgressDialog.ProgressInterface())
                {
                    GUILayer.EditorInterfaceUtils.GenerateAmbientOcclusionSurface(
                        BuildEngineConfig(), UberSurfaceDirectory.LocalPath,
                        progress);
                }
            }
            catch (Exception e)
            {
                Show(e, "shadow generation operation");
            }

            Reload();
        }
コード例 #5
0
        void DoRebuildCellFiles(XLETerrainGob terrain)
        {
            if (terrain == null)
            {
                return;
            }

            terrain.Unload();

            try
            {
                using (var progress = new ControlsLibrary.ProgressDialog.ProgressInterface())
                {
                    GUILayer.EditorInterfaceUtils.GenerateCellFiles(
                        terrain.BuildEngineConfig(), terrain.UberSurfaceDirectory.LocalPath, true,
                        LayerId, progress);
                }
            }
            catch (Exception e)
            {
                XLETerrainGob.Show(e, "Rebuilding cell files");
            }

            terrain.Reload();
        }
コード例 #6
0
        internal void DoExport(XLETerrainGob terrain)
        {
            if (terrain == null)
            {
                return;
            }

            var fileDlg = new SaveFileDialog();

            fileDlg.Filter = "Tiff files|*.tiff;*.tif";
            if (fileDlg.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    terrain.Unload();
                    using (var progress = new ControlsLibrary.ProgressDialog.ProgressInterface())
                    {
                        GUILayer.EditorInterfaceUtils.ExecuteTerrainExport(
                            fileDlg.FileName,
                            terrain.BuildEngineConfig(),
                            terrain.UberSurfaceDirectory.LocalPath,
                            LayerId, progress);
                    }
                    terrain.Reload();
                }
                catch (Exception e)
                {
                    XLETerrainGob.Show(e, "Terrain export to tiff");
                }
            }
        }
コード例 #7
0
        private void _saveButton_Click(object sender, EventArgs e)
        {
            if (_attachedSceneManager == null || _attached == null)
            {
                return;
            }
            var sceneManager = _attachedSceneManager.Target as GUILayer.EditorSceneManager;

            if (sceneManager == null)
            {
                return;
            }

            try
            {
                using (var progress = new ControlsLibrary.ProgressDialog.ProgressInterface())
                {
                    sceneManager.SaveTerrainLock(_attached.ActiveLayer, progress);
                }
            }
            catch (Exception ex)
            {
                ControlsLibrary.BasicControls.ExceptionReport.Show(ex, "Saving terrain lock");
            }
        }
コード例 #8
0
        public static bool ConfirmClose(IDocument document, IFileDialogService fileDialogService)
        {
            var game = document.As <Game.GameExtensions>();

            if (game == null)
            {
                return(true);
            }
            var terrain      = game.Terrain;
            var sceneManager = game.SceneManager;

            if (terrain == null || sceneManager == null)
            {
                return(true);
            }

            var  layerIds       = terrain.GetAllLayerIds();
            bool hasActiveLocks = false;

            foreach (var l in layerIds)
            {
                hasActiveLocks |= sceneManager.HasTerrainLock(l);
            }

            if (hasActiveLocks)
            {
                string message = "You still have active terrain locks. These are unsaved areas of terrain."
                                 + System.Environment.NewLine + "Do you want to save all active terrain locks?";
                FileDialogResult result = fileDialogService.ConfirmFileClose(message);
                if (result == FileDialogResult.Yes)
                {
                    foreach (var l in layerIds)
                    {
                        try
                        {
                            using (var progress = new ControlsLibrary.ProgressDialog.ProgressInterface())
                            {
                                sceneManager.SaveTerrainLock(l, progress);
                            }
                        }
                        catch (Exception ex)
                        {
                            ControlsLibrary.BasicControls.ExceptionReport.Show(ex, "Saving terrain lock");
                        }
                    }
                }
                else if (result == FileDialogResult.Cancel)
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #9
0
ファイル: XLETerrainGob.cs プロジェクト: coreafive/XLE
        internal void Reconfigure(TerrainConfig.Config cfg)
        {
            cfg.NodeDimensions = ClampNodeDimensions(cfg.NodeDimensions);
            cfg.CellTreeDepth  = ClampCellTreeDepth(cfg.CellTreeDepth);

            Unload();

            try
            {
                var newCellCount = new GUILayer.VectorUInt2(0, 0);
                using (var progress = new ControlsLibrary.ProgressDialog.ProgressInterface())
                {
                    // if there is a source DEM file specified then we should
                    // attempt to build the starter uber surface.
                    if (cfg.Import == TerrainConfig.Config.ImportType.DEMFile &&
                        cfg.SourceDEMFile != null && cfg.SourceDEMFile.Length > 0)
                    {
                        cfg.ImportOp.ExecuteForHeights(cfg.UberSurfaceDirectory, progress);
                    }
                    else if (cfg.Import == TerrainConfig.Config.ImportType.NewBlankTerrain &&
                             cfg.NewCellCountX != 0 && cfg.NewCellCountY != 0)
                    {
                        GUILayer.EditorInterfaceUtils.GenerateBlankUberSurface(
                            cfg.UberSurfaceDirectory, cfg.NewCellCountX, cfg.NewCellCountY,
                            cfg.NodeDimensions, cfg.CellTreeDepth,
                            progress);
                    }

                    var engineCfg = BuildEngineConfig(cfg);
                    engineCfg.InitCellCountFromUberSurface(cfg.UberSurfaceDirectory);
                    newCellCount = engineCfg.CellCount;

                    // fill in the cells directory with starter cells (if they don't already exist)
                    // (and build empty uber surface files for any that are missing)
                    GUILayer.EditorInterfaceUtils.GenerateMissingUberSurfaceFiles(
                        engineCfg, cfg.UberSurfaceDirectory, progress);
                    GUILayer.EditorInterfaceUtils.GenerateCellFiles(
                        engineCfg, cfg.UberSurfaceDirectory, false,
                        cfg.SlopeThreshold0, cfg.SlopeThreshold1, cfg.SlopeThreshold2,
                        progress);
                }

                // if the above completed without throwing an exception, we can commit the values
                CommitDialogConfig(cfg);
                CellCount = new uint[2] {
                    newCellCount.X, newCellCount.Y
                };
            }
            catch { }

            Reload();
        }
コード例 #10
0
ファイル: XLETerrainGob.cs プロジェクト: coreafive/XLE
        void DoRebuildCellFiles()
        {
            Unload();

            try
            {
                using (var progress = new ControlsLibrary.ProgressDialog.ProgressInterface())
                {
                    GUILayer.EditorInterfaceUtils.GenerateCellFiles(
                        BuildEngineConfig(), UberSurfaceDirectory, true,
                        GradFlagSlopeThreshold0, GradFlagSlopeThreshold1, GradFlagSlopeThreshold2, progress);
                }
            }
            catch {}

            Reload();
        }
コード例 #11
0
        internal bool Reconfigure(TerrainCoverageConfig.Config cfg, XLETerrainGob terrain)
        {
            if (terrain != null)
            {
                terrain.Unload();   // (have to unload to write to ubersurface)
            }
            try
            {
                // If an import or create operation was requested, we
                // must perform those now. Note that this might require
                // some format changes.
                if (cfg.Import == TerrainCoverageConfig.Config.ImportType.DEMFile &&
                    cfg.SourceFile != null && cfg.SourceFile.Length > 0 &&
                    terrain != null)
                {
                    using (var progress = new ControlsLibrary.ProgressDialog.ProgressInterface())
                    {
                        cfg.ImportOp.Execute(
                            terrain.UberSurfaceDirectory.LocalPath,
                            cfg.Id, cfg.ImportOp.ImportCoverageFormat,
                            progress);
                    }
                    Format = cfg.ImportOp.ImportCoverageFormat;
                }
                else if (cfg.Import == TerrainCoverageConfig.Config.ImportType.NewBlankTerrain)
                {
                    // todo -- create new blank coverage with the given format
                }
            }
            catch (Exception e)
            {
                XLETerrainGob.Show(e, "Terrain import operation");
                return(false);
            }

            CommitDialogConfig(cfg);

            if (terrain != null)
            {
                terrain.Reconfigure();
            }
            return(true);
        }
コード例 #12
0
ファイル: XLETerrainGob.cs プロジェクト: coreafive/XLE
        void DoGenerateShadows()
        {
            Unload();

            try
            {
                using (var progress = new ControlsLibrary.ProgressDialog.ProgressInterface())
                {
                    GUILayer.EditorInterfaceUtils.GenerateShadowsSurface(
                        BuildEngineConfig(), UberSurfaceDirectory,
                        progress);
                }

                using (var progress = new ControlsLibrary.ProgressDialog.ProgressInterface())
                {
                    GUILayer.EditorInterfaceUtils.GenerateAmbientOcclusionSurface(
                        BuildEngineConfig(), UberSurfaceDirectory,
                        progress);
                }
            }
            catch {}

            Reload();
        }