31 lines
1.3 KiB
C++
31 lines
1.3 KiB
C++
// hmap_sample: writes a demo map in every format Hammer++ supports.
|
|
// hmap_sample [outdir] -> demo.hmap (editable source), demo_runtime.hmap (compiled + baked), demo.fbx, demo.obj
|
|
#include <hmap/hmap.h>
|
|
|
|
#include <cstdio>
|
|
#include <string>
|
|
|
|
int main(int argc, char** argv) {
|
|
std::string dir = argc > 1 ? argv[1] : ".";
|
|
hmap::Map map = hmap::makeDemoMap();
|
|
|
|
hmap::CompileOptions opt;
|
|
opt.bakeLighting = true;
|
|
opt.lightEdge = 64; // coarse light grid keeps the sample files small
|
|
hmap::CompiledMap cm = hmap::compile(map, opt);
|
|
std::printf("compiled in %.1f ms: %u brushes, %u meshes, %u tris, BSP %u nodes / %u leaves (depth %u), %u lights\n", cm.stats.ms,
|
|
cm.stats.brushes, cm.stats.meshes, cm.stats.triangles, cm.stats.bspNodes, cm.stats.bspLeaves, cm.stats.bspDepth,
|
|
cm.stats.lights);
|
|
|
|
auto report = [](const char* what, const hmap::Status& s) {
|
|
std::printf("%-22s %s\n", what, s ? "ok" : s.message.c_str());
|
|
return s.ok;
|
|
};
|
|
bool ok = true;
|
|
ok &= report("demo.hmap", hmap::saveMap(dir + "/demo.hmap", map));
|
|
ok &= report("demo_runtime.hmap", hmap::saveCompiled(dir + "/demo_runtime.hmap", cm));
|
|
ok &= report("demo.fbx", hmap::exportFBX(dir + "/demo.fbx", cm));
|
|
ok &= report("demo.obj", hmap::exportOBJ(dir + "/demo.obj", cm));
|
|
return ok ? 0 : 1;
|
|
}
|