16 Procgen *pg() {
return eve::ModuleManager::getInstance<Procgen>(
"Procgen"); }
18 std::vector<std::string> algorithms()
override {
19 std::vector<std::string> out;
21 for (
int i = 0; i <
p->getAlgorithmCount(); ++i) out.push_back(
p->getAlgorithmId(i));
25 std::vector<std::string> meshRecipes()
override {
26 std::vector<std::string> out;
28 for (
int i = 0; i <
p->getMeshRecipeCount(); ++i)
29 out.push_back(
p->getMeshRecipeId(i));
33 std::vector<std::string> textureRecipes()
override {
34 std::vector<std::string> out;
36 for (
int i = 0; i <
p->getTextureRecipeCount(); ++i)
37 out.push_back(
p->getTextureRecipeId(i));
41 std::vector<std::string> pbrRecipes()
override {
42 std::vector<std::string> out;
44 for (
int i = 0; i <
p->getPbrRecipeCount(); ++i) out.push_back(
p->getPbrRecipeId(i));
48 std::string generateMap(
const std::string &algorithm,
int width,
int height, uint32_t
seed,
49 const std::vector<std::pair<std::string, std::string>> ¶ms,
50 std::string *err)
override {
53 if (err) *err =
"Procgen module not available";
56 auto *par =
p->newParams();
59 for (
const auto &kv : params) {
60 if (kv.second.find_first_not_of(
"0123456789-") == std::string::npos)
61 par->setInt(kv.first, std::atoi(kv.second.c_str()));
63 par->setString(kv.first, kv.second);
65 auto *grid =
p->generate(algorithm, par);
67 if (err) *err =
"generate failed: " +
p->lastError();
70 std::string json =
p->gridToJson(grid);
75 std::string buildMesh(
const std::string &recipe, uint32_t
seed,
int width,
int height,
76 int depth, std::string *err)
override {
79 if (err) *err =
"Procgen module not available";
82 auto *par =
p->newParams();
87 auto *
mesh =
p->buildMesh(recipe, par);
89 if (err) *err =
"build failed: " +
p->lastError();
92 std::string json =
"{\"vertices\":" + std::to_string(
mesh->getVertexCount()) +
93 ",\"triangles\":" + std::to_string(
mesh->getIndexCount() / 3) +
"}";
102 static ProcgenQueryImpl
impl;
Procedural generation query surface (provided by the procgen module).
void registerProcgenCapabilities()