32 std::vector<Vector3> map_data;
34 switch (messenger_.
mode)
38 CreateFlatMap(&map_data);
43 CreateVerticalStripeMap(&map_data);
48 CreateHorizontalStripeMap(&map_data);
53 CreateDiagonalStripeMap(&map_data);
58 CreateMeshMap(&map_data);
63 CreateLatticePointMap(&map_data);
68 CreateCircleMap(&map_data);
73 CreateDonutMap(&map_data);
79 CreateFlatMap(&map_data);
89 ChangeMapToPerforated(&map_data);
95 ChangeMapToStep(&map_data);
101 ChangeMapToSlope(&map_data);
107 ChangeMapToTilt(&map_data);
113 ChangeMapToRough(&map_data);
119 ChangeMapToRadial(&map_data);
131void MapCreatorForSimulation::CreateFlatMap(std::vector<Vector3>* map)
const
133 assert(map !=
nullptr);
134 assert(map->empty());
140 for (
int x = 0; x < x_max; x++)
142 for (
int y = 0; y < y_max; y++)
150 map->push_back({ x_pos, y_pos, messenger_.
base_z });
155void MapCreatorForSimulation::CreateVerticalStripeMap(std::vector<Vector3>* map)
const
157 assert(map !=
nullptr);
158 assert(map->empty());
164 for (
int x = 0; x < x_max; x++)
166 for (
int y = 0; y < y_max; y++)
180 map->push_back({ x_pos, y_pos, messenger_.
base_z });
186void MapCreatorForSimulation::CreateHorizontalStripeMap(std::vector<Vector3>* map)
const
188 assert(map !=
nullptr);
189 assert(map->empty());
195 for (
int x = 0; x < x_max; x++)
197 for (
int y = 0; y < y_max; y++)
211 map->push_back({ x_pos, y_pos, messenger_.
base_z });
217void MapCreatorForSimulation::CreateDiagonalStripeMap(std::vector<Vector3>* map)
const
219 assert(map !=
nullptr);
220 assert(map->empty());
226 for (
int x = 0; x < x_max; x++)
228 for (
int y = 0; y < y_max; y++)
237 const bool do_create_map = x_in_stripe == y_in_stripe;
242 if (do_create_map || x < x_rough)
250 map->push_back({ x_pos, y_pos, messenger_.
base_z });
256void MapCreatorForSimulation::CreateMeshMap(std::vector<Vector3>* map)
const
258 assert(map !=
nullptr);
259 assert(map->empty());
265 for (
int x = 0; x < x_max; x++)
267 for (
int y = 0; y < y_max; y++)
277 do_create_map =
true;
281 do_create_map =
false;
286 do_create_map =
true;
292 if (do_create_map || x < x_rough)
300 map->push_back({ x_pos, y_pos, messenger_.
base_z });
306void MapCreatorForSimulation::CreateLatticePointMap(std::vector<Vector3>* map)
const
308 assert(map !=
nullptr);
309 assert(map->empty());
316 for (
int x = 0; x < x_max; x++)
318 for (
int y = 0; y < y_max; y++)
322 bool do_create_map =
false;
328 do_create_map =
false;
332 do_create_map =
true;
337 do_create_map =
false;
343 if (do_create_map || x < x_rough)
352 map->push_back({ x_pos, y_pos, messenger_.
base_z });
358void MapCreatorForSimulation::CreateCircleMap(std::vector<Vector3>* map)
const
360 assert(map !=
nullptr);
385 map->push_back({ x_pos, y_pos, messenger_.
base_z });
391void MapCreatorForSimulation::CreateDonutMap(std::vector<Vector3>* map)
const
393 assert(map !=
nullptr);
418 map->push_back({ x_pos, y_pos, messenger_.
base_z });
424void MapCreatorForSimulation::ChangeMapToPerforated(std::vector<Vector3>* map)
const
426 assert(map !=
nullptr);
430 const int cell_num_x =
static_cast<int>(
434 const int cell_num_y =
static_cast<int>(
438 const int cell_sum = cell_num_x * cell_num_y;
441 std::vector<bool> do_perforated(cell_sum,
false);
444 const int hole_num = cell_sum * messenger_.
hole_rate / 100;
446 for (
int i = 0; i < hole_num; i++)
448 do_perforated.at(i) =
true;
452 std::shuffle(std::begin(do_perforated), std::end(do_perforated),
453 std::default_random_engine());
456 for (
auto itr = (*map).begin(); itr != (*map).end();)
466 const int cell_pos_x =
static_cast<int>(
470 const int cell_pos_y =
static_cast<int>(
474 const int cell_index = cell_pos_x * cell_num_y + cell_pos_y;
477 if (0 <= cell_index && cell_index < do_perforated.size())
480 if (do_perforated[cell_index])
483 itr = (*map).erase(itr);
499void MapCreatorForSimulation::ChangeMapToStep(std::vector<Vector3>* map)
const
501 assert(map !=
nullptr);
509 const int step_count = 1 +
static_cast<int>((i.x - messenger_.
map_start_rough_x) /
518void MapCreatorForSimulation::ChangeMapToSlope(std::vector<Vector3>* map)
const
520 assert(map !=
nullptr);
534void MapCreatorForSimulation::ChangeMapToTilt(std::vector<Vector3>* map)
const
536 assert(map !=
nullptr);
549void MapCreatorForSimulation::ChangeMapToRough(std::vector<Vector3>* map)
const
551 assert(map !=
nullptr);
554 const int cell_num_x =
static_cast<int>(
558 const int cell_num_y =
static_cast<int>(
562 const int cell_sum = cell_num_x * cell_num_y;
565 std::vector<float> change_z_length;
567 for (
int i = 0; i < cell_sum; i++)
587 const int cell_pos_y =
static_cast<int>((i.y - messenger_.
map_min_y) /
591 const int cell_index = cell_pos_x * cell_num_y + cell_pos_y;
594 if (0 <= cell_index && cell_index < change_z_length.size())
596 i.z += change_z_length[cell_index];
601void MapCreatorForSimulation::ChangeMapToRadial(std::vector<Vector3>* map)
const
603 assert(map !=
nullptr);
605 const float divided_angle = std::numbers::pi_v<float> / messenger_.
radial_division;
607 for (
auto itr = (*map).begin(); itr != (*map).end();)
613 if (
static_cast<int>(angle / divided_angle) % 2 == 1)
615 const int i =
static_cast<int>(angle / divided_angle);
616 const float angle_dif = angle - i * divided_angle;
622 itr = (*map).erase(itr);
MapCreatorForSimulation(const SimulationMapParameter ¶m)
コンストラクタで作成するマップ情報を与える
MapState InitMap() override
マップの初期化を行う.
void UpdateMap(MapState *current_map) override
マップの更新を行う.
static constexpr float kMapPointDistance
z軸から(上から)みたとき,格子点状に分けられた脚接地可能点の間隔 [mm].
@ kHorizontalStripe
横じまの面を生成する.
@ kVerticalStripe
縦じまの面を生成する.
@ kLatticePoint
格子点の面を生成する.網目状の逆.
@ kMesh
格子状の面を生成する.網目状の地形ともいっていい.
@ kDiagonalStripe
斜めじまの面を生成する.
@ kTilt
縦軸を中心軸として回転させた地形に変化させる.
@ kRadiation
放射状の地形に変化させる.
@ kPerforated
穴の空いたマップに変化させる.
T GenerateRandomNumber(T min, T max)
指定した範囲内の乱数を生成する.
constexpr T ConvertDegToRad(const T deg) noexcept
角度を [deg] から [rad] に変換する関数.
マップ生成時のモードとオプションを指定する構造体.
int radial_hole_rate
放射状の地形のホール率[%].
int radial_division
放射状の地形の分割数.
float map_max_y
マップのY座標の最大値.
enums::SimulationMapMode mode
int stripe_interval
各種模様や穴を作成する際,これで指定したマス分の1辺を持つ正方形状にあなをあける.
float map_min_x
マップのX座標の最小値.
float step_length
階段の奥行[mm]
float map_start_rough_x
不整地が始まるX座標.
float circle_radius
円 / ドーナツの半径.
float radial_angle_offset
放射状の地形の角度オフセット[deg].
float map_min_y
マップのY座標の最小値.
float donut_radius
ドーナツの内側の半径.
unsigned int option
マップ生成のオプションを指定するbit.
Vector2 radial_center
放射状の地形の中心座標.
float step_height
段差高さ[mm].負の値にすると下りの階段になる.
float rough_min_height
デコボコな地形の最小高さ[mm]
float map_max_x
マップのX座標の最大値.
float slope_angle
斜面の傾斜角[deg]
float rough_max_height
デコボコな地形の最大高さ[mm]
float tilt_angle
地形を傾ける角度[deg]
float base_z
マップの基準となるZ座標.
Vector3 circle_center
円 / ドーナツの中心座標.
int hole_rate
不整地上の足場を除外する割合。ホール率[%]
constexpr Vector2 ProjectedXY() const noexcept
XY平面に射影したベクトルを返す.