From 09d21f08dd0741a6ae598336787aafe7be0fc8f0 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Sat, 9 May 2026 09:56:38 -0700 Subject: [PATCH] feat(editor): add --gen-mesh-brazier fire-pit primitive MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 57th procedural mesh: 7-box brazier — square base plate, narrow vertical stem, wider bowl on top of the stem, and 3 flame boxes of varying heights rising from the bowl. The flame layout is a triangle (tallest center, two shorter on either side) so the silhouette reads as fire rather than a uniform block. Useful for dungeons, temples, watchtowers, throne rooms, goblin camps — anywhere a fantasy world needs visible light sources. Defaults to 0.55m bowl on a 0.80m stem (~1.28m total height). --- tools/editor/cli_gen_mesh.cpp | 127 ++++++++++++++++++++++++++++++++++ tools/editor/cli_help.cpp | 2 + tools/editor/main.cpp | 2 +- 3 files changed, 130 insertions(+), 1 deletion(-) diff --git a/tools/editor/cli_gen_mesh.cpp b/tools/editor/cli_gen_mesh.cpp index db10d04a..f1be8d4f 100644 --- a/tools/editor/cli_gen_mesh.cpp +++ b/tools/editor/cli_gen_mesh.cpp @@ -4655,6 +4655,130 @@ int handleCoffin(int& i, int argc, char** argv) { return 0; } +int handleBrazier(int& i, int argc, char** argv) { + // Brazier: 7-box fire-pit on a pedestal — square base + // plate, narrow vertical stem, wider bowl on top of the + // stem, and 3 small flame boxes of varying heights rising + // from the bowl. Useful for dungeons, temples, watchtowers, + // throne rooms — anywhere a fantasy world needs visible + // light sources. The 57th procedural mesh primitive. + std::string womBase = argv[++i]; + float bowlSize = 0.55f; + float stemHeight = 0.80f; + float stemT = 0.10f; + float baseSize = 0.35f; + if (i + 1 < argc && argv[i + 1][0] != '-') { + try { bowlSize = std::stof(argv[++i]); } catch (...) {} + } + if (i + 1 < argc && argv[i + 1][0] != '-') { + try { stemHeight = std::stof(argv[++i]); } catch (...) {} + } + if (i + 1 < argc && argv[i + 1][0] != '-') { + try { stemT = std::stof(argv[++i]); } catch (...) {} + } + if (i + 1 < argc && argv[i + 1][0] != '-') { + try { baseSize = std::stof(argv[++i]); } catch (...) {} + } + if (bowlSize <= 0 || stemHeight <= 0 || stemT <= 0 || baseSize <= 0 || + stemT >= baseSize || stemT >= bowlSize) { + std::fprintf(stderr, + "gen-mesh-brazier: dims > 0; stem must fit in base & bowl\n"); + return 1; + } + if (womBase.size() >= 4 && + womBase.substr(womBase.size() - 4) == ".wom") { + womBase = womBase.substr(0, womBase.size() - 4); + } + wowee::pipeline::WoweeModel wom; + wom.name = std::filesystem::path(womBase).stem().string(); + wom.version = 3; + auto addBox = [&](float cx, float cy, float cz, + float hx, float hy, float hz) { + struct Face { glm::vec3 n, du, dv; }; + Face faces[6] = { + {{0, 1, 0}, {1, 0, 0}, {0, 0, 1}}, + {{0,-1, 0}, {1, 0, 0}, {0, 0,-1}}, + {{1, 0, 0}, {0, 0, 1}, {0, 1, 0}}, + {{-1,0, 0}, {0, 0,-1}, {0, 1, 0}}, + {{0, 0, 1}, {-1,0, 0}, {0, 1, 0}}, + {{0, 0,-1}, {1, 0, 0}, {0, 1, 0}}, + }; + glm::vec3 c(cx, cy, cz); + for (const Face& f : faces) { + glm::vec3 center = c + glm::vec3(f.n.x*hx, f.n.y*hy, f.n.z*hz); + glm::vec3 du = glm::vec3(f.du.x*hx, f.du.y*hy, f.du.z*hz); + glm::vec3 dv = glm::vec3(f.dv.x*hx, f.dv.y*hy, f.dv.z*hz); + uint32_t base = static_cast(wom.vertices.size()); + auto push = [&](glm::vec3 p, float u, float v) { + wowee::pipeline::WoweeModel::Vertex vtx; + vtx.position = p; vtx.normal = f.n; vtx.texCoord = {u, v}; + wom.vertices.push_back(vtx); + }; + push(center - du - dv, 0, 0); + push(center + du - dv, 1, 0); + push(center + du + dv, 1, 1); + push(center - du + dv, 0, 1); + wom.indices.insert(wom.indices.end(), + {base, base + 1, base + 2, base, base + 2, base + 3}); + } + }; + // Base plate. + float baseHeight = baseSize * 0.20f; + float halfBase = baseSize * 0.5f; + addBox(0, baseHeight * 0.5f, 0, + halfBase, baseHeight * 0.5f, halfBase); + // Stem rising from base to where the bowl will sit. + float halfStemT = stemT * 0.5f; + float stemCY = baseHeight + stemHeight * 0.5f; + addBox(0, stemCY, 0, + halfStemT, stemHeight * 0.5f, halfStemT); + // Bowl: wide thin slab on top of the stem. + float bowlH = bowlSize * 0.25f; + float halfBowl = bowlSize * 0.5f; + float bowlCY = baseHeight + stemHeight + bowlH * 0.5f; + addBox(0, bowlCY, 0, halfBowl, bowlH * 0.5f, halfBowl); + // 3 flame boxes rising from the bowl, varying heights so + // the silhouette reads as a fire rather than a uniform + // block. Centered triangle layout. + float flameTop = baseHeight + stemHeight + bowlH; + float flameW = bowlSize * 0.18f; + float halfFW = flameW * 0.5f; + struct Flame { float dx, dz, h; }; + Flame flames[3] = { + { 0.0f, 0.0f, bowlSize * 0.50f }, // tallest center + { bowlSize * 0.18f, bowlSize * 0.10f, bowlSize * 0.30f }, + {-bowlSize * 0.18f, bowlSize * 0.10f, bowlSize * 0.35f }, + }; + for (const auto& f : flames) { + addBox(f.dx, flameTop + f.h * 0.5f, f.dz, + halfFW, f.h * 0.5f, halfFW); + } + wowee::pipeline::WoweeModel::Batch batch; + batch.indexStart = 0; + batch.indexCount = static_cast(wom.indices.size()); + batch.textureIndex = 0; + wom.batches.push_back(batch); + float totalH = flameTop + bowlSize * 0.50f; + wom.boundMin = glm::vec3(-halfBowl, 0.0f, -halfBowl); + wom.boundMax = glm::vec3( halfBowl, totalH, halfBowl); + if (!wowee::pipeline::WoweeModelLoader::save(wom, womBase)) { + std::fprintf(stderr, + "gen-mesh-brazier: failed to save %s.wom\n", womBase.c_str()); + return 1; + } + std::printf("Wrote %s.wom\n", womBase.c_str()); + std::printf(" base : %.3f square × %.3f thick\n", + baseSize, baseHeight); + std::printf(" stem : %.3f square × %.3f tall\n", + stemT, stemHeight); + std::printf(" bowl : %.3f wide × %.3f thick\n", bowlSize, bowlH); + std::printf(" flames : 3 (varied heights)\n"); + std::printf(" total H : %.3f\n", totalH); + std::printf(" vertices : %zu\n", wom.vertices.size()); + std::printf(" triangles : %zu\n", wom.indices.size() / 3); + return 0; +} + int handlePodium(int& i, int argc, char** argv) { // Podium: 4-box stepped pyramid speaker stand — large // bottom step, medium middle step, small top platform, @@ -6976,6 +7100,9 @@ bool handleGenMesh(int& i, int argc, char** argv, int& outRc) { if (std::strcmp(argv[i], "--gen-mesh-podium") == 0 && i + 1 < argc) { outRc = handlePodium(i, argc, argv); return true; } + if (std::strcmp(argv[i], "--gen-mesh-brazier") == 0 && i + 1 < argc) { + outRc = handleBrazier(i, argc, argv); return true; + } return false; } diff --git a/tools/editor/cli_help.cpp b/tools/editor/cli_help.cpp index 6fa494be..c44ca894 100644 --- a/tools/editor/cli_help.cpp +++ b/tools/editor/cli_help.cpp @@ -230,6 +230,8 @@ void printUsage(const char* argv0) { std::printf(" Sundial: square base + central gnomon slab + 4 cardinal hour markers (default 0.80/0.06/0.35/0.04)\n"); std::printf(" --gen-mesh-podium [baseSize] [stepH] [steps] [lecternSize]\n"); std::printf(" Podium: stepped pyramid + lectern at back of top platform (default 1.60/0.20/3/0.30)\n"); + std::printf(" --gen-mesh-brazier [bowlSize] [stemH] [stemT] [baseSize]\n"); + std::printf(" Brazier: base + stem + bowl + 3 flame boxes for fire-pit lighting (default 0.55/0.80/0.10/0.35)\n"); std::printf(" Procedural tree: cylindrical trunk + spherical foliage (default 0.1/2.0/0.7)\n"); std::printf(" --displace-mesh [scale]\n"); std::printf(" Offset each vertex along its normal by heightmap brightness × scale (default 1.0)\n"); diff --git a/tools/editor/main.cpp b/tools/editor/main.cpp index f613ba83..357d7a29 100644 --- a/tools/editor/main.cpp +++ b/tools/editor/main.cpp @@ -168,7 +168,7 @@ int main(int argc, char* argv[]) { "--gen-mesh-stool", "--gen-mesh-cauldron", "--gen-mesh-gate", "--gen-mesh-beehive", "--gen-mesh-weathervane", "--gen-mesh-scarecrow", "--gen-mesh-sundial", - "--gen-mesh-podium", + "--gen-mesh-podium", "--gen-mesh-brazier", "--gen-texture-gradient", "--gen-mesh-from-heightmap", "--export-mesh-heightmap", "--displace-mesh",