Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        private GUILayer.TerrainConfig BuildEngineConfig(TerrainConfig.Config cfg)
        {
            var result = new GUILayer.TerrainConfig(
                cfg.CellsDirectory,
                cfg.NodeDimensions, cfg.CellTreeDepth, cfg.Overlap,
                cfg.Spacing, (float)(cfg.SunPathAngle * Math.PI / 180.0f),
                cfg.HasEncodedGradientFlags);

            result.CellCount = new GUILayer.VectorUInt2(CellCount[0], CellCount[1]);

            var layers = CoverageLayers;

            foreach (var l in layers)
            {
                if (!l.Enable)
                {
                    continue;
                }

                // we should avoid adding multiple layers with the same id
                var  id          = l.LayerId;
                bool alreadyHere = false;
                for (uint c = 0; c < result.CoverageLayerCount; ++c)
                {
                    if (result.GetCoverageLayer(c).Id == id)
                    {
                        alreadyHere = true;
                        break;
                    }
                }

                if (alreadyHere)
                {
                    break;
                }

                var d = GUILayer.EditorInterfaceUtils.DefaultCoverageLayer(
                    result, cfg.UberSurfaceDirectory, id);
                d.NodeDims = new GUILayer.VectorUInt2(
                    (uint)(l.Resolution * cfg.NodeDimensions),
                    (uint)(l.Resolution * cfg.NodeDimensions));
                if (l.Format != 0)
                {
                    d.FormatCat        = l.Format;
                    d.FormatArrayCount = 1;
                }
                d.ShaderNormalizationMode = l.ShaderNormalizationMode;
                result.Add(d);
            }

            return(result);
        }
Exemplo n.º 3
0
 internal void CommitDialogConfig(TerrainConfig.Config cfg)
 {
     NodeDimensions          = cfg.NodeDimensions;
     Overlap                 = cfg.Overlap;
     CellTreeDepth           = cfg.CellTreeDepth;
     Spacing                 = cfg.Spacing;
     UberSurfaceDirectory    = cfg.UberSurfaceDirectory;
     CellsDirectory          = cfg.CellsDirectory;
     HasEncodedGradientFlags = cfg.HasEncodedGradientFlags;
     SunPathAngle            = cfg.SunPathAngle;
     GradFlagSlopeThreshold0 = cfg.SlopeThreshold0;
     GradFlagSlopeThreshold1 = cfg.SlopeThreshold1;
     GradFlagSlopeThreshold2 = cfg.SlopeThreshold2;
 }
Exemplo n.º 4
0
        internal TerrainConfig.Config BuildDialogConfig()
        {
            var cfg = new TerrainConfig.Config();

            cfg.NodeDimensions          = NodeDimensions;
            cfg.Overlap                 = Overlap;
            cfg.Spacing                 = Spacing;
            cfg.CellTreeDepth           = CellTreeDepth;
            cfg.UberSurfaceDirectory    = UberSurfaceDirectory;
            cfg.CellsDirectory          = CellsDirectory;
            cfg.HasEncodedGradientFlags = HasEncodedGradientFlags;
            cfg.SunPathAngle            = SunPathAngle;
            cfg.SlopeThreshold0         = GradFlagSlopeThreshold0;
            cfg.SlopeThreshold1         = GradFlagSlopeThreshold1;
            cfg.SlopeThreshold2         = GradFlagSlopeThreshold2;
            return(cfg);
        }