mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-06 00:53:52 +00:00
feat(editor): alpha map export as individual 64x64 grayscale PNGs
This commit is contained in:
parent
25f1893b49
commit
4ea09b0b8b
2 changed files with 27 additions and 0 deletions
|
|
@ -121,6 +121,29 @@ bool WoweeTerrain::exportNormalMap(const pipeline::ADTTerrain& terrain,
|
|||
return true;
|
||||
}
|
||||
|
||||
int WoweeTerrain::exportAlphaMaps(const pipeline::ADTTerrain& terrain,
|
||||
const std::string& outputDir) {
|
||||
namespace fs = std::filesystem;
|
||||
fs::create_directories(outputDir);
|
||||
int exported = 0;
|
||||
|
||||
for (int ci = 0; ci < 256; ci++) {
|
||||
const auto& chunk = terrain.chunks[ci];
|
||||
for (size_t li = 1; li < chunk.layers.size(); li++) {
|
||||
if (!chunk.layers[li].useAlpha()) continue;
|
||||
size_t off = chunk.layers[li].offsetMCAL;
|
||||
if (off + 4096 > chunk.alphaMap.size()) continue;
|
||||
|
||||
std::string path = outputDir + "/chunk_" + std::to_string(ci) +
|
||||
"_layer_" + std::to_string(li) + ".png";
|
||||
stbi_write_png(path.c_str(), 64, 64, 1,
|
||||
chunk.alphaMap.data() + off, 64);
|
||||
exported++;
|
||||
}
|
||||
}
|
||||
return exported;
|
||||
}
|
||||
|
||||
bool WoweeTerrain::importOpen(const std::string& basePath, pipeline::ADTTerrain& terrain) {
|
||||
std::string hmPath = basePath + ".whm";
|
||||
std::ifstream f(hmPath, std::ios::binary);
|
||||
|
|
|
|||
|
|
@ -18,6 +18,10 @@ public:
|
|||
static bool exportNormalMap(const pipeline::ADTTerrain& terrain,
|
||||
const std::string& path);
|
||||
|
||||
// Export alpha maps as individual 64x64 grayscale PNGs per chunk layer
|
||||
static int exportAlphaMaps(const pipeline::ADTTerrain& terrain,
|
||||
const std::string& outputDir);
|
||||
|
||||
// Import terrain from open format back to ADTTerrain
|
||||
static bool importOpen(const std::string& basePath, pipeline::ADTTerrain& terrain);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue