Ejemplo n.º 1
0
        public Guid Generate(OpenSimplexRequestDto requestDto)
        {
            int seed = requestDto.Seed.HasValue ? requestDto.Seed.Value : new Random().Next();

            var heightmapDto = openSimplexGenerator.Generate(
                requestDto.Width,
                requestDto.Height,
                requestDto.OverlappedSize,
                seed,
                requestDto.Scale,
                requestDto.Octaves,
                requestDto.Persistance,
                requestDto.Lacunarity
                );

            var id = CreateHeightmap(heightmapDto);

            if (requestDto.Infinite)
            {
                repository.AddBaseHeightmapChunk(new BaseHeightmapChunkDto
                {
                    Id             = id,
                    Width          = requestDto.Width,
                    Height         = requestDto.Height,
                    OverlappedSize = requestDto.OverlappedSize,
                    Seed           = seed,
                    Scale          = requestDto.Scale,
                    Octaves        = requestDto.Octaves,
                    Persistance    = requestDto.Persistance,
                    Lacunarity     = requestDto.Lacunarity,
                    Heightmap      = heightmapDto
                });

                repository.SaveChanges();
            }

            return(id);
        }
Ejemplo n.º 2
0
        public IActionResult CreateSimplexHeightmap([FromBody] OpenSimplexRequestDto requestDto)
        {
            var result = terrainService.Generate(requestDto);

            return(Ok(result));
        }