载入中...
搜索中...
未找到
MarchingCubes.cpp
浏览该文件的文档.
21
22#include <algorithm>
23#include <cmath>
24#include <cstdint>
25#include <map>
26
27namespace eve::procgen {
28namespace {
29
30#include "procgen/algorithms/MarchingCubesTables.inc"
31
32using eve::procgen::mc_tables::kEdgeTable;
33using eve::procgen::mc_tables::kTriTable;
34
35// Edge endpoints for the 12 cube edges (corner index pairs).
36constexpr int kEdgeCorners[12][2] = {
37 {0, 1}, {1, 2}, {2, 3}, {3, 0}, {4, 5}, {5, 6}, {6, 7}, {7, 4}, {0, 4}, {1, 5}, {2, 6}, {3, 7},
38};
39
40// Corner offsets in unit cube (x,y,z).
41constexpr float kCornerOffset[8][3] = {
42 {0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}, {0, 0, 1}, {1, 0, 1}, {1, 1, 1}, {0, 1, 1},
43};
44
45inline float lerp(float a, float b, float t) { return a + (b - a) * t; }
46
47inline void normalize3(float &x, float &y, float &z) {
48 const float len = std::sqrt(x * x + y * y + z * z);
49 if (len > 1e-8f) {
50 x /= len;
51 y /= len;
52 z /= len;
53 } else {
54 x = 0.f;
55 y = 1.f;
56 z = 0.f;
57 }
58}
59
60inline float fade(float t) { return t * t * t * (t * (t * 6.f - 15.f) + 10.f); }
61
62inline float grad3(uint32_t h, float x, float y, float z) {
63 const uint32_t g = h & 15u;
64 const float u = g < 8 ? x : y;
65 const float v = g < 4 ? y : (g == 12 || g == 14 ? x : z);
66 return ((g & 1u) ? -u : u) + ((g & 2u) ? -v : v);
67}
68
69float valueNoise3(float x, float y, float z, uint32_t seed) {
70 const int xi = int(std::floor(x));
71 const int yi = int(std::floor(y));
72 const int zi = int(std::floor(z));
73 const float xf = x - float(xi);
74 const float yf = y - float(yi);
75 const float zf = z - float(zi);
76 const float u = fade(xf);
77 const float v = fade(yf);
78 const float w = fade(zf);
79
80 auto h = [&](int ix, int iy, int iz) -> uint32_t {
81 return uint32_t(ix) * 374761393u + uint32_t(iy) * 668265263u + uint32_t(iz) * 1274126177u +
82 seed * 2246822519u;
83 };
84
85 const float n000 = grad3(h(xi, yi, zi), xf, yf, zf);
86 const float n100 = grad3(h(xi + 1, yi, zi), xf - 1, yf, zf);
87 const float n010 = grad3(h(xi, yi + 1, zi), xf, yf - 1, zf);
88 const float n110 = grad3(h(xi + 1, yi + 1, zi), xf - 1, yf - 1, zf);
89 const float n001 = grad3(h(xi, yi, zi + 1), xf, yf, zf - 1);
90 const float n101 = grad3(h(xi + 1, yi, zi + 1), xf - 1, yf, zf - 1);
91 const float n011 = grad3(h(xi, yi + 1, zi + 1), xf, yf - 1, zf - 1);
92 const float n111 = grad3(h(xi + 1, yi + 1, zi + 1), xf - 1, yf - 1, zf - 1);
93
94 const float x00 = lerp(n000, n100, u);
95 const float x10 = lerp(n010, n110, u);
96 const float x01 = lerp(n001, n101, u);
97 const float x11 = lerp(n011, n111, u);
98 const float y0 = lerp(x00, x10, v);
99 const float y1 = lerp(x01, x11, v);
100 return lerp(y0, y1, w); // roughly [-1,1]
101}
102
103float fbm3(float x, float y, float z, uint32_t seed, int octaves) {
104 float sum = 0.f;
105 float amp = 0.5f;
106 float freq = 1.f;
107 float norm = 0.f;
108 for (int i = 0; i < octaves; ++i) {
109 sum += valueNoise3(x * freq, y * freq, z * freq, seed + uint32_t(i) * 1013u) * amp;
110 norm += amp;
111 amp *= 0.5f;
112 freq *= 2.f;
113 }
114 return norm > 0.f ? sum / norm : 0.f;
115}
116
117struct Vec3 {
118 float x = 0.f, y = 0.f, z = 0.f;
119};
120
121Vec3 add(Vec3 a, Vec3 b) { return {a.x + b.x, a.y + b.y, a.z + b.z}; }
122Vec3 sub(Vec3 a, Vec3 b) { return {a.x - b.x, a.y - b.y, a.z - b.z}; }
123Vec3 mul(Vec3 a, float s) { return {a.x * s, a.y * s, a.z * s}; }
124float dot(Vec3 a, Vec3 b) { return a.x * b.x + a.y * b.y + a.z * b.z; }
125Vec3 cross(Vec3 a, Vec3 b) {
126 return {a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x};
127}
128Vec3 normalized(Vec3 v) {
129 const float len = std::sqrt(dot(v, v));
130 return len > 1e-8f ? mul(v, 1.f / len) : Vec3{0.f, 1.f, 0.f};
131}
132
133struct Triangle {
134 uint32_t a, b, c;
135};
136
137uint64_t edgeKey(uint32_t a, uint32_t b) {
138 if (a > b) std::swap(a, b);
139 return (uint64_t(a) << 32u) | uint64_t(b);
140}
141
142uint32_t midpoint(uint32_t a, uint32_t b, std::vector<Vec3> &vertices,
143 std::map<uint64_t, uint32_t> &cache) {
144 const uint64_t key = edgeKey(a, b);
145 const auto it = cache.find(key);
146 if (it != cache.end()) return it->second;
147 const uint32_t index = uint32_t(vertices.size());
148 vertices.push_back(normalized(add(vertices[a], vertices[b])));
149 cache.emplace(key, index);
150 return index;
151}
152
153void addPlanetVertex(MeshBuild &out, Vec3 p, float radius) {
154 p = normalized(p);
155 constexpr float kPi = 3.14159265358979323846f;
156 const float u = std::atan2(p.z, p.x) / (2.f * kPi) + 0.5f;
157 const float v = std::asin(std::clamp(p.y, -1.f, 1.f)) / kPi + 0.5f;
158 out.addVertex(p.x * radius, p.y * radius, p.z * radius, p.x, p.y, p.z, u, v);
159}
160
161} // namespace
162
163bool generateHexPlanetMesh(const Params &params, MeshBuild &out, std::string &error) {
164 const int subdivisions = params.getInt("subdivisions", 2);
165 const float radius = params.getFloat("radius", 1.f);
166 const float inset = params.getFloat("tileInset", 0.06f);
167 if (subdivisions < 0 || subdivisions > 7) {
168 error = "mesh.hexplanet: subdivisions must be in [0, 7]";
169 return false;
170 }
171 if (!(radius > 0.f)) {
172 error = "mesh.hexplanet: radius must be positive";
173 return false;
174 }
175 if (inset < 0.f || inset >= 0.5f) {
176 error = "mesh.hexplanet: tileInset must be in [0, 0.5)";
177 return false;
178 }
179
180 const float phi = (1.f + std::sqrt(5.f)) * 0.5f;
181 std::vector<Vec3> vertices = {
182 {-1, phi, 0}, {1, phi, 0}, {-1, -phi, 0}, {1, -phi, 0},
183 {0, -1, phi}, {0, 1, phi}, {0, -1, -phi}, {0, 1, -phi},
184 {phi, 0, -1}, {phi, 0, 1}, {-phi, 0, -1}, {-phi, 0, 1},
185 };
186 for (Vec3 &v : vertices) v = normalized(v);
187 std::vector<Triangle> faces = {
188 {0, 11, 5}, {0, 5, 1}, {0, 1, 7}, {0, 7, 10}, {0, 10, 11},
189 {1, 5, 9}, {5, 11, 4}, {11, 10, 2}, {10, 7, 6}, {7, 1, 8},
190 {3, 9, 4}, {3, 4, 2}, {3, 2, 6}, {3, 6, 8}, {3, 8, 9},
191 {4, 9, 5}, {2, 4, 11}, {6, 2, 10}, {8, 6, 7}, {9, 8, 1},
192 };
193 for (int level = 0; level < subdivisions; ++level) {
194 std::map<uint64_t, uint32_t> cache;
195 std::vector<Triangle> next;
196 next.reserve(faces.size() * 4u);
197 for (const Triangle &f : faces) {
198 const uint32_t ab = midpoint(f.a, f.b, vertices, cache);
199 const uint32_t bc = midpoint(f.b, f.c, vertices, cache);
200 const uint32_t ca = midpoint(f.c, f.a, vertices, cache);
201 next.insert(next.end(), {{f.a, ab, ca}, {f.b, bc, ab}, {f.c, ca, bc}, {ab, bc, ca}});
202 }
203 faces.swap(next);
204 }
205
206 std::vector<std::vector<uint32_t>> incident(vertices.size());
207 std::vector<Vec3> faceCenters;
208 faceCenters.reserve(faces.size());
209 for (uint32_t i = 0; i < faces.size(); ++i) {
210 const Triangle &f = faces[i];
211 faceCenters.push_back(normalized(add(add(vertices[f.a], vertices[f.b]), vertices[f.c])));
212 incident[f.a].push_back(i);
213 incident[f.b].push_back(i);
214 incident[f.c].push_back(i);
215 }
216
217 out.clear();
218 int pentagons = 0, hexagons = 0;
219 for (uint32_t cell = 0; cell < vertices.size(); ++cell) {
220 const Vec3 center = vertices[cell];
221 const Vec3 reference = std::fabs(center.y) < 0.9f ? normalized(cross({0, 1, 0}, center))
222 : normalized(cross({1, 0, 0}, center));
223 const Vec3 tangent = cross(center, reference);
224 auto &ring = incident[cell];
225 std::sort(ring.begin(), ring.end(), [&](uint32_t lhs, uint32_t rhs) {
226 const Vec3 a = sub(faceCenters[lhs], mul(center, dot(faceCenters[lhs], center)));
227 const Vec3 b = sub(faceCenters[rhs], mul(center, dot(faceCenters[rhs], center)));
228 return std::atan2(dot(a, tangent), dot(a, reference)) <
229 std::atan2(dot(b, tangent), dot(b, reference));
230 });
231 if (ring.size() == 5) ++pentagons;
232 else if (ring.size() == 6) ++hexagons;
233
234 const uint32_t base = uint32_t(out.getVertexCount());
235 addPlanetVertex(out, center, radius);
236 for (uint32_t faceIndex : ring) {
237 // Pull dual corners toward this cell's center. Re-normalizing keeps every tile spherical.
238 addPlanetVertex(out, normalized(add(mul(faceCenters[faceIndex], 1.f - inset),
239 mul(center, inset))), radius);
240 }
241 for (uint32_t i = 0; i < ring.size(); ++i) {
242 out.addTriangle(base, base + 1u + i, base + 1u + (i + 1u) % uint32_t(ring.size()));
243 }
244 }
245 out.setMeta("algorithm", "mesh.hexplanet");
246 out.setMeta("cells", std::to_string(vertices.size()));
247 out.setMeta("pentagons", std::to_string(pentagons));
248 out.setMeta("hexagons", std::to_string(hexagons));
249 out.setMeta("subdivisions", std::to_string(subdivisions));
250 return true;
251}
252
253bool marchingCubes(const float *density, int nx, int ny, int nz, float isolevel, MeshBuild &out,
254 std::string *error) {
255 if (!density) {
256 if (error) *error = "marchingCubes: null density";
257 return false;
258 }
259 if (nx < 2 || ny < 2 || nz < 2) {
260 if (error) *error = "marchingCubes: volume must be at least 2x2x2";
261 return false;
262 }
263
264 out.clear();
265 out.reserve((nx * ny * nz) / 2, (nx * ny * nz) * 3);
266
267 auto at = [&](int x, int y, int z) -> float {
268 return density[size_t(x) + size_t(y) * size_t(nx) + size_t(z) * size_t(nx) * size_t(ny)];
269 };
270
271 // World-space mapping: unit cube centered at origin spanning [-0.5, 0.5]^3.
272 const float sx = 1.f / float(nx - 1);
273 const float sy = 1.f / float(ny - 1);
274 const float sz = 1.f / float(nz - 1);
275
276 for (int z = 0; z < nz - 1; ++z) {
277 for (int y = 0; y < ny - 1; ++y) {
278 for (int x = 0; x < nx - 1; ++x) {
279 float val[8];
280 int cubeIndex = 0;
281 for (int i = 0; i < 8; ++i) {
282 const int cx = x + int(kCornerOffset[i][0]);
283 const int cy = y + int(kCornerOffset[i][1]);
284 const int cz = z + int(kCornerOffset[i][2]);
285 val[i] = at(cx, cy, cz);
286 if (val[i] < isolevel) cubeIndex |= (1 << i);
287 }
288 const int edges = kEdgeTable[cubeIndex];
289 if (edges == 0) continue;
290
291 float vertList[12][3];
292 for (int e = 0; e < 12; ++e) {
293 if (!(edges & (1 << e))) continue;
294 const int a = kEdgeCorners[e][0];
295 const int b = kEdgeCorners[e][1];
296 const float va = val[a];
297 const float vb = val[b];
298 float t = (isolevel - va) / (vb - va + 1e-12f);
299 t = std::clamp(t, 0.f, 1.f);
300 const float px =
301 (float(x) + lerp(kCornerOffset[a][0], kCornerOffset[b][0], t)) * sx - 0.5f;
302 const float py =
303 (float(y) + lerp(kCornerOffset[a][1], kCornerOffset[b][1], t)) * sy - 0.5f;
304 const float pz =
305 (float(z) + lerp(kCornerOffset[a][2], kCornerOffset[b][2], t)) * sz - 0.5f;
306 vertList[e][0] = px;
307 vertList[e][1] = py;
308 vertList[e][2] = pz;
309 }
310
311 for (int i = 0; kTriTable[cubeIndex][i] != -1; i += 3) {
312 const int e0 = kTriTable[cubeIndex][i];
313 const int e1 = kTriTable[cubeIndex][i + 1];
314 const int e2 = kTriTable[cubeIndex][i + 2];
315 const float *p0 = vertList[e0];
316 const float *p1 = vertList[e1];
317 const float *p2 = vertList[e2];
318
319 float ax = p1[0] - p0[0], ay = p1[1] - p0[1], az = p1[2] - p0[2];
320 float bx = p2[0] - p0[0], by = p2[1] - p0[1], bz = p2[2] - p0[2];
321 float nxn = ay * bz - az * by;
322 float nyn = az * bx - ax * bz;
323 float nzn = ax * by - ay * bx;
324 normalize3(nxn, nyn, nzn);
325
326 // Flip so normals point toward empty (lower density / outside).
327 // With cubeIndex bits for val < isolevel, winding already tends outward.
328 const uint32_t base = uint32_t(out.getVertexCount());
329 const float u0 = p0[0] + 0.5f, v0 = p0[1] + 0.5f;
330 const float u1 = p1[0] + 0.5f, v1 = p1[1] + 0.5f;
331 const float u2 = p2[0] + 0.5f, v2 = p2[1] + 0.5f;
332 out.addVertex(p0[0], p0[1], p0[2], nxn, nyn, nzn, u0, v0);
333 out.addVertex(p1[0], p1[1], p1[2], nxn, nyn, nzn, u1, v1);
334 out.addVertex(p2[0], p2[1], p2[2], nxn, nyn, nzn, u2, v2);
335 out.addTriangle(base, base + 1, base + 2);
336 }
337 }
338 }
339 }
340
341 out.setMeta("algorithm", "mesh.marchingcubes");
342 return true;
343}
344
345bool fillDensityField(const Params &params, std::vector<float> &density, int &nx, int &ny, int &nz,
346 std::string &error) {
347 const int res = params.getInt("resolution",
348 params.getWidth() > 0 ? params.getWidth() : 24);
349 nx = params.getInt("nx", res);
350 // An explicit uniform resolution takes precedence over the default grid height.
351 ny = params.getInt("ny", params.has("resolution") ? res : (params.getHeight() > 0 ? params.getHeight() : res));
352 nz = params.getInt("nz", params.getInt("depth", res));
353 if (nx < 2 || ny < 2 || nz < 2) {
354 error = "mesh.marchingcubes: resolution must be at least 2 in each axis";
355 return false;
356 }
357 if (nx > 128 || ny > 128 || nz > 128) {
358 error = "mesh.marchingcubes: resolution capped at 128 per axis";
359 return false;
360 }
361
362 const std::string field = params.getString("field", "sphere");
363 const float scale = params.getFloat("scale", 1.f);
364 const int octaves = std::max(1, params.getInt("octaves", 3));
365 const uint32_t seed = params.getSeed();
366
367 density.assign(size_t(nx) * size_t(ny) * size_t(nz), 0.f);
368 for (int z = 0; z < nz; ++z) {
369 for (int y = 0; y < ny; ++y) {
370 for (int x = 0; x < nx; ++x) {
371 const float px = (float(x) / float(nx - 1) - 0.5f) * 2.f;
372 const float py = (float(y) / float(ny - 1) - 0.5f) * 2.f;
373 const float pz = (float(z) / float(nz - 1) - 0.5f) * 2.f;
374 float d = 0.f;
375 if (field == "sphere") {
376 const float r = params.getFloat("radius", 0.7f);
377 d = r - std::sqrt(px * px + py * py + pz * pz);
378 } else if (field == "rock") {
379 // An ellipsoid SDF whose radius is displaced by low-frequency strata and
380 // higher-frequency erosion. Quantising the direction before sampling the
381 // strata creates broad, natural fracture planes instead of a noisy sphere.
382 const float radius = params.getFloat("radius", 0.68f);
383 const float flattening =
384 std::clamp(params.getFloat("flattening", 0.22f), 0.f, 0.7f);
385 const float angularity =
386 std::clamp(params.getFloat("angularity", 0.35f), 0.f, 1.f);
387 const float erosion =
388 std::clamp(params.getFloat("erosion", 0.18f), 0.f, 0.45f);
389 const float detailScale = std::max(0.25f, scale);
390 const float sy = std::max(0.3f, 1.f - flattening);
391 const float ex = px;
392 const float ey = py / sy;
393 const float ez = pz;
394 const float len = std::sqrt(ex * ex + ey * ey + ez * ez);
395 const float invLen = len > 1e-5f ? 1.f / len : 0.f;
396 const float steps = 3.f + angularity * 9.f;
397 const float qx = std::round(ex * invLen * steps) / steps;
398 const float qy = std::round(ey * invLen * steps) / steps;
399 const float qz = std::round(ez * invLen * steps) / steps;
400 const float strata = fbm3((qx + 2.3f) * detailScale,
401 (qy + 4.7f) * detailScale,
402 (qz + 8.1f) * detailScale, seed, octaves);
403 const float pits = fbm3((px + 7.2f) * detailScale * 2.7f,
404 (py + 1.9f) * detailScale * 2.7f,
405 (pz + 5.4f) * detailScale * 2.7f,
406 seed + 7919u, std::max(2, octaves - 1));
407 const float displacement = strata * (0.08f + angularity * 0.16f) -
408 std::max(0.f, pits) * erosion;
409 d = radius + displacement - len;
410 } else if (field == "torus") {
411 const float R = params.getFloat("majorRadius", 0.55f);
412 const float r = params.getFloat("minorRadius", 0.22f);
413 const float q = std::sqrt(px * px + pz * pz) - R;
414 d = r - std::sqrt(q * q + py * py);
415 } else if (field == "terrain") {
416 const float h =
417 fbm3(px * scale + 3.1f, 0.f, pz * scale + 1.7f, seed, octaves) * 0.45f;
418 d = h - py;
419 } else if (field == "noise") {
420 const float n =
421 fbm3(px * scale + 2.f, py * scale + 5.f, pz * scale + 9.f, seed, octaves);
422 d = n - params.getFloat("threshold", 0.05f);
423 } else {
424 error = "mesh.marchingcubes: unknown field '" + field +
425 "' (use sphere|rock|torus|noise|terrain)";
426 return false;
427 }
428 // Soft boundary falloff so surfaces close.
429 const float margin = 0.92f;
430 const float bx = std::max(0.f, std::fabs(px) - margin);
431 const float by = std::max(0.f, std::fabs(py) - margin);
432 const float bz = std::max(0.f, std::fabs(pz) - margin);
433 d -= (bx * bx + by * by + bz * bz) * 4.f;
434 density[size_t(x) + size_t(y) * size_t(nx) + size_t(z) * size_t(nx) * size_t(ny)] =
435 d;
436 }
437 }
438 }
439 return true;
440}
441
443 std::vector<float> density;
444 int nx = 0, ny = 0, nz = 0;
445 if (!fillDensityField(params, density, nx, ny, nz, error)) return false;
446 const float isolevel = params.getFloat("isolevel", 0.f);
447 if (!marchingCubes(density.data(), nx, ny, nz, isolevel, out, &error)) return false;
448 out.setMeta("field", params.getString("field", "sphere"));
449 if (out.empty()) {
450 error = "mesh.marchingcubes: empty mesh (adjust field/isolevel/resolution)";
451 return false;
452 }
453 return true;
454}
455
456MeshRecipeRegistry &MeshRecipeRegistry::instance() {
457 static MeshRecipeRegistry reg;
458 return reg;
459}
460
461void MeshRecipeRegistry::registerRecipe(const std::string &id, MeshRecipeFn fn) {
463 descriptor.id = id;
464 descriptor.displayName = id;
465 registerRecipe(std::move(descriptor), std::move(fn));
466}
467
468void MeshRecipeRegistry::registerRecipe(RecipeDescriptor descriptor, MeshRecipeFn fn) {
469 const std::string id = descriptor.id;
470 recipes_[id] = Entry{std::move(fn), std::move(descriptor)};
471}
472
473bool MeshRecipeRegistry::has(const std::string &id) const {
474 return recipes_.find(id) != recipes_.end();
475}
476
477bool MeshRecipeRegistry::generate(const std::string &id, const Params &params, MeshBuild &out,
478 std::string &error) const {
479 auto it = recipes_.find(id);
480 if (it == recipes_.end()) {
481 error = "unknown mesh recipe '" + id + "'";
482 return false;
483 }
484 return it->second.fn(params, out, error);
485}
486
487const RecipeDescriptor *MeshRecipeRegistry::descriptor(const std::string &id) const {
488 const auto it = recipes_.find(id);
489 return it == recipes_.end() ? nullptr : &it->second.descriptor;
490}
491
492bool MeshRecipeRegistry::applyDefaults(const std::string &id, Params &params) const {
493 if (id == "mesh.autoBridge" && has(id)) {
494 auto applied = road::applyBridgeRecipeDefaults(params);
495 return applied.ok();
496 }
497 const RecipeDescriptor *schema = descriptor(id);
498 if (!schema) return false;
499 schema->applyDefaults(params);
500 return true;
501}
502
503std::vector<std::string> MeshRecipeRegistry::list() const {
504 std::vector<std::string> ids;
505 ids.reserve(recipes_.size());
506 for (const auto &kv : recipes_) ids.push_back(kv.first);
507 std::sort(ids.begin(), ids.end());
508 return ids;
509}
510
511void MeshRecipeRegistry::registerBuiltins() {
512 if (builtinsRegistered_) return;
517 auto mesh = [](std::string id, std::string name) {
518 RecipeDescriptor schema{std::move(id), std::move(name), "Mesh", {}};
519 schema.params.push_back(ParamDescriptor::integer("seed", "Seed", 1, 0, 2147483647));
520 return schema;
521 };
522 auto addAdvanced = [](RecipeDescriptor &schema, ParamDescriptor param) {
523 param.advanced = true;
524 schema.params.push_back(std::move(param));
525 };
526 RecipeDescriptor marching = mesh("mesh.marchingcubes", "Marching Cubes");
527 marching.params.push_back(ParamDescriptor::choice("field", "Density Field", "sphere",
528 {"sphere", "rock", "terrain", "torus", "noise"}));
529 marching.params.push_back(ParamDescriptor::integer("resolution", "Resolution", 24, 4, 256));
530 marching.params.push_back(ParamDescriptor::floating("isolevel", "Iso Level", 0.f, -2.f, 2.f, 0.01f));
531 marching.params.push_back(ParamDescriptor::floating("scale", "Noise Scale", 1.f, 0.01f, 128.f, 0.01f));
532 marching.params.push_back(ParamDescriptor::integer("octaves", "Octaves", 3, 1, 12));
533 addAdvanced(marching, ParamDescriptor::integer("nx", "X Resolution", 24, 2, 512));
534 addAdvanced(marching, ParamDescriptor::integer("ny", "Y Resolution", 24, 2, 512));
535 addAdvanced(marching, ParamDescriptor::integer("nz", "Z Resolution", 24, 2, 512));
536 addAdvanced(marching,
537 ParamDescriptor::floating("radius", "Field Radius", 0.7f, 0.01f, 10.f, 0.01f));
538 addAdvanced(marching, ParamDescriptor::floating("flattening", "Rock Flattening", 0.22f,
539 0.f, 0.7f, 0.01f));
540 addAdvanced(marching, ParamDescriptor::floating("angularity", "Rock Angularity", 0.35f,
541 0.f, 1.f, 0.01f));
542 addAdvanced(marching,
543 ParamDescriptor::floating("erosion", "Rock Erosion", 0.18f, 0.f, 0.45f, 0.01f));
544 addAdvanced(marching, ParamDescriptor::floating("majorRadius", "Torus Major Radius", 0.55f,
545 0.01f, 10.f, 0.01f));
546 addAdvanced(marching, ParamDescriptor::floating("minorRadius", "Torus Minor Radius", 0.22f,
547 0.01f, 10.f, 0.01f));
548 addAdvanced(marching, ParamDescriptor::floating("threshold", "Noise Threshold", 0.05f,
549 -1.f, 1.f, 0.01f));
550 registerRecipe(std::move(marching), generateMarchingCubesMesh);
551
553
554 RecipeDescriptor rock = mesh("mesh.rock", "Rock");
555 rock.params.push_back(ParamDescriptor::choice("baseShape", "Base Shape", "mixed",
556 {"mixed", "boulder", "slab", "block", "shard", "cliff"}));
557 rock.params.push_back(ParamDescriptor::integer("subdivisions", "Subdivisions", 3, 0, 6));
558 rock.params.push_back(ParamDescriptor::floating("radius", "Radius", 0.72f, 0.05f, 32.f, 0.01f));
559 rock.params.push_back(ParamDescriptor::floating("scale", "Scale", 2.4f, 0.25f, 64.f, 0.05f));
560 rock.params.push_back(ParamDescriptor::floating("variation", "Variation", 0.42f, 0.f, 1.f, 0.01f));
561 rock.params.push_back(ParamDescriptor::floating("angularity", "Angularity", 0.38f, 0.f, 1.f, 0.01f));
562 rock.params.push_back(ParamDescriptor::floating("erosion", "Erosion", 0.16f, 0.f, 0.45f, 0.01f));
563 addAdvanced(rock,
564 ParamDescriptor::floating("flattening", "Flattening", 0.22f, 0.f, 0.7f, 0.01f));
565 addAdvanced(rock, ParamDescriptor::integer("octaves", "Octaves", 4, 1, 8));
566 registerRecipe(std::move(rock), generateRockMesh);
567
568 RecipeDescriptor planet = mesh("mesh.hexplanet", "Hex Planet");
569 planet.params.push_back(ParamDescriptor::floating("radius", "Radius", 1.f, 0.01f, 1000.f, 0.01f));
570 planet.params.push_back(ParamDescriptor::integer("subdivisions", "Subdivisions", 2, 0, 7));
571 planet.params.push_back(ParamDescriptor::floating("tileInset", "Tile Inset", 0.06f, 0.f, 0.49f, 0.01f));
572 registerRecipe(std::move(planet), generateHexPlanetMesh);
573
574 RecipeDescriptor terrain = mesh("mesh.hexterrain", "Hex Terrain World");
575 terrain.params.push_back(ParamDescriptor::integer("width", "Width", 32, 2, 256));
576 terrain.params.push_back(ParamDescriptor::integer("height", "Height", 24, 2, 256));
577 terrain.params.push_back(ParamDescriptor::floating("radius", "Hex Radius", 1.f, 0.05f, 64.f, 0.05f));
578 terrain.params.push_back(ParamDescriptor::integer("seed", "Seed", 1, 1, 2147483647));
579 terrain.params.push_back(ParamDescriptor::floating("seaLevel", "Sea Level", 0.43f, 0.f, 1.f, 0.01f));
580 terrain.params.push_back(ParamDescriptor::floating("heightScale", "Height Scale", 4.f, 0.05f, 128.f, 0.05f));
581 terrain.params.push_back(ParamDescriptor::integer("riverCount", "River Count", 8, 0, 128));
582 terrain.params.push_back(ParamDescriptor::boolean("decorations", "Terrain Decorations", true));
583 terrain.params.push_back(ParamDescriptor::floating("vegetationDensity", "Vegetation Density", 1.f, 0.f, 2.f, 0.05f));
584 registerRecipe(std::move(terrain), generateHexTerrainMesh);
585
586 RecipeDescriptor tree = mesh("mesh.tree", "Tree");
587 tree.params.push_back(ParamDescriptor::choice("style", "Style", "lowpoly", {"lowpoly", "realistic"}));
588 tree.params.push_back(
589 ParamDescriptor::choice("leafMode", "Leaf Mode", "cards", {"cards", "clusters", "canopy", "none"}));
590 tree.params.push_back(ParamDescriptor::choice("branchAlgorithm", "Branch Algorithm", "weberPenn",
591 {"weberPenn", "spaceColonization"}));
592 tree.params.push_back(ParamDescriptor::floating("height", "Height", 6.f, 0.5f, 100.f, 0.1f));
593 tree.params.push_back(ParamDescriptor::floating("trunkRadius", "Trunk Radius", 0.33f, 0.02f, 10.f, 0.01f));
594 addAdvanced(tree, ParamDescriptor::floating("trunkTipRatio", "Trunk Tip Radius Ratio", 0.10f, 0.03f, 0.4f, 0.01f));
595 addAdvanced(tree, ParamDescriptor::floating("trunkTaper", "Trunk Taper Profile", 0.85f, 0.5f, 2.f, 0.05f));
596 addAdvanced(tree, ParamDescriptor::floating("rootFlare", "Root Flare", 0.70f, 0.f, 1.5f, 0.05f));
597 addAdvanced(tree, ParamDescriptor::floating("rootFlareHeight", "Root Flare Height", 0.10f, 0.03f, 0.25f, 0.01f));
598 addAdvanced(tree, ParamDescriptor::floating("barkRelief", "Bark Relief", 0.04f, 0.f, 0.12f, 0.01f));
599 addAdvanced(tree, ParamDescriptor::floating("trunkNoise", "Trunk Surface Noise", 0.18f, 0.f, 0.35f, 0.01f));
600 addAdvanced(tree, ParamDescriptor::floating("trunkNoiseScale", "Trunk Noise Wavelength", 3.f, 1.f, 8.f, 0.1f));
601 addAdvanced(tree, ParamDescriptor::integer("trunkKnots", "Trunk Knots", 3, 0, 8));
602 addAdvanced(tree, ParamDescriptor::floating("trunkKnotStrength", "Trunk Knot Strength", 0.35f, 0.f, 0.6f, 0.01f));
603 addAdvanced(tree, ParamDescriptor::integer("surfaceSegments", "Stem Surface Segments", 64, 8, 192));
604 tree.params.push_back(ParamDescriptor::floating("crownRadius", "Crown Radius", 2.04f, 0.1f, 50.f, 0.05f));
605 tree.params.push_back(ParamDescriptor::floating("leafDensity", "Leaf Density", 0.65f, 0.f, 1.f, 0.01f));
606 tree.params.push_back(ParamDescriptor::integer("branchLevels", "Branch Levels", 2, 1, 5));
607 tree.params.push_back(ParamDescriptor::integer("branchCount", "Branch Count", 6, 2, 20));
608 addAdvanced(tree,
609 ParamDescriptor::floating("leafSize", "Leaf Size", 0.45f, 0.02f, 10.f, 0.01f));
610 addAdvanced(tree, ParamDescriptor::floating("foliageStart", "Foliage Start", 0.35f,
611 0.1f, 0.9f, 0.01f));
612 addAdvanced(tree, ParamDescriptor::integer("radialSegments", "Radial Segments", 6, 3, 24));
613 addAdvanced(tree, ParamDescriptor::integer("curveSegments", "Curve Segments", 5, 2, 20));
614 addAdvanced(tree,
615 ParamDescriptor::floating("trunkCurve", "Trunk Curve", 0.1f, 0.f, 0.45f, 0.01f));
616 addAdvanced(tree,
617 ParamDescriptor::floating("curveBack", "Curve Back", 0.16f, -0.5f, 0.5f, 0.01f));
618 addAdvanced(tree, ParamDescriptor::floating("branchCurve", "Branch Curve", 0.13f, 0.f,
619 0.5f, 0.01f));
620 addAdvanced(tree, ParamDescriptor::floating("branchAngle", "Branch Angle", 62.f, 5.f, 88.f,
621 1.f));
622 addAdvanced(tree, ParamDescriptor::floating("branchAngleVariation", "Angle Variation", 12.f,
623 0.f, 40.f, 1.f));
624 addAdvanced(tree, ParamDescriptor::floating("phyllotaxis", "Phyllotaxis", 137.5f, 0.f,
625 360.f, 0.5f));
626 addAdvanced(tree,
627 ParamDescriptor::floating("tropism", "Tropism", 0.22f, -0.5f, 0.8f, 0.01f));
628 addAdvanced(tree, ParamDescriptor::floating("droop", "Droop", 0.18f, 0.f, 0.8f, 0.01f));
629 addAdvanced(tree, ParamDescriptor::floating("apicalDominance", "Apical Dominance", 0.62f,
630 0.f, 1.f, 0.01f));
631 addAdvanced(tree, ParamDescriptor::integer("attractorCount", "Attractor Count", 80, 12, 1200));
632 addAdvanced(tree,
633 ParamDescriptor::integer("colonizationIterations", "Growth Iterations", 30, 4, 160));
634 addAdvanced(tree, ParamDescriptor::floating("influenceRadius", "Influence Radius", 2.2032f,
635 0.05f, 100.f, 0.01f));
636 addAdvanced(tree, ParamDescriptor::floating("killRadius", "Kill Radius", 0.2652f, 0.01f,
637 100.f, 0.01f));
638 addAdvanced(tree,
639 ParamDescriptor::floating("growthStep", "Growth Step", 0.2856f, 0.01f, 100.f, 0.01f));
640 addAdvanced(tree, ParamDescriptor::floating("branchInertia", "Branch Inertia", 1.2f, 0.f,
641 4.f, 0.01f));
642 addAdvanced(tree, ParamDescriptor::floating("maxTurnAngle", "Maximum Turn Angle", 22.f, 2.f,
643 60.f, 1.f));
644 addAdvanced(tree, ParamDescriptor::floating("maxCumulativeAngle", "Maximum Crown Angle", 58.f,
645 10.f, 85.f, 1.f));
646 addAdvanced(tree, ParamDescriptor::floating("branchLengthFalloff", "Length Falloff", 0.58f,
647 0.f, 0.9f, 0.01f));
648 addAdvanced(tree, ParamDescriptor::floating("branchRadiusFalloff", "Radius Falloff", 0.5f,
649 0.f, 0.9f, 0.01f));
650 addAdvanced(tree, ParamDescriptor::floating("lowerLeafCoverage", "Lower Leaf Coverage", 0.72f,
651 0.f, 1.f, 0.01f));
652 addAdvanced(tree, ParamDescriptor::floating("upperLeafCoverage", "Upper Leaf Coverage", 0.18f,
653 0.f, 1.f, 0.01f));
654 addAdvanced(tree, ParamDescriptor::integer("maxChildren", "Maximum Children", 2, 1, 4));
655 addAdvanced(tree, ParamDescriptor::floating("clusterSize", "Cluster Size", 0.30f, 0.04f, 0.8f, 0.01f));
656 addAdvanced(tree, ParamDescriptor::floating("clusterLeafScale", "Cluster Leaf Scale", 0.85f, 0.1f, 3.f, 0.01f));
657 addAdvanced(tree, ParamDescriptor::floating("clusterSpacing", "Cluster Leaf Spacing", 0.80f, 0.25f, 3.f, 0.01f));
658 addAdvanced(tree, ParamDescriptor::floating("clusterSeparation", "Cluster Separation", 0.55f, 0.1f, 3.f, 0.01f));
659 addAdvanced(tree, ParamDescriptor::floating("clusterTilt", "Cluster Plane Tilt", 26.f, 0.f, 80.f, 1.f));
660 addAdvanced(tree, ParamDescriptor::integer("clusterPlanes", "Cluster Planes", 10, 1, 24));
661 addAdvanced(tree, ParamDescriptor::integer("clusterCaps", "Cluster Cap Planes", 2, 0, 8));
662 addAdvanced(tree, ParamDescriptor::integer("clusterLeaves", "Cluster Leaves Per Plane", 28, 1, 256));
663 addAdvanced(tree, ParamDescriptor::integer("clusterLimit", "Cluster Limit", 120, 1, 512));
664 registerRecipe(std::move(tree), generateTreeMesh);
665
666 RecipeDescriptor bush = mesh("mesh.bush", "Bush");
667 bush.params.push_back(ParamDescriptor::choice("style", "Style", "mound", {"mound", "sphere"}));
668 bush.params.push_back(
669 ParamDescriptor::choice("leafMode", "Leaf Mode", "mixed", {"mixed", "cards", "clusters", "blobs", "none"}));
670 bush.params.push_back(ParamDescriptor::floating("height", "Height", 1.4f, 0.3f, 30.f, 0.05f));
671 bush.params.push_back(ParamDescriptor::floating("width", "Width", 2.2f, 0.4f, 30.f, 0.05f));
672 bush.params.push_back(ParamDescriptor::integer("blobs", "Foliage Patches", 24, 1, 96));
673 bush.params.push_back(ParamDescriptor::floating("leafDensity", "Leaf Density", 0.62f, 0.f, 1.f, 0.01f));
674 bush.params.push_back(ParamDescriptor::floating("lobeScale", "Lobe Scale", 0.68f, 0.35f, 1.25f, 0.01f));
675 bush.params.push_back(
676 ParamDescriptor::floating("irregularity", "Irregularity", 0.62f, 0.f, 1.f, 0.01f));
677 addAdvanced(bush, ParamDescriptor::integer("rings", "Rings", 3, 2, 10));
678 addAdvanced(bush, ParamDescriptor::integer("radialSegments", "Radial Segments", 7, 4, 24));
679 addAdvanced(bush,
680 ParamDescriptor::floating("leafSize", "Leaf Size", 0.224f, 0.02f, 10.f, 0.01f));
681 addAdvanced(bush, ParamDescriptor::integer("twigs", "Twigs", 4, 0, 16));
682 addAdvanced(bush, ParamDescriptor::floating("twigRadius", "Twig Radius", 0.0264f, 0.001f, 2.4f, 0.001f));
683 addAdvanced(bush,
684 ParamDescriptor::floating("twigLength", "Twig Length", 0.42f, 0.05f, 10.f, 0.01f));
685 addAdvanced(bush, ParamDescriptor::floating("stemSpread", "Basal Stem Spread", 0.22f, 0.02f, 0.45f, 0.01f));
686 addAdvanced(bush, ParamDescriptor::floating("branchingStart", "Branching Start", 0.14f, 0.08f, 0.55f, 0.01f));
687 addAdvanced(bush, ParamDescriptor::floating("branchCurve", "Branch Curve", 0.3f, 0.f, 0.6f, 0.01f));
688 addAdvanced(bush,
689 ParamDescriptor::floating("branchRadiusFalloff", "Branch Radius Falloff", 0.5f, 0.3f, 0.7f, 0.01f));
690 addAdvanced(bush, ParamDescriptor::integer("branchCount", "Side Branches Per Stem", 4, 2, 6));
691 addAdvanced(bush, ParamDescriptor::floating("foliageStart", "Foliage Start", 0.10f, 0.05f, 0.5f, 0.01f));
692 addAdvanced(bush, ParamDescriptor::integer("branchLevels", "Branch Levels", 3, 1, 3));
693 addAdvanced(bush, ParamDescriptor::integer("branchSegments", "Branch Segments", 12, 4, 24));
694 addAdvanced(bush, ParamDescriptor::floating("canopyNormalBlend", "Canopy Normal Blend", 0.45f, 0.f, 0.8f, 0.01f));
695 addAdvanced(bush, ParamDescriptor::integer("clusterPlanes", "Cluster Planes", 10, 1, 24));
696 addAdvanced(bush, ParamDescriptor::integer("clusterLeaves", "Cluster Leaves Per Plane", 48, 1, 256));
697 registerRecipe(std::move(bush), generateBushMesh);
698
699 // Clay-sheet crowns only: look (noise lip, foam, transparency) is material-side.
700 RecipeDescriptor splash = mesh("mesh.water_splash", "Water Splash");
701 splash.params.push_back(ParamDescriptor::floating("height", "Height", 2.4f, 0.2f, 20.f, 0.05f));
702 splash.params.push_back(ParamDescriptor::floating("width", "Width", 3.2f, 0.3f, 30.f, 0.05f));
703 splash.params.push_back(ParamDescriptor::integer("layers", "Layers", 4, 2, 4));
704 splash.params.push_back(ParamDescriptor::floating("flare", "Flare", 1.0f, 0.35f, 1.75f, 0.01f));
705 addAdvanced(splash, ParamDescriptor::integer("onlyLayer", "Only Layer (-1=all)", -1, -1, 3));
706 addAdvanced(splash, ParamDescriptor::integer("radialSegments", "Radial Segments", 32, 8, 64));
707 addAdvanced(splash, ParamDescriptor::integer("heightSegments", "Height Segments", 12, 3, 32));
708 registerRecipe(std::move(splash), generateWaterSplashMesh);
709
710 RecipeDescriptor flower = mesh("mesh.flower", "Flower");
711 flower.params.push_back(ParamDescriptor::floating("height", "Height", 0.55f, 0.15f, 2.5f, 0.01f));
712 flower.params.push_back(
713 ParamDescriptor::floating("petalLength", "Petal Length", 0.22f, 0.05f, 1.2f, 0.01f));
714 flower.params.push_back(
715 ParamDescriptor::floating("petalWidth", "Petal Width", 0.12f, 0.03f, 1.0f, 0.01f));
716 flower.params.push_back(ParamDescriptor::integer("petals", "Petals", 6, 3, 12));
717 flower.params.push_back(
718 ParamDescriptor::floating("openAngle", "Open Angle", 58.f, 20.f, 85.f, 1.f));
719 addAdvanced(flower,
720 ParamDescriptor::floating("stemRadius", "Stem Radius", 0.02f, 0.005f, 0.12f, 0.001f));
721 addAdvanced(flower, ParamDescriptor::integer("sides", "Stem Sides", 6, 4, 16));
722 registerRecipe(std::move(flower), [](const Params &params, MeshBuild &out, std::string &error) {
724 if (!result.ok()) {
725 error = result.status().describe();
726 return false;
727 }
728 return true;
729 });
730
731 RecipeDescriptor tower = mesh("mesh.skyscraper", "Skyscraper");
732 tower.params.push_back(ParamDescriptor::integer("tiers", "Tiers", 5, 1, 24));
733 tower.params.push_back(ParamDescriptor::floating("baseWidth", "Base Width", 10.f, 0.5f, 500.f, 0.1f));
734 tower.params.push_back(ParamDescriptor::floating("baseDepth", "Base Depth", 10.f, 0.5f, 500.f, 0.1f));
735 tower.params.push_back(ParamDescriptor::floating("tierHeight", "Tier Height", 6.f, 0.5f, 100.f, 0.1f));
736 tower.params.push_back(ParamDescriptor::floating("setback", "Setback", 0.08f, 0.f, 0.6f, 0.01f));
737 tower.params.push_back(ParamDescriptor::integer("windowCols", "Window Columns", 6, 1, 24));
738 tower.params.push_back(ParamDescriptor::integer("windowRows", "Window Rows", 4, 1, 24));
739 addAdvanced(tower, ParamDescriptor::floating("windowDepth", "Window Depth", 0.04f, 0.f,
740 10.f, 0.01f));
741 addAdvanced(tower, ParamDescriptor::floating("spireHeight", "Spire Height", 0.f, 0.f,
742 1000.f, 0.1f));
743 registerRecipe(std::move(tower), generateSkyscraperMesh);
747 urban::registerUrbanMeshRecipes(*this);
748 road::registerRoadMeshRecipes(*this);
750 builtinsRegistered_ = true;
751}
752
753} // namespace eve::procgen
double z
double y
double x
float w
Definition AnimClip.cpp:738
std::string descriptor
std::string terrain
AuthorityStoreHandleRef reference
Definition Authority.cpp:24
const std::string & s
float cx
Definition CardTypes.cpp:36
float cy
Definition CardTypes.cpp:37
bool applied
glm::vec4 p[6]
SQObjectPtr key
Definition ECS.cpp:155
std::string name
Definition ECS.cpp:154
float density
tensor::Graph g
Definition GpuGraph.cpp:7
float u
Definition Grass.cpp:233
glm::vec3 n
Definition Grass.cpp:63
std::array< double, 10 > q
std::uint32_t ab
double r
float v
std::int32_t c
int h
std::vector< Colorf > px
std::array< float, 3 > scale
uint32_t a
uint32_t b
float y
float x
float z
std::vector< Edge > edges
std::string id
Poco::JSON::Object::Ptr result
std::vector< RecipeParam > params
MeleePoint3 b
Definition MeleeHit.cpp:41
double radius
Definition MeleeHit.cpp:42
MeleePoint3 a
Definition MeleeHit.cpp:40
int level
OceanMeshSettings mesh
glm::dvec2 center
glm::dvec3 displacement
std::string error
Definition Package.cpp:174
float f
float d
int steps
float t
ScriptStructure out
double splash
Cell cell
std::array< double, 2 > vertices[3]
int margin
uint32_t seed
Definition TreeMesh.cpp:276
std::size_t at
uint32_t index
std::vector< double > phi
std::string getString(const char *key, const std::string &fallback={}) const
Returns the string.
Definition Json.cpp:428
CPU triangle mesh from procedural mesh recipes (e.g. marching cubes). Positions/normals are xyz-packe...
Definition MeshBuild.h:20
EVENGINE_API_DOMAINS public API.
Owning, typed generation parameters.
Definition Params.h:27
std::unordered_map< const void *, size_t > ids
Definition Snapshot.cpp:109
constexpr HexVec3 lerp(HexVec3 a, HexVec3 b, float t) noexcept
Linear interpolation between two positions.
Definition HexMetrics.h:51
ForceVector add(ForceVector a, ForceVector b)
Definition ForceMath.h:13
double dot(ForceVector a, ForceVector b)
Definition ForceMath.h:14
Vec3 sub(Vec3 a, Vec3 b)
Vec3 mul(Vec3 a, float scale)
V3 cross(V3 a, V3 b)
Module-private road bake implementation helper.
Definition RoadBake.cpp:29
void registerCabinetRecipe(MeshRecipeRegistry &registry)
Register mesh.cabinet and its editor schema during single-threaded initialization.
Definition Cabinet.cpp:119
void registerCableChainRopeRecipes(MeshRecipeRegistry &registry)
Register mesh.cable / mesh.chain / mesh.rope mesh recipes.
bool generateHexPlanetMesh(const Params &params, MeshBuild &out, std::string &error)
Build the dual of a subdivided icosahedron. The result is a closed planet made of hexagonal cells plu...
void registerCastleMeshRecipe(MeshRecipeRegistry &r)
Register mesh.castle in the built-in mesh recipe registry.
bool generateBushMesh(const Params &params, MeshBuild &out, std::string &error)
Build a deterministic procedural small bush. Registered as the mesh.bush recipe.
Definition BushMesh.cpp:253
bool generateHexTerrainMesh(const Params &params, MeshBuild &out, std::string &error)
Build a deterministic, flat-top hexagonal continent mesh.
std::function< bool(const Params &params, MeshBuild &out, std::string &error)> MeshRecipeFn
void registerCaveMeshRecipe(MeshRecipeRegistry &registry)
Register the deterministic three-dimensional limestone cave recipe.
void registerMeshDeformationGeometryRecipes(MeshRecipeRegistry &registry)
Register the extended-plane and customizable hex-grid mesh recipes.
bool marchingCubes(const float *density, int nx, int ny, int nz, float isolevel, MeshBuild &out, std::string *error)
Classic Marching Cubes (Lorensen & Cline) over a regular scalar volume. Density >= isolevel is treate...
EVENGINE_API_DOMAINS void registerVesselRecipes(MeshRecipeRegistry &registry)
Register pottery recipes at initialization on the registry owner thread.
void registerLinearStructureRecipes(MeshRecipeRegistry &registry)
Register all built-in linear structure mesh recipes into a registry.
bool generateTreeMesh(const Params &params, MeshBuild &out, std::string &error)
Build a deterministic procedural tree. Registered as the mesh.tree recipe.
Definition TreeMesh.cpp:624
eve::Result< void > generateFlowerMesh(const Params &params, MeshBuild &out)
Build a small accent flower (stem + radial petals + centre).
void registerPrototypePieceRecipes(MeshRecipeRegistry &registry)
Register all prototype modules as prototype.* mesh recipes.
void registerLSystemRecipes(MeshRecipeRegistry &registry)
Register the mesh.lsystem grammar-based plant recipe.
bool generateWaterSplashMesh(const Params &params, MeshBuild &out, std::string &error)
Build deterministic clay-sheet crowns for a stylized water splash.
bool generateMarchingCubesMesh(const Params &params, MeshBuild &out, std::string &error)
Build mesh from Params (field + resolution + isolevel).
bool fillDensityField(const Params &params, std::vector< float > &density, int &nx, int &ny, int &nz, std::string &error)
Fill a density volume from a named field recipe (sphere / noise / terrain / torus).
bool generateRockMesh(const Params &params, MeshBuild &out, std::string &error)
Build a shared-vertex, deformed icosphere rock for economical game props.
Definition RockMesh.cpp:167
bool generateSkyscraperMesh(const Params &params, MeshBuild &out, std::string &error)
Build a deterministic procedural skyscraper. Registered as the mesh.skyscraper recipe.
SettlementPipeline::Stage fn
UI-independent metadata for one procedural recipe parameter.
Definition ParamSchema.h:14
Complete metadata and parameter schema shared by every procgen recipe family.
Definition ParamSchema.h:52
const ParamDescriptor * find(const std::string &key) const
Find one parameter descriptor by stable key.
std::vector< ParamDescriptor > params
Definition ParamSchema.h:56
void applyDefaults(Params &params) const
Fill missing Params values from this schema.