From f84a4771f3efe642c0946ccd94a52ede27f1d997 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 20 Oct 2024 21:55:00 +0100 Subject: Randomise for many trees, positions, rotations --- application/main.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'application/main.cpp') diff --git a/application/main.cpp b/application/main.cpp index d58cf6d..db42a63 100644 --- a/application/main.cpp +++ b/application/main.cpp @@ -24,6 +24,7 @@ #include #include // IWYU pragma: keep #include +#include #include #include #include @@ -79,10 +80,18 @@ public: &train->orders, l3->ends[1], l3->length, rl->findNodeAt({-1100000, -450000, 15000})); train->currentActivity = train->orders.current()->createActivity(); - auto foliage = std::dynamic_pointer_cast(assets.at("Tree-01-1")); + std::random_device randomdev {}; + std::uniform_real_distribution rotationDistribution {0, two_pi}; + std::uniform_int_distribution positionOffsetDistribution {-1500, +1500}; + std::uniform_int_distribution treeDistribution {1, 3}; + std::uniform_int_distribution treeVariantDistribution {1, 4}; for (auto x = 311000000; x < 311830000; x += 5000) { for (auto y = 491100000; y < 491130000; y += 5000) { - world.create(foliage, Location {geoData->positionAt({{x, y}})}); + world.create(std::dynamic_pointer_cast(assets.at(std::format("Tree-{:#02}-{}", + treeDistribution(randomdev), treeVariantDistribution(randomdev)))), + Location {geoData->positionAt({{x + positionOffsetDistribution(randomdev), + y + positionOffsetDistribution(randomdev)}}), + {0, rotationDistribution(randomdev), 0}}); } } } -- cgit v1.2.3