mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-10 02:53:51 +00:00
feat(editor): add --gen-mesh-stool small-furniture primitive
49th procedural mesh: 5-box backless stool — flat square seat on 4 short legs at the corners. Smaller-footprint counterpart to --gen-mesh-bench, pairs with --gen-mesh-table for taverns, workshops, NPC market stalls, dwarven taprooms. Defaults to 0.36m square seat at 0.49m total height — typical 3-legged-bar-stool proportions. Customizable per dimension so the same primitive covers child stools, milking stools, and tall workshop stools.
This commit is contained in:
parent
dfe997c564
commit
29c7ff6af6
3 changed files with 108 additions and 0 deletions
|
|
@ -4655,6 +4655,108 @@ int handleCoffin(int& i, int argc, char** argv) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int handleStool(int& i, int argc, char** argv) {
|
||||
// Stool: 5-box small backless seat — flat round-ish seat
|
||||
// (square here, since axis-aligned) on 4 short legs at the
|
||||
// corners. Pairs with --gen-mesh-table for taverns and
|
||||
// workshops. Smaller-footprint counterpart to --gen-mesh-bench.
|
||||
// The 49th procedural mesh primitive.
|
||||
std::string womBase = argv[++i];
|
||||
float seatSize = 0.36f; // seat side length
|
||||
float seatT = 0.04f; // seat thickness
|
||||
float legHeight = 0.45f;
|
||||
float legT = 0.04f; // square leg cross-section
|
||||
if (i + 1 < argc && argv[i + 1][0] != '-') {
|
||||
try { seatSize = std::stof(argv[++i]); } catch (...) {}
|
||||
}
|
||||
if (i + 1 < argc && argv[i + 1][0] != '-') {
|
||||
try { seatT = std::stof(argv[++i]); } catch (...) {}
|
||||
}
|
||||
if (i + 1 < argc && argv[i + 1][0] != '-') {
|
||||
try { legHeight = std::stof(argv[++i]); } catch (...) {}
|
||||
}
|
||||
if (i + 1 < argc && argv[i + 1][0] != '-') {
|
||||
try { legT = std::stof(argv[++i]); } catch (...) {}
|
||||
}
|
||||
if (seatSize <= 0 || seatT <= 0 || legHeight <= 0 || legT <= 0 ||
|
||||
legT * 2 >= seatSize) {
|
||||
std::fprintf(stderr,
|
||||
"gen-mesh-stool: dims > 0; legT must fit in seatSize\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});
|
||||
}
|
||||
};
|
||||
float halfSeat = seatSize * 0.5f;
|
||||
float halfLeg = legT * 0.5f;
|
||||
float seatTopY = legHeight + seatT;
|
||||
// Seat: flat slab on top of the legs.
|
||||
addBox(0, legHeight + seatT * 0.5f, 0,
|
||||
halfSeat, seatT * 0.5f, halfSeat);
|
||||
// 4 legs: corner-inset by halfLeg so they sit flush with
|
||||
// the seat's edge.
|
||||
float legX = halfSeat - halfLeg;
|
||||
float legCY = legHeight * 0.5f;
|
||||
addBox( legX, legCY, legX, halfLeg, legHeight * 0.5f, halfLeg);
|
||||
addBox(-legX, legCY, legX, halfLeg, legHeight * 0.5f, halfLeg);
|
||||
addBox( legX, legCY, -legX, halfLeg, legHeight * 0.5f, halfLeg);
|
||||
addBox(-legX, legCY, -legX, halfLeg, legHeight * 0.5f, halfLeg);
|
||||
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);
|
||||
wom.boundMin = glm::vec3(-halfSeat, 0.0f, -halfSeat);
|
||||
wom.boundMax = glm::vec3( halfSeat, seatTopY, halfSeat);
|
||||
if (!wowee::pipeline::WoweeModelLoader::save(wom, womBase)) {
|
||||
std::fprintf(stderr,
|
||||
"gen-mesh-stool: failed to save %s.wom\n", womBase.c_str());
|
||||
return 1;
|
||||
}
|
||||
std::printf("Wrote %s.wom\n", womBase.c_str());
|
||||
std::printf(" seat : %.3f square × %.3f thick\n", seatSize, seatT);
|
||||
std::printf(" legs : 4 × %.3f square (%.3f tall)\n",
|
||||
legT, legHeight);
|
||||
std::printf(" total H : %.3f\n", seatTopY);
|
||||
std::printf(" vertices : %zu\n", wom.vertices.size());
|
||||
std::printf(" triangles : %zu\n", wom.indices.size() / 3);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handleCrate(int& i, int argc, char** argv) {
|
||||
// Crate: 5-box wooden shipping crate — main cube body
|
||||
// plus 4 reinforcement posts running along the vertical
|
||||
|
|
@ -6027,6 +6129,9 @@ bool handleGenMesh(int& i, int argc, char** argv, int& outRc) {
|
|||
if (std::strcmp(argv[i], "--gen-mesh-crate") == 0 && i + 1 < argc) {
|
||||
outRc = handleCrate(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--gen-mesh-stool") == 0 && i + 1 < argc) {
|
||||
outRc = handleStool(i, argc, argv); return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -206,6 +206,8 @@ void printUsage(const char* argv0) {
|
|||
std::printf(" Tombstone: base plinth + tall slab + decorative crown (default 0.60/1.10/0.18/1.45)\n");
|
||||
std::printf(" --gen-mesh-crate <wom-base> [size] [postRadius]\n");
|
||||
std::printf(" Crate: cube body + 4 corner reinforcement posts (default 0.80/0.05)\n");
|
||||
std::printf(" --gen-mesh-stool <wom-base> [seatSize] [seatThick] [legHeight] [legThick]\n");
|
||||
std::printf(" Stool: small backless seat on 4 corner legs (default 0.36/0.04/0.45/0.04)\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");
|
||||
|
|
|
|||
|
|
@ -150,6 +150,7 @@ int main(int argc, char* argv[]) {
|
|||
"--gen-mesh-table", "--gen-mesh-lamppost", "--gen-mesh-bed",
|
||||
"--gen-mesh-ladder", "--gen-mesh-well", "--gen-mesh-signpost",
|
||||
"--gen-mesh-mailbox", "--gen-mesh-tombstone", "--gen-mesh-crate",
|
||||
"--gen-mesh-stool",
|
||||
"--gen-texture-gradient",
|
||||
"--gen-mesh-from-heightmap", "--export-mesh-heightmap",
|
||||
"--displace-mesh",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue