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(); }
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); } } }
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"); } } }
private void BuildLayerList(XLETerrainGob terrain) { _coverageLayer.DisplayMember = "Value"; _coverageLayer.Items.Clear(); _coverageLayer.Items.Add(new KeyValuePair <uint, string>(1, "Heights")); foreach (var l in terrain.CoverageLayers) { _coverageLayer.Items.Add(new KeyValuePair <uint, string>(l.LayerId, l.LayerName)); } SyncActiveLayer(); }
internal bool DoModalConfigure(XLETerrainGob terrain) { // open the configuration dialog using (var dlg = new TerrainCoverageConfig()) { dlg.Value = BuildDialogConfig(terrain); var result = dlg.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { return(Reconfigure(dlg.Value, terrain)); } } return(false); }
internal TerrainCoverageConfig.Config BuildDialogConfig(XLETerrainGob terrain) { var cfg = new TerrainCoverageConfig.Config(); cfg.NodeDimensions = terrain.NodeDimensions; cfg.CellTreeDepth = terrain.CellTreeDepth; cfg.Resolution = Resolution; cfg.SourceFile = SourceFile; cfg.Enable = Enable; cfg.Id = LayerId; cfg.ShaderNormalizationMode = ShaderNormalizationMode; return(cfg); }
public static DomNode CreateWithConfigure(XLETerrainGob terrain, uint id) { var result = new DomNode(Schema.terrainCoverageLayer.Type); var adapter = result.As <XLETerrainCoverage>(); if (adapter != null) { adapter.LayerId = id; if (adapter.DoModalConfigure(terrain)) { return(result); } } return(null); }
private void OnActiveContextChanged(object obj, EventArgs args) { IContextRegistry registry = obj as IContextRegistry; if (registry != null) { var gameExt = registry.GetActiveContext <Game.GameExtensions>(); if (gameExt != null) { Context = gameExt.TerrainManipulatorContext; Terrain = gameExt.Terrain; _attachedSceneManager = new WeakReference(gameExt.SceneManager); } } }
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); }