feat(editor): add --gen-mesh-signpost wayfinding primitive

45th procedural mesh: 4-box signpost — stone base anchor,
tall vertical pole, thin sign board mounted face-out near
the top, and a small decorative cap. Useful for crossroads,
tavern fronts, town entrances, dungeon area markers, quest
hub indicators.

Sign board's long axis runs along Z so the player reads the
sign when facing parallel to the road. Defaults to a 2.5 m
post with a 0.8 x 0.35 m board (~2.7 m total).
This commit is contained in:
Kelsi 2026-05-09 07:58:45 -07:00
parent db8d499e8e
commit af3c4f0bd6
3 changed files with 130 additions and 1 deletions

View file

@ -4655,6 +4655,130 @@ int handleCoffin(int& i, int argc, char** argv) {
return 0;
}
int handleSignpost(int& i, int argc, char** argv) {
// Signpost: 4-box wayfinding prop — stone base anchor at the
// ground, tall vertical pole, decorative cap, and one
// horizontal sign board mounted face-out from the pole near
// the top. Useful for crossroads, tavern fronts, town
// entrances, dungeon area markers. The 45th procedural mesh.
std::string womBase = argv[++i];
float postHeight = 2.5f;
float postThickness = 0.10f;
float baseSize = 0.30f;
float signWidth = 0.80f; // along Z (perpendicular to pole face)
float signHeight = 0.35f; // along Y
if (i + 1 < argc && argv[i + 1][0] != '-') {
try { postHeight = std::stof(argv[++i]); } catch (...) {}
}
if (i + 1 < argc && argv[i + 1][0] != '-') {
try { postThickness = std::stof(argv[++i]); } catch (...) {}
}
if (i + 1 < argc && argv[i + 1][0] != '-') {
try { baseSize = std::stof(argv[++i]); } catch (...) {}
}
if (i + 1 < argc && argv[i + 1][0] != '-') {
try { signWidth = std::stof(argv[++i]); } catch (...) {}
}
if (i + 1 < argc && argv[i + 1][0] != '-') {
try { signHeight = std::stof(argv[++i]); } catch (...) {}
}
if (postHeight <= 0 || postThickness <= 0 || baseSize <= 0 ||
signWidth <= 0 || signHeight <= 0 ||
postThickness >= baseSize) {
std::fprintf(stderr,
"gen-mesh-signpost: dims > 0; post must fit in base\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<uint32_t>(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 plinth at the floor.
float baseHeight = baseSize * 0.45f;
float halfBase = baseSize * 0.5f;
addBox(0, baseHeight * 0.5f, 0,
halfBase, baseHeight * 0.5f, halfBase);
// Pole rising above the base.
float poleBottomY = baseHeight;
float poleTopY = baseHeight + postHeight;
float poleCY = (poleBottomY + poleTopY) * 0.5f;
float halfPole = postThickness * 0.5f;
addBox(0, poleCY, 0,
halfPole, postHeight * 0.5f, halfPole);
// Sign board: thin rectangle mounted on the pole near the top.
// signWidth runs along Z (the long axis), signHeight along Y,
// and a sliver of postThickness along X — a billboard that
// reads as a sign when viewed from either +Z or -Z.
float signCenterY = poleTopY - signHeight * 0.7f;
float signThickness = postThickness * 0.6f;
addBox(0, signCenterY, 0,
signThickness * 0.5f, signHeight * 0.5f, signWidth * 0.5f);
// Decorative cap on top of the pole.
float capHeight = postThickness * 0.8f;
float capCY = poleTopY + capHeight * 0.5f;
float halfCap = postThickness * 0.9f;
addBox(0, capCY, 0,
halfCap, capHeight * 0.5f, halfCap);
wowee::pipeline::WoweeModel::Batch batch;
batch.indexStart = 0;
batch.indexCount = static_cast<uint32_t>(wom.indices.size());
batch.textureIndex = 0;
wom.batches.push_back(batch);
float totalH = capCY + capHeight * 0.5f;
float halfSignZ = signWidth * 0.5f;
wom.boundMin = glm::vec3(-std::max(halfBase, halfSignZ), 0.0f, -halfSignZ);
wom.boundMax = glm::vec3( std::max(halfBase, halfSignZ), totalH, halfSignZ);
if (!wowee::pipeline::WoweeModelLoader::save(wom, womBase)) {
std::fprintf(stderr,
"gen-mesh-signpost: failed to save %s.wom\n", womBase.c_str());
return 1;
}
std::printf("Wrote %s.wom\n", womBase.c_str());
std::printf(" total H : %.3f\n", totalH);
std::printf(" base : %.3f square × %.3f tall\n",
baseSize, baseHeight);
std::printf(" pole : %.3f square × %.3f tall\n",
postThickness, postHeight);
std::printf(" sign board : %.3f × %.3f (wide × tall)\n",
signWidth, signHeight);
std::printf(" vertices : %zu\n", wom.vertices.size());
std::printf(" triangles : %zu\n", wom.indices.size() / 3);
return 0;
}
int handleWell(int& i, int argc, char** argv) {
// Well: 4 stone walls arranged in a square ring (hollow
// interior so a player can see down the shaft) + 2 vertical
@ -5553,6 +5677,9 @@ bool handleGenMesh(int& i, int argc, char** argv, int& outRc) {
if (std::strcmp(argv[i], "--gen-mesh-well") == 0 && i + 1 < argc) {
outRc = handleWell(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--gen-mesh-signpost") == 0 && i + 1 < argc) {
outRc = handleSignpost(i, argc, argv); return true;
}
return false;
}

View file

@ -190,6 +190,8 @@ void printUsage(const char* argv0) {
std::printf(" Ladder: 2 vertical rails + N evenly-spaced horizontal rungs (default 3.0/0.6/8/0.06/0.04)\n");
std::printf(" --gen-mesh-well <wom-base> [outerSize] [wallH] [wallT] [postH] [postT]\n");
std::printf(" Well: 4 stone walls in a hollow square + 2 roof posts + cross beam (default 1.4/0.8/0.15/1.6/0.12)\n");
std::printf(" --gen-mesh-signpost <wom-base> [poleH] [poleT] [baseSize] [signWidth] [signHeight]\n");
std::printf(" Signpost: base + pole + sign board + cap (default 2.5/0.10/0.30/0.80/0.35)\n");
std::printf(" Procedural tree: cylindrical trunk + spherical foliage (default 0.1/2.0/0.7)\n");
std::printf(" --displace-mesh <wom-base> <heightmap.png> [scale]\n");
std::printf(" Offset each vertex along its normal by heightmap brightness × scale (default 1.0)\n");

View file

@ -140,7 +140,7 @@ int main(int argc, char* argv[]) {
"--gen-mesh-shrine", "--gen-mesh-totem", "--gen-mesh-cage",
"--gen-mesh-throne", "--gen-mesh-coffin", "--gen-mesh-bookshelf",
"--gen-mesh-table", "--gen-mesh-lamppost", "--gen-mesh-bed",
"--gen-mesh-ladder", "--gen-mesh-well",
"--gen-mesh-ladder", "--gen-mesh-well", "--gen-mesh-signpost",
"--gen-texture-gradient",
"--gen-mesh-from-heightmap", "--export-mesh-heightmap",
"--displace-mesh",