From 539c5dde8324f1e94e38378b69f587d0d93db5e4 Mon Sep 17 00:00:00 2001 From: lzwdgc Date: Tue, 12 Dec 2017 01:26:11 +0300 Subject: [PATCH] Rename height to length. --- src/common/types.cpp | 2 +- src/common/types.h | 2 +- src/mmp_extractor/mmp.cpp | 52 +++++++++++++++++++-------------------- src/mmp_extractor/mmp.h | 17 ++++++------- 4 files changed, 35 insertions(+), 38 deletions(-) diff --git a/src/common/types.cpp b/src/common/types.cpp index 09243c7..899ff1c 100644 --- a/src/common/types.cpp +++ b/src/common/types.cpp @@ -54,7 +54,7 @@ void weather_group::load(const buffer &b) { READ(b, n_segs); segments.resize(n_segs); - READ(b, name); + READ_STRING_N(b, name, 0xA0); for (auto &s : segments) s.load(b); } diff --git a/src/common/types.h b/src/common/types.h index 3bcead5..ba818be 100644 --- a/src/common/types.h +++ b/src/common/types.h @@ -107,7 +107,7 @@ struct weather struct weather_group { uint32_t n_segs; - char name[0xA0]; + std::string name; std::vector segments; void load(const buffer &b); diff --git a/src/mmp_extractor/mmp.cpp b/src/mmp_extractor/mmp.cpp index 5dc69af..0523899 100644 --- a/src/mmp_extractor/mmp.cpp +++ b/src/mmp_extractor/mmp.cpp @@ -69,7 +69,7 @@ void header::load(const buffer &b) READ_WSTRING(b, name1); READ_WSTRING(b, name2); READ(b, width); - READ(b, height); + READ(b, length); READ(b, n_header_segs); segments.resize(n_header_segs); READ_STRING_N(b, name, 0xA0); @@ -96,8 +96,8 @@ void mmp::load(const buffer &b) xsegs = (h.width - 1) / 64; if ((h.width - 1) % 64 != 0) xsegs++; - ysegs = (h.height - 1) / 64; - if ((h.height - 1) % 64 != 0) + ysegs = (h.length - 1) / 64; + if ((h.length - 1) % 64 != 0) ysegs++; int n_segs = xsegs * ysegs; segments.resize(n_segs); @@ -159,38 +159,38 @@ void mmp::process() c2.g = 255 - i * color_step; textures_map[iter->first] = c2; } - alpha_maps[0] = mat(h.width, h.height); + alpha_maps[0] = mat(h.width, h.length); for (auto &t : textures_map) { - alpha_maps[t.second.g] = mat(h.width, h.height); + alpha_maps[t.second.g] = mat(h.width, h.length); } // merge - heightmap = decltype(heightmap)(h.width, h.height); - texmap = decltype(texmap)(h.width, h.height); - texmap_colored = decltype(texmap_colored)(h.width, h.height); - colormap = decltype(colormap)(h.width, h.height); + heightmap = decltype(heightmap)(h.width, h.length); + texmap = decltype(texmap)(h.width, h.length); + texmap_colored = decltype(texmap_colored)(h.width, h.length); + colormap = decltype(colormap)(h.width, h.length); h_min = std::numeric_limits::max(); h_max = std::numeric_limits::min(); for (auto &s : segments) { const auto &data = s.d; - int y1 = s.desc.Ymin / 10; - int y2 = s.desc.Ymax / 10; - if (y2 > h.height) - y2 = h.height; + int y1 = s.desc.min.y / 10; + int y2 = s.desc.max.y / 10; + if (y2 > h.length) + y2 = h.length; for (int y = 0; y1 < y2; y1++, y++) { - int x1 = s.desc.Xmin / 10; - int x2 = s.desc.Xmax / 10; + int x1 = s.desc.min.x / 10; + int x2 = s.desc.max.x / 10; auto dx = x2 - x1; if (x2 > h.width) x2 = h.width; for (int x = 0; x1 < x2; x1++, x++) { auto p = y * dx + x; - auto y_rev = h.height - y1 - 1; // for bmp reversion + auto y_rev = h.length - y1 - 1; // for bmp reversion //auto y_rev = y1; auto t = data.Infomap[p].getTexture(); @@ -204,9 +204,9 @@ void mmp::process() texmap_colored(y_rev, x1) = textures_map_colored[t]; colormap(y_rev, x1) = data.Colormap[p]; - auto height = data.Heightmap[p]; - h_min = std::min(h_min, height); - h_max = std::max(h_max, height); + auto length = data.Heightmap[p]; + h_min = std::min(h_min, length); + h_max = std::max(h_max, length); } } } @@ -220,14 +220,14 @@ void mmp::process() for (auto &s : segments) { - int y1 = s.desc.Ymin / 10; - int y2 = s.desc.Ymax / 10; - if (y2 > h.height) - y2 = h.height; + int y1 = s.desc.min.y / 10; + int y2 = s.desc.max.y / 10; + if (y2 > h.length) + y2 = h.length; for (int y = 0; y1 < y2; y1++, y++) { - int x1 = s.desc.Xmin / 10; - int x2 = s.desc.Xmax / 10; + int x1 = s.desc.min.x / 10; + int x2 = s.desc.max.x / 10; auto dx = x2 - x1; if (x2 > h.width) x2 = h.width; @@ -248,7 +248,7 @@ void mmp::writeFileInfo() if (!ofile) return; ofile << "width: " << h.width << "\n"; - ofile << "height: " << h.height << "\n"; + ofile << "length: " << h.length << "\n"; ofile << "x segments: " << xsegs << "\n"; ofile << "y segments: " << ysegs << "\n"; ofile << "h_min: " << h_min << "\n"; diff --git a/src/mmp_extractor/mmp.h b/src/mmp_extractor/mmp.h index c37a4df..92839a9 100644 --- a/src/mmp_extractor/mmp.h +++ b/src/mmp_extractor/mmp.h @@ -64,9 +64,9 @@ struct header std::wstring name1; std::wstring name2; uint32_t width; - uint32_t height; + uint32_t length; uint32_t n_header_segs; - std::string name; + std::string name; // default horizont name? std::vector segments; void load(const buffer &b); @@ -75,6 +75,7 @@ private: header_segment *create_segment(const buffer &b); }; +// see https://docs.unrealengine.com/latest/INT/Engine/Landscape/TechnicalGuide/index.html struct segment { static const int len = 65; @@ -83,12 +84,8 @@ struct segment struct description { uint32_t offset; - float Xmin; - float Ymin; - float Zmin; - float Xmax; - float Ymax; - float Zmax; + vector3 min; + vector3 max; float unk0[5]; uint32_t unk1[7]; }; @@ -156,8 +153,8 @@ struct mmp std::map> alpha_maps; std::map textures_map_colored; std::map textures_names; - Height h_min; - Height h_max; + Height h_min = 0; + Height h_max = 0; double scale16 = 0; double scale = 0; mat heightmap;