-
-
Notifications
You must be signed in to change notification settings - Fork 81
dtl::shape::PerlinIsland (形状クラス)
Kasugaccho edited this page Oct 13, 2019
·
19 revisions
// v0.4.10.0 - v0.4.13.0
namespace dtl::shape {
template <typename T>
class PerlinIsland;
}
// v0.4.14.0 -
namespace dtl::shape {
template <typename T, typename Random_Engine = DTL_RANDOM_DEFAULT_RANDOM>
class PerlinIsland;
}
※ T
は1bit以上の型
※ Random_Engine
は乱数生成クラス
(デフォルトでDTL_RANDOM_DEFAULT_RANDOM
が入っている)
機能名 | 対応 |
---|---|
非長方形Matrix | 可能✅ |
PerlinIsland
とは "Matrixの描画範囲にパーリンノイズを使用して地形を生成する" 機能を持つクラスである。
描画範囲の全てを必ず塗りつぶす。
dtl::shape::PerlinIsland in Unreal Engine (形状クラス) [上級者向けの解説]
dtl::shape::PerlinIsland in Unreal Engine (形状クラス) [初心者向けの解説]
名前 | 説明 | 対応バージョン |
---|---|---|
draw | Matrixに描画する | v0.4.10 |
drawArray | Matrixに描画する | v0.4.10 |
create | Matrixに描画してMatrixを返す | v0.4.10 |
createArray | Matrixに描画してMatrixを返す | v0.4.10 |
名前 | 説明 | 対応バージョン |
---|---|---|
getPointX | 描画始点座標Xを取得 | v0.4.10 |
getPointY | 描画始点座標Yを取得 | v0.4.10 |
getWidth | 描画横幅Wを取得 | v0.4.10 |
getHeight | 描画縦幅Hを取得 | v0.4.10 |
getValue | 描画値を取得 | v0.4.10 |
名前 | 説明 | 対応バージョン |
---|---|---|
setPointX | 描画始点座標Xを指定 | v0.4.10 |
setPointY | 描画始点座標Yを指定 | v0.4.10 |
setWidth | 描画横幅Wを指定 | v0.4.10 |
setHeight | 描画縦幅Hを指定 | v0.4.10 |
setPoint | 描画始点座標(X,Y)を指定 | v0.4.10 |
setRange | 描画範囲(X,Y,W,H)を指定 | v0.4.10 |
setValue | 描画値を指定 | v0.4.10 |
名前 | 説明 | 対応バージョン |
---|---|---|
clearPointX | 描画始点座標Xを消去 | v0.4.10 |
clearPointY | 描画始点座標Yを消去 | v0.4.10 |
clearWidth | 描画横幅Wを消去 | v0.4.10 |
clearHeight | 描画縦幅Hを消去 | v0.4.10 |
clearPoint | 描画始点座標(X,Y)を消去 | v0.4.10 |
clearRange | 描画範囲(X,Y,W,H)を消去 | v0.4.10 |
clearValue | 描画値を消去 | v0.4.10 |
継承元: <DTL/Range/RectBasePerlin.hpp>
dtl::shape::PerlinIsland<shape_t>(frequency, octaves, max_height, min_height).draw(matrix, width, height);
#include <DTL.hpp>
#include <cstdint>
#include <array>
int main() {
using shape_t = std::uint_fast8_t;
std::array<std::array<shape_t, 48>, 48> matrix{ {} };
dtl::shape::PerlinIsland<shape_t>(6.0, 8, 63).draw(matrix);
dtl::console::OutputNumber<shape_t>(",").draw(matrix);
dtl::console::OutputStringBool<shape_t>("##", "//").drawOperator(matrix, [](const shape_t value) {return value > 30; });
return 0;
}
31,35,37,38,39,36,34,32,31,31,24,20,23,26,25,25,31,36,39,34,31,27,27,32,31,34,32,27,23,19,20,26,31,37,41,45,47,42,37,34,31,27,24,20,23,29,32,30,
37,40,40,40,41,34,33,36,36,33,25,22,26,32,33,32,36,44,49,42,39,37,36,37,37,37,32,28,25,20,21,28,35,39,44,54,57,49,40,37,36,34,30,28,32,36,32,29,
36,41,42,41,39,34,36,38,34,32,23,20,26,36,41,44,48,50,50,42,37,36,31,32,36,39,39,37,32,26,26,29,33,38,48,57,59,52,45,40,39,39,36,33,33,40,37,34,
36,40,39,38,37,37,37,37,33,26,20,23,32,41,46,48,52,51,46,42,37,33,26,24,28,35,43,43,34,29,32,37,38,41,51,56,54,51,44,39,40,36,32,31,27,31,32,33,
31,39,40,37,39,38,36,35,31,24,25,29,35,43,48,46,47,49,48,43,35,29,25,24,31,34,39,44,39,33,39,47,47,45,51,52,51,47,37,30,31,32,32,31,23,22,25,27,
33,41,41,38,37,37,37,33,25,25,33,36,40,46,45,39,41,43,42,39,29,24,21,24,33,37,37,40,38,35,42,48,50,52,52,44,41,40,31,27,29,28,28,29,22,17,17,19,
34,41,40,39,35,31,30,30,28,26,29,33,37,43,44,39,41,38,33,30,22,22,23,26,34,42,40,40,40,37,39,39,44,50,43,34,37,39,33,31,31,28,27,26,17,12,13,18,
32,37,37,38,38,33,28,29,30,28,30,33,32,34,39,38,38,36,29,20,16,21,27,32,36,38,37,40,41,36,33,31,35,40,35,32,36,41,37,34,33,32,30,23,16,14,15,21,
31,38,42,39,39,37,30,30,31,29,31,33,31,28,35,35,31,30,21,17,23,26,28,32,31,33,38,40,39,33,30,28,31,37,37,36,39,43,38,33,31,30,28,22,23,21,21,30,
33,41,49,46,38,33,32,32,31,29,29,29,28,28,33,29,24,20,18,24,31,31,31,33,30,35,42,42,39,32,26,23,26,32,34,37,41,41,37,30,24,27,28,26,28,29,29,35,
41,47,51,52,44,33,33,32,28,28,27,29,30,27,25,21,14,9,15,26,29,29,34,37,36,37,41,40,35,28,20,17,22,28,28,31,33,32,36,32,29,28,26,23,24,29,27,33,
45,53,55,51,45,36,32,32,28,24,21,24,26,23,17,14,12,7,9,18,21,25,31,35,34,36,39,39,38,30,20,19,24,26,24,24,24,26,34,35,32,27,26,27,26,27,27,33,
47,54,53,46,43,38,34,31,23,18,15,13,15,20,19,15,15,12,12,18,19,24,26,29,31,34,40,40,39,35,28,28,31,29,27,24,23,22,27,28,23,21,30,37,35,34,36,40,
41,46,45,43,38,33,34,33,26,20,15,12,10,13,19,21,19,14,14,16,18,20,23,26,28,29,34,38,39,38,33,34,38,39,35,30,26,20,19,17,14,19,31,37,39,40,42,48,
41,43,42,42,35,27,30,33,29,25,21,19,14,13,20,26,21,16,18,21,23,23,27,28,26,26,28,36,39,42,37,32,36,38,34,31,24,17,15,15,16,24,31,35,42,47,47,50,
42,40,38,40,38,33,29,30,31,27,25,23,18,19,27,28,22,22,27,28,29,30,33,33,30,28,29,32,35,41,39,32,28,30,29,24,18,12,14,18,22,28,31,35,40,45,46,43,
31,33,37,38,39,39,30,28,31,30,32,29,23,23,29,31,31,29,27,28,31,32,35,35,31,27,26,32,39,42,38,37,31,31,29,20,15,10,14,24,31,35,38,39,39,41,41,36,
21,27,39,40,40,41,35,29,26,30,35,34,31,29,34,41,39,33,27,29,35,32,33,35,31,25,24,31,40,42,39,38,34,33,29,18,13,10,16,30,40,45,45,42,39,41,41,32,
26,27,36,41,46,45,39,34,30,29,28,31,33,35,40,44,38,36,36,34,35,32,36,40,33,30,33,36,43,41,36,32,25,22,18,14,16,21,32,43,48,50,45,44,41,39,36,28,
32,29,32,38,47,47,41,35,33,30,26,30,34,36,40,42,39,40,43,40,39,38,41,44,40,40,44,47,46,37,31,26,18,11,6,11,20,29,43,52,54,49,42,44,46,42,35,29,
31,31,37,38,43,49,47,40,39,36,29,33,39,40,45,44,39,38,40,38,39,42,45,47,47,45,42,44,39,30,30,23,15,10,6,11,19,28,41,49,47,44,41,42,43,45,42,34,
33,36,40,38,40,47,50,48,46,38,27,29,38,41,46,46,41,37,37,36,36,40,45,48,50,47,42,40,32,26,29,25,13,10,10,13,20,27,35,40,40,40,41,42,42,45,46,41,
32,39,42,41,45,45,41,41,38,36,33,30,38,43,46,47,41,36,36,36,34,38,42,43,48,47,43,40,31,23,25,28,21,14,10,9,14,25,31,30,33,34,35,39,39,38,38,36,
33,41,46,47,49,43,34,33,31,34,34,33,43,49,46,40,34,29,27,29,29,33,33,32,38,44,44,40,32,22,22,27,29,23,14,12,16,24,31,30,31,33,36,38,35,30,30,31,
31,36,42,43,39,33,30,32,31,34,33,30,39,47,42,32,31,27,24,24,23,26,25,23,31,40,41,41,39,31,30,30,31,31,24,22,23,25,32,34,31,32,35,36,31,27,31,35,
22,29,34,32,31,27,22,25,27,29,30,28,32,41,42,32,29,25,21,19,17,21,19,19,24,31,36,40,43,39,37,37,34,31,27,26,27,32,36,33,30,29,28,29,24,24,33,38,
22,29,30,27,28,29,25,23,21,18,20,26,32,36,39,33,31,28,25,23,22,24,21,21,20,21,27,31,37,39,39,43,36,27,26,23,23,29,27,25,26,26,27,29,27,26,29,30,
24,29,31,29,27,28,29,22,17,13,13,21,29,32,35,35,35,35,32,27,26,31,30,26,21,16,16,21,32,38,39,39,34,29,26,19,19,24,22,20,24,25,26,30,34,32,26,24,
31,33,34,35,31,27,30,22,15,11,5,11,19,26,32,32,31,35,31,28,31,35,31,29,23,18,19,21,31,40,40,34,31,28,20,17,23,30,29,27,31,30,28,30,35,40,35,31,
43,44,38,35,34,33,32,25,21,16,8,8,15,23,27,27,29,32,29,30,37,38,35,32,24,20,23,27,34,37,38,34,27,22,20,21,28,34,32,30,34,34,32,35,38,41,39,38,
43,48,39,32,32,34,32,25,25,23,16,11,13,21,22,25,31,35,33,31,35,36,35,32,25,21,24,32,36,33,33,31,22,18,22,25,31,38,34,30,36,37,36,41,43,42,42,39,
39,41,39,34,31,32,31,29,28,27,25,18,13,13,17,27,33,39,37,35,37,40,40,34,27,25,28,30,34,37,34,30,24,19,21,25,28,33,33,31,36,36,35,39,40,45,45,36,
31,29,33,38,39,36,34,35,31,29,29,24,15,10,18,27,31,36,37,41,47,47,44,37,31,28,26,26,31,37,32,31,31,27,28,28,23,22,25,27,31,32,33,36,39,44,38,31,
23,21,28,42,48,46,39,35,34,32,29,25,19,14,18,23,22,27,35,46,53,50,45,41,38,32,28,25,31,37,35,34,36,34,30,23,20,19,18,23,28,32,33,32,37,40,34,27,
19,17,28,43,48,52,43,34,37,37,35,32,25,20,18,21,21,25,37,48,51,51,50,47,41,35,32,29,35,45,44,39,40,37,28,18,16,18,20,28,32,31,25,20,26,30,31,24,
19,19,30,41,43,48,45,37,41,41,38,33,26,23,20,20,21,24,34,42,45,46,45,44,43,38,35,32,38,47,45,40,39,35,31,24,16,18,24,30,29,24,19,17,18,21,25,26,
31,26,30,41,43,45,45,41,47,47,41,38,31,27,24,23,23,23,29,31,31,37,37,37,39,38,35,34,39,46,43,36,31,27,28,32,27,21,22,26,23,16,17,23,23,24,30,28,
40,33,29,36,37,36,39,41,47,52,46,38,32,30,29,26,25,24,24,22,22,29,34,34,35,33,31,32,35,40,42,35,29,26,27,35,39,31,26,27,25,21,19,21,26,29,31,27,
40,35,30,34,31,28,35,40,44,50,42,34,30,24,23,23,24,25,24,20,19,21,25,29,30,28,29,32,31,32,34,33,30,32,34,38,42,38,34,32,29,29,24,19,26,31,29,26,
36,34,33,32,30,31,34,34,37,43,40,37,36,29,24,23,25,29,30,23,14,14,22,27,26,27,31,35,34,33,31,29,29,32,38,38,41,43,39,35,33,31,27,24,30,34,32,26,
31,29,27,28,31,32,27,27,31,38,41,39,39,35,30,28,31,33,29,24,15,11,21,31,31,30,30,37,39,40,37,33,31,29,33,34,39,42,34,29,31,29,30,29,31,35,32,29,
30,27,27,31,33,30,24,24,26,32,38,40,43,39,35,39,43,40,29,18,11,5,14,28,29,26,28,38,41,45,45,38,35,31,32,34,34,34,29,26,25,28,33,32,32,35,32,31,
28,25,29,33,30,24,20,21,22,28,37,41,45,46,46,48,43,39,30,16,8,2,8,22,24,23,29,37,40,43,45,42,41,38,38,42,40,39,39,37,33,33,34,34,36,38,37,37,
26,26,28,30,27,21,17,20,24,28,37,38,39,42,46,44,35,32,30,22,16,9,9,19,24,27,31,35,39,43,47,48,47,43,41,44,47,50,50,45,39,38,39,39,40,40,41,44,
23,26,31,33,31,27,24,26,31,31,35,34,31,30,35,36,31,26,28,26,19,12,9,17,23,30,33,36,43,47,51,50,47,44,43,44,47,51,47,42,39,38,40,40,39,37,37,42,
23,28,36,37,36,34,33,35,39,38,37,29,23,22,25,27,24,21,26,30,25,18,14,19,28,37,38,42,49,52,50,41,38,38,39,42,43,46,42,39,41,41,41,41,39,34,31,36,
29,32,36,36,39,41,39,41,43,41,37,28,25,25,26,26,22,21,28,32,26,22,19,23,36,48,47,46,46,45,40,32,37,37,35,37,36,40,41,35,38,41,40,35,32,27,25,33,
31,32,32,36,44,46,42,42,41,38,32,27,28,27,29,30,26,25,31,33,27,20,17,21,33,46,48,46,44,36,27,29,38,40,34,31,32,37,36,34,37,36,34,31,25,17,16,27,
####################////////////##########////########//////////##################//////////##//
####################//////############################//////////####################////######//
####################//////################################//////################################
##################//////####################//////########//############################//######
##################//////##################//////##############################//########////////
################////####################////////##############################//////////////////
############//////////################//////////##################################//////////////
############//////////##############//////////######################################////////////
############////##//######//######////////////##############////##################//////////////
##################//////////##//////////########//##########//////############////////////////##
################////////////////////////////##############////////////##########//////////////##
################////////////////////////////##############//////////////////######////////////##
################////////////////////////////////############////##////////////////////##########
################////////////////////////////////////##################//////////////############
##########////##//////////////////////////////////////##################////////////############
############////##//////////////////////////####//////##########////////////////////############
############////##//##////////####//////##########////##############////////////################
////##########//////######//########////##########////##############////////////################
////############//////############################//############////////////##################//
##//##############//////######################################//////////////##################//
####################//####################################//////////////////####################
####################////##################################//////////////////####################
######################//##################################//////////////////##//################
##################################////////################//////////////////##//##########////##
############//########//##########//////////////############////####////////##############//####
////######//////////////########//////////////////##################//////######////////////####
////////////////////////##########////////////////////############//////////////////////////////
////##////////////////////############////##////////////##########//////////////////////####////
##########//////////////////##########//######//////////##########//////////////##//////########
##############////////////////////##////########////////########//////////####//################
##############//////////////////################//////##########////////######//################
##############//////////////////################////////######////////////######################
##//##############//////////////##################//////##########//////////////################
//////##############////////////////################////############//////////////############//
//////##################////////////##################//############////////////####////////##//
//////##################////////////##################################//////////////////////////
##////####################////////////############################////##////////////////////////
####//####################//////////////////####################//////######////////////////##//
####//####//############//////////////////////////////##########//##############//////////##////
########//################//////////////////////////##########////##################//////####//
##//////####////############////####//////////####////############//##########//##//////######//
//////####////////##################//////////////////######################////////############
//////##////////////################//////////////////##########################################
////////////////////################////////////////############################################
////######//////##########//######//////////////////############################################
////##################////////////////////////////##############################################
//####################////////////////##////////##########################################////##
######################//////////////####////////############////########################////////
#include <DTL.hpp>
#include <DTL/ImageWrite.hpp>
#include <cstddef>
#include <cstdint>
#include <new>
#include <memory>
int main() {
using shape_t = std::uint_fast8_t;
constexpr std::size_t size_x{ 512 };
constexpr std::size_t size_y{ 512 };
//温度
std::unique_ptr<float[][size_x] > temperature(new(std::nothrow) float[size_y][size_x]);
dtl::shape::PerlinIsland<float>(6.0, 8, -20.0f, 60.0f).draw(temperature, size_x, size_y);
//降水量
std::unique_ptr<std::uint_fast16_t[][size_x] > amount_of_rainfall(new(std::nothrow) std::uint_fast16_t[size_y][size_x]);
dtl::shape::PerlinIsland<std::uint_fast16_t>(6.0, 8, 0, 4500).draw(amount_of_rainfall, size_x, size_y);
//標高
std::unique_ptr<shape_t[][size_x] > elevation(new(std::nothrow) shape_t[size_y][size_x]);
dtl::shape::PerlinIsland<shape_t>(6.0, 8, 200).draw(elevation, size_x, size_y);
//バイオーム
std::unique_ptr<shape_t[][size_x] > biome(new(std::nothrow) shape_t[size_y][size_x]);
for (std::size_t row{}; row < size_x; ++row)
for (std::size_t col{}; col < size_y; ++col) {
//海
if (elevation[row][col] < 90) biome[row][col] = 0;
//ツンドラ
else if (temperature[row][col] < -5.0f) biome[row][col] = 1;
//砂漠
else if (amount_of_rainfall[row][col] < 500) biome[row][col] = 2;
else if (amount_of_rainfall[row][col] < 1500) {
//ステップ
if (temperature[row][col] < 20.0f) biome[row][col] = 3;
//サバンナ
else biome[row][col] = 4;
}
//針葉樹林
else if (temperature[row][col] < 3.0f) biome[row][col] = 5;
//夏緑樹林
else if (temperature[row][col] < 12.0f) biome[row][col] = 6;
//照葉樹林
else if (temperature[row][col] < 20.0f) biome[row][col] = 7;
//雨緑樹林
else if (amount_of_rainfall[row][col] < 2500) biome[row][col] = 8;
//亜熱帯多雨林
else if (temperature[row][col] < 24.0f) biome[row][col] = 9;
//熱帯多雨林
else biome[row][col] = 10;
}
dtl::storage::FilePNG<shape_t>("file_sample_biome.png", 3).write(biome, size_x, size_y, [](const shape_t value, unsigned char* const color) {
switch (value) {
//海
case 0:
color[0] = 41;
color[1] = 40;
color[2] = 159;
break;
//ツンドラ
case 1:
color[0] = 218;
color[1] = 217;
color[2] = 225;
break;
//砂漠
case 2:
color[0] = 223;
color[1] = 203;
color[2] = 140;
break;
//ステップ
case 3:
color[0] = 188;
color[1] = 205;
color[2] = 146;
break;
//サバンナ
case 4:
color[0] = 164;
color[1] = 143;
color[2] = 50;
break;
//針葉樹林
case 5:
color[0] = 97;
color[1] = 154;
color[2] = 96;
break;
//夏緑樹林
case 6:
color[0] = 101;
color[1] = 163;
color[2] = 56;
break;
//照葉樹林
case 7:
color[0] = 9;
color[1] = 100;
color[2] = 5;
break;
//雨緑樹林
case 8:
//亜熱帯多雨林
case 9:
//熱帯多雨林
case 10:
color[0] = 43;
color[1] = 84;
color[2] = 41;
break;
}
});
return 0;
}
Copyright (c) 2018-2021 As Project.
Distributed under the Boost Software License, Version 1.0.(See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)