コード例 #1
0
ファイル: TerrainService.cs プロジェクト: Atee134/ptgweb
        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);
        }
コード例 #2
0
        public IActionResult CreateSimplexHeightmap([FromBody] OpenSimplexRequestDto requestDto)
        {
            var result = terrainService.Generate(requestDto);

            return(Ok(result));
        }