protected override void LoadContent() { settings.LevelCount = levelCount; settings.LeafNodeSize = leafNodeSize; settings.PatchResolution = patchResolution; settings.MapScale = mapScale; settings.HeightScale = heightScale; settings.HeightMapWidth = heightMapWidth; settings.HeightMapHeight = heightMapHeight; var visibleRanges = new CDLODDefaultVisibleRanges(settings); visibleRanges.FinestNodeSize = finestNodeSize; visibleRanges.DetailBalance = detailBalance; visibleRanges.Initialize(); partitionContext = new DemoPartitionContext( GraphicsDevice, Content, settings, visibleRanges); partitionContext.TerrainRenderer.FogEnabled = true; partitionContext.TerrainRenderer.FogStart = fogStart; partitionContext.TerrainRenderer.FogEnd = fogEnd; partitionContext.TerrainRenderer.FogColor = fogColor; partitionContext.MDHurst = mdHurst; partitionFactory = new DemoPartitionFactory(partitionContext); var terrainScale = settings.TerrainScale; partitionManager = new PartitionManager(partitionFactory.Create, loadThreadCount, initialPartitionPoolCapacity, maxPartitionPoolCapacity); partitionManager.PartitionWidth = terrainScale.X; partitionManager.PartitionHeight = terrainScale.Z; partitionManager.ActivationRange = terrainScale.X * 3.0f; partitionManager.DeactivationRange = partitionManager.ActivationRange * 1.5f; partitionManager.EyePosition = view.Position; #region Debug spriteBatch = new SpriteBatch(GraphicsDevice); font = Content.Load<SpriteFont>("Fonts/Debug"); fillTexture = Texture2DHelper.CreateFillTexture(GraphicsDevice); helpMessageFontSize = font.MeasureString(helpMessage); BuildInformationMessage(); informationTextFontSize = font.MeasureString(stringBuilder); #endregion }
protected override void LoadContent() { settings.LevelCount = levelCount; settings.LeafNodeSize = leafNodeSize; settings.PatchResolution = patchResolution; settings.MapScale = mapScale; settings.HeightScale = heightScale; settings.HeightMapWidth = heightMapWidth; settings.HeightMapHeight = heightMapHeight; var visibleRanges = new CDLODDefaultVisibleRanges(settings); visibleRanges.FinestNodeSize = finestNodeSize; visibleRanges.DetailBalance = detailBalance; visibleRanges.Initialize(); #region Noise and fractal test classicPerlin.Seed = noiseSeed; classicPerlin.Reseed(); perlin.Seed = noiseSeed; perlin.Reseed(); simplex.Seed = noiseSeed; simplex.Reseed(); //var noise = perlinNoise; var noise = perlin; //var noise = simplexNoise; //var noise = voronoi; perlinFractal.Source = noise.Sample; sumFractal.Source = noise.Sample; multifractal.Source = noise.Sample; heterofractal.Source = noise.Sample; hybridMultifractal.Source = noise.Sample; ridgedMultifractal.Source = noise.Sample; sinFractal.Source = noise.Sample; billow.Source = noise.Sample; #endregion #region Vorononi test voronoi.Seed = noiseSeed; voronoi.Frequency = 1; voronoi.VoronoiType = VoronoiType.First; voronoi.Metrics = Metrics.Squared; //voronoi.DistanceEnabled = true; #endregion #region Noise combination test var testBaseNoise = perlin; mountainTerrain.Source = testBaseNoise.Sample; baseFlatTerrain.Source = testBaseNoise.Sample; baseFlatTerrain.Frequency = 2.0f; flatTerrain.Source = baseFlatTerrain.Sample; flatTerrain.Scale = 0.525f; flatTerrain.Bias = -0.75f; terrainType.Source = testBaseNoise.Sample; terrainSelector.Controller = terrainType.Sample; terrainSelector.Source0 = (x, y, z) => { return mountainTerrain.Sample(x, y, z) * 1.25f - 1; }; terrainSelector.Source1 = flatTerrain.Sample; terrainSelector.LowerBound = 0; terrainSelector.UpperBound = 1000; terrainSelector.EdgeFalloff = 0.125f; perturbTerrain.Source = terrainSelector.Sample; perturbTerrain.Frequency = 4; perturbTerrain.Power = 0.125f; finalTerrain.Source = perturbTerrain.Sample; finalTerrain.Bias = 0.8f; #endregion #region Recording recNoise.Seed = noiseSeed; recBaseTerrain.Source = recNoise.Sample; recBaseTerrain.OctaveCount = 7; recFinalTerrain.Source = recBaseTerrain.Sample; recFinalTerrain.Scale = 2.5f; #endregion SampleSourceDelegate finalNoiseSource = recFinalTerrain.Sample; partitionContext = new DemoPartitionContext( GraphicsDevice, Content, settings, visibleRanges, finalNoiseSource, noiseSampleX, noiseSampleY, noiseSampleWidth, noiseSampleHeight); partitionContext.TerrainRenderer.FogEnabled = true; partitionContext.TerrainRenderer.FogStart = fogStart; partitionContext.TerrainRenderer.FogEnd = fogEnd; partitionContext.TerrainRenderer.FogColor = fogColor; partitionFactory = new DemoPartitionFactory(partitionContext); var terrainScale = settings.TerrainScale; partitionManager = new PartitionManager(partitionFactory.Create, loadThreadCount, initialPartitionPoolCapacity, maxPartitionPoolCapacity); partitionManager.PartitionWidth = terrainScale.X; partitionManager.PartitionHeight = terrainScale.Z; partitionManager.ActivationRange = terrainScale.X * 4.0f; //partitionManager.ActivationRange = terrainScale.X * 2.0f; partitionManager.DeactivationRange = partitionManager.ActivationRange * 1.5f; partitionManager.EyePosition = view.Position; #region Debug spriteBatch = new SpriteBatch(GraphicsDevice); font = Content.Load<SpriteFont>("Fonts/Debug"); fillTexture = Texture2DHelper.CreateFillTexture(GraphicsDevice); helpMessageFontSize = font.MeasureString(helpMessage); BuildInformationMessage(); informationTextFontSize = font.MeasureString(stringBuilder); #endregion }