public void CreateTestImageRenderer() { testTextureImage = new Image(); testRenderer = new ImageRenderer(); testRenderer.ClearGradient(); testRenderer.AddGradientPoint(-1.00, new Color(189, 94, 4, 255)); testRenderer.AddGradientPoint(0.50, new Color(144, 48, 6, 255)); testRenderer.AddGradientPoint(1.00, new Color(60, 10, 8, 255)); testRenderer.EnableLight = false; }
private static void BuildTerrainRenderer(ImageRenderer renderer) { renderer.ClearGradient(); renderer.AddGradientPoint(0, new Color(0, 0, 128, 255)); renderer.AddGradientPoint(0.4, new Color(32, 64, 128, 255)); renderer.AddGradientPoint(0.46, new Color(64, 96, 192, 255)); renderer.AddGradientPoint(0.48, new Color(192, 192, 128, 255)); renderer.AddGradientPoint(0.5, new Color(0, 192, 0, 255)); renderer.AddGradientPoint(0.625, new Color(192, 192, 0, 255)); renderer.AddGradientPoint(0.75, new Color(160, 96, 64, 255)); renderer.AddGradientPoint(0.875, new Color(128, 255, 255, 255)); renderer.AddGradientPoint(1.00, new Color(255, 255, 255, 255)); }
public GraniteTextureTest() { module = new Turbulence { Seed = 2, Frequency = 4, Power = 1.0 / 8.0, Roughness = 6, Source0 = new Add { Source0 = new Billow { Seed = 1, Frequency = 8, Persistence = 0.625, Lacunarity = 2.18359375, OctaveCount = 6, }, Source1 = new ScaleBias { Scale = -0.5, Bias = 0, Source0 = new Cell { Seed = 1, Frequency = 16, EnableDistance = true, } } } }; noiseMap = new NoiseMap(); textureImage = new Image(); renderer = new ImageRenderer { EnableLight = true, LightAzimuth = 135, LightElevation = 60, LightContrast = 2, LightColor = new Color(255, 255, 255, 0), }; renderer.AddGradientPoint(-1.0000, new Color(0, 0, 0, 255)); renderer.AddGradientPoint(-0.9375, new Color(0, 0, 0, 255)); renderer.AddGradientPoint(-0.8750, new Color(216, 216, 242, 255)); renderer.AddGradientPoint(0.0000, new Color(191, 191, 191, 255)); renderer.AddGradientPoint(0.5000, new Color(210, 116, 125, 255)); renderer.AddGradientPoint(0.7500, new Color(210, 113, 98, 255)); renderer.AddGradientPoint(1.0000, new Color(255, 176, 192, 255)); }
public void CreateTestImageRenderer() { testTextureImage = new Image(); testRenderer = new ImageRenderer(); testRenderer.ClearGradient(); testRenderer.AddGradientPoint(-1.0000, new Color(0, 0, 0, 255)); testRenderer.AddGradientPoint(-0.9375, new Color(0, 0, 0, 255)); testRenderer.AddGradientPoint(-0.8750, new Color(216, 216, 242, 255)); testRenderer.AddGradientPoint(0.0000, new Color(191, 191, 191, 255)); testRenderer.AddGradientPoint(0.5000, new Color(210, 116, 125, 255)); testRenderer.AddGradientPoint(0.7500, new Color(210, 113, 98, 255)); testRenderer.AddGradientPoint(1.0000, new Color(255, 176, 192, 255)); testRenderer.EnableLight = true; testRenderer.LightAzimuth = 135; testRenderer.LightElevation = 60; testRenderer.LightContrast = 2; testRenderer.LightColor = new Color(255, 255, 255, 0); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { nbEnemy = 0; gameover = false; world = new World(new Vector2(0, 0)); debugView = new DebugView(); debugView.LoadContent(GraphicsDevice, Content); inputHelper = new InputHelper(resolutionIndependence); inputHelper.ShowCursor = true; shadowsRendering = new ShadowsRenderer(); listGraphicObj = new List <GraphicObj>(); inputHelper.LoadContent(); font = Content.Load <SpriteFont>("pixelSpriteFont"); Texture2D textureCarre = Content.Load <Texture2D>("carre"); Texture2D textureCarre2 = Content.Load <Texture2D>("carre2"); Texture2D textureTotem = Content.Load <Texture2D>("Totem"); bouleRouge = Content.Load <Texture2D>("blood"); blood1 = Content.Load <Texture2D>("blood1"); blood2 = Content.Load <Texture2D>("blood2"); blood3 = Content.Load <Texture2D>("blood3"); debugNodeBusy = Content.Load <Texture2D>("debugPathFinderNode"); debugNodeFree = Content.Load <Texture2D>("debugPathFinderNode2"); particuleSystem = new ParticuleSystem(); //pathFinder = new PathFinder(2); pFinder = new PathFinder(); pFinder.BuildtNavMeshes(6, 10); mapFactory = new MapFactory(); mapFactory.newMap(listGraphicObj, seedIndexToLoad); seedIndexToLoad = -1; savedSeeds = mapFactory.mGen.savedSeeds; var treeplanter = new TreePlanter( mapFactory.minX * pixelToMeter, mapFactory.maxX * pixelToMeter, mapFactory.minY * pixelToMeter, mapFactory.maxY * pixelToMeter, mapFactory.mGen.rand ); frameRateCounter = new FrameRateCounter(font); particuleSystem.addParticuleSpawner(new SnowSpawner(new Vector2(100, 100), 0, player, new Vector2(475, -475))); snowMarkSpawner = new SnowMarkSpawner(new Vector2(0, 0), 0, player, new Vector2(0, 0)); var noiseSource = new Perlin { Seed = mapFactory.mGen.rand.Next() }; var noiseMap = new NoiseMap(); var noiseMapBuilder = new PlaneNoiseMapBuilder { DestNoiseMap = noiseMap, SourceModule = noiseSource, EnableSeamless = true }; //noiseMapBuilder.SetDestSize(300, 300); //noiseMapBuilder.SetBounds(-4.5, 4.5, -4.5, 4.5); noiseMapBuilder.SetDestSize(256, 256); noiseMapBuilder.SetBounds(2, 6, 1, 5); noiseMapBuilder.Build(); textureImageNoise = new SharpNoise.Utilities.Imaging.Image(); imageRendererNoise = new ImageRenderer { SourceNoiseMap = noiseMap, DestinationImage = textureImageNoise, EnableLight = true, LightContrast = 1.0, LightBrightness = 2.3, EnableWrap = true }; imageRendererNoise.ClearGradient(); imageRendererNoise.AddGradientPoint(0.0000, new SharpNoise.Utilities.Imaging.Color(170, 180, 240, 255)); imageRendererNoise.AddGradientPoint(1.000, new SharpNoise.Utilities.Imaging.Color(170, 180, 240, 255)); imageRendererNoise.Render(); renderedmap = createTexture(imageRendererNoise); minNoiseX = (int)mapFactory.minX - textureImageNoise.Width * 2; maxNoiseX = (int)mapFactory.maxX + textureImageNoise.Width * 2; minNoiseY = (int)mapFactory.minY - textureImageNoise.Height * 2; maxNoiseY = (int)mapFactory.maxY + textureImageNoise.Height * 2; menu = new Menu(font); }
public async void BiomesAsync() { await Task.Run(() => { var map = new NoiseMap(); var builder = new PlaneNoiseMapBuilder() { DestNoiseMap = map, SourceModule = noiseGen.FinalBiomes }; var image = new Image(); var biomesRenderer = new ImageRenderer() { SourceNoiseMap = map, DestinationImage = image }; biomesRenderer.AddGradientPoint((int)Biomes.TheVoid, new Color(0, 0, 0, 255)); biomesRenderer.AddGradientPoint((int)Biomes.Plains, new Color(86, 125, 70, 255)); biomesRenderer.AddGradientPoint((int)Biomes.SunflowerPlains, new Color(255, 196, 63, 255)); biomesRenderer.AddGradientPoint((int)Biomes.SnowyPlains, new Color(200, 200, 255, 255)); biomesRenderer.AddGradientPoint((int)Biomes.IceSpikes, new Color(100, 100, 255, 255)); biomesRenderer.AddGradientPoint((int)Biomes.Desert, new Color(128, 128, 0, 255)); biomesRenderer.AddGradientPoint((int)Biomes.Swamp, new Color(0, 128, 0, 255)); biomesRenderer.AddGradientPoint((int)Biomes.Forest, new Color(32, 255, 32, 255)); biomesRenderer.AddGradientPoint((int)Biomes.FlowerForest, new Color(96, 255, 0, 255)); biomesRenderer.AddGradientPoint((int)Biomes.BirchForest, new Color(182, 255, 182, 255)); biomesRenderer.AddGradientPoint((int)Biomes.DarkForest, new Color(0, 100, 0, 255)); biomesRenderer.AddGradientPoint((int)Biomes.OldGrowthBirchForest, new Color(150, 255, 150, 255)); biomesRenderer.AddGradientPoint((int)Biomes.OldGrowthPineTaiga, new Color(1, 121, 111, 255)); biomesRenderer.AddGradientPoint((int)Biomes.OldGrowthSpruceTaiga, new Color(105, 193, 126, 255)); biomesRenderer.AddGradientPoint((int)Biomes.Taiga, new Color(118, 128, 120, 255)); biomesRenderer.AddGradientPoint((int)Biomes.SnowyTaiga, new Color(218, 228, 220, 255)); biomesRenderer.AddGradientPoint((int)Biomes.Savanna, new Color(209, 163, 110, 255)); biomesRenderer.AddGradientPoint((int)Biomes.SavannaPlateau, new Color(224, 190, 146, 255)); biomesRenderer.AddGradientPoint((int)Biomes.WindsweptHills, new Color(11, 102, 35, 255)); biomesRenderer.AddGradientPoint((int)Biomes.WindsweptGravellyHills, new Color(128, 164, 128, 255)); biomesRenderer.AddGradientPoint((int)Biomes.WindsweptForest, new Color(11, 102, 35, 196)); biomesRenderer.AddGradientPoint((int)Biomes.WindsweptSavanna, new Color(209, 163, 110, 196)); biomesRenderer.AddGradientPoint((int)Biomes.Jungle, new Color(41, 171, 135, 255)); biomesRenderer.AddGradientPoint((int)Biomes.SparseJungle, new Color(41, 171, 135, 196)); biomesRenderer.AddGradientPoint((int)Biomes.BambooJungle, new Color(221, 202, 133, 255)); biomesRenderer.AddGradientPoint((int)Biomes.Badlands, new Color(167, 161, 143, 255)); biomesRenderer.AddGradientPoint((int)Biomes.ErodedBadlands, new Color(167, 161, 143, 196)); biomesRenderer.AddGradientPoint((int)Biomes.WoodedBadlands, new Color(167, 224, 143, 255)); biomesRenderer.AddGradientPoint((int)Biomes.Meadow, new Color(48, 186, 143, 255)); biomesRenderer.AddGradientPoint((int)Biomes.Grove, new Color(120, 127, 86, 255)); biomesRenderer.AddGradientPoint((int)Biomes.SnowySlopes, new Color(144, 184, 212, 255)); biomesRenderer.AddGradientPoint((int)Biomes.FrozenPeaks, new Color(144, 184, 255, 255)); biomesRenderer.AddGradientPoint((int)Biomes.JaggedPeaks, new Color(128, 128, 128, 255)); biomesRenderer.AddGradientPoint((int)Biomes.StonyPeaks, new Color(128, 128, 128, 196)); biomesRenderer.AddGradientPoint((int)Biomes.River, new Color(38, 102, 145, 255)); biomesRenderer.AddGradientPoint((int)Biomes.FrozenRiver, new Color(186, 218, 232, 255)); biomesRenderer.AddGradientPoint((int)Biomes.Beach, new Color(248, 220, 172, 255)); biomesRenderer.AddGradientPoint((int)Biomes.SnowyBeach, new Color(248, 220, 255, 255)); biomesRenderer.AddGradientPoint((int)Biomes.StonyShore, new Color(170, 170, 170, 255)); biomesRenderer.AddGradientPoint((int)Biomes.WarmOcean, new Color(60, 181, 177, 255)); biomesRenderer.AddGradientPoint((int)Biomes.LukewarmOcean, new Color(40, 181, 177, 255)); biomesRenderer.AddGradientPoint((int)Biomes.DeepLukewarmOcean, new Color(40, 181, 177, 128)); biomesRenderer.AddGradientPoint((int)Biomes.Ocean, new Color(0, 105, 148, 255)); biomesRenderer.AddGradientPoint((int)Biomes.DeepOcean, new Color(0, 105, 148, 128)); biomesRenderer.AddGradientPoint((int)Biomes.ColdOcean, new Color(107, 197, 198, 255)); biomesRenderer.AddGradientPoint((int)Biomes.DeepColdOcean, new Color(107, 197, 198, 128)); biomesRenderer.AddGradientPoint((int)Biomes.FrozenOcean, new Color(163, 191, 203, 255)); biomesRenderer.AddGradientPoint((int)Biomes.DeepFrozenOcean, new Color(163, 191, 203, 128)); biomesRenderer.AddGradientPoint((int)Biomes.MushroomFields, new Color(119, 103, 84, 255)); builder.SetBounds(-400, 400, -300, 300); builder.SetDestSize(800, 600); builder.Build(); biomesRenderer.Render(); var bmp = biomesRenderer.DestinationImage.ToGdiBitmap(); bmp.Save("_biomes.bmp"); Assert.Equal(0, 0); }); }
public WoodTextureTest() { module = new Turbulence { Seed = 2, Frequency = 2, Power = 1.0 / 64.0, Roughness = 4, Source0 = new RotatePoint { XAngle = 84, Source0 = new TranslatePoint { ZTranslation = 1.48, Source0 = new Turbulence { Seed = 1, Frequency = 4, Power = 1.0 / 256.0, Roughness = 4, Source0 = new Add { Source0 = new Cylinders { Frequency = 16, }, Source1 = new ScaleBias { Scale = 0.25, Bias = 0.125, Source0 = new ScalePoint { YScale = 0.25, Source0 = new Perlin { Seed = 2135, Frequency = 48, Persistence = 0.5, Lacunarity = 2.20703125, OctaveCount = 3, } } } } } } } }; noiseMap = new NoiseMap(); textureImage = new Image(); renderer = new ImageRenderer { EnableLight = false, }; renderer.AddGradientPoint(-1.00, new Color(189, 94, 4, 255)); renderer.AddGradientPoint(0.50, new Color(144, 48, 6, 255)); renderer.AddGradientPoint(1.00, new Color(60, 10, 8, 255)); }
private async void startButton_Click(object sender, EventArgs e) { timeLabel.Text = string.Empty; var cts = new CancellationTokenSource(); var dialog = new ProgressDialog(); dialog.Owner = this; dialog.cancelButton.Click += (s, ea) => cts.Cancel(); dialog.Show(); var stopwatch = new Stopwatch(); stopwatch.Start(); var generatorModule = new PlanetGenerator(GeneratorSettings).CreatePlanetModule(); var planetBuilder = new SphereNoiseMapBuilder(); var planetElevationMap = new NoiseMap(); planetBuilder.SetBounds(GeneratorSettings.SouthCoord, GeneratorSettings.NorthCoord, GeneratorSettings.WestCoord, GeneratorSettings.EastCoord); planetBuilder.SetDestSize(GeneratorSettings.GridWidth, GeneratorSettings.GridHeight); planetBuilder.SourceModule = generatorModule; planetBuilder.DestNoiseMap = planetElevationMap; bool cancelled = false; try { await planetBuilder.BuildAsync(cts.Token); } catch (OperationCanceledException) { cancelled = true; } stopwatch.Stop(); dialog.Close(); if (cancelled) { return; } timeLabel.Text = String.Format("Planet generated in {0}", stopwatch.Elapsed.ToString()); var degExtent = GeneratorSettings.EastCoord - GeneratorSettings.WestCoord; var gridExtent = (double)GeneratorSettings.GridWidth; var metersPerDegree = (GeneratorSettings.PlanetCircumference / 360.0); var resInMeters = (degExtent / gridExtent) * metersPerDegree; var seaLevelInMeters = (((GeneratorSettings.SeaLevel + 1) / 2.0) * (GeneratorSettings.MaxElev - GeneratorSettings.MinElev)) + GeneratorSettings.MinElev; var planetImage = new Image(); var planetRenderer = new ImageRenderer(); planetRenderer.SourceNoiseMap = planetElevationMap; planetRenderer.DestinationImage = planetImage; planetRenderer.AddGradientPoint(-16384.0 + seaLevelInMeters, new Color(0, 0, 0, 255)); planetRenderer.AddGradientPoint(-256 + seaLevelInMeters, new Color(6, 58, 127, 255)); planetRenderer.AddGradientPoint(-1.0 + seaLevelInMeters, new Color(14, 112, 192, 255)); planetRenderer.AddGradientPoint(0.0 + seaLevelInMeters, new Color(70, 120, 60, 255)); planetRenderer.AddGradientPoint(1024.0 + seaLevelInMeters, new Color(110, 140, 75, 255)); planetRenderer.AddGradientPoint(2048.0 + seaLevelInMeters, new Color(160, 140, 111, 255)); planetRenderer.AddGradientPoint(3072.0 + seaLevelInMeters, new Color(184, 163, 141, 255)); planetRenderer.AddGradientPoint(4096.0 + seaLevelInMeters, new Color(255, 255, 255, 255)); planetRenderer.AddGradientPoint(6144.0 + seaLevelInMeters, new Color(128, 255, 255, 255)); planetRenderer.AddGradientPoint(16384.0 + seaLevelInMeters, new Color(0, 0, 255, 255)); planetRenderer.EnableLight = true; planetRenderer.LightContrast = 1.0 / resInMeters; planetRenderer.LightIntensity = 2; planetRenderer.LightElevation = 45; planetRenderer.LightAzimuth = 135; planetRenderer.Render(); string filename; using (var sfd = new SaveFileDialog()) { sfd.Filter = "PNG Image (*.png)|*.png"; DialogResult result; do { result = sfd.ShowDialog(); } while (result != DialogResult.OK); filename = sfd.FileName; } planetImage.SaveGdiBitmap(filename, System.Drawing.Imaging.ImageFormat.Png); }
private static void BuildGrayscaleRenderer(ImageRenderer renderer) { renderer.ClearGradient(); renderer.AddGradientPoint(0, new Color(0, 0, 0, 255)); renderer.AddGradientPoint(1D, new Color(255, 255, 255, 255)); }