Fix mmp_extractor.

This commit is contained in:
lzwdgc 2018-07-09 20:28:34 +03:00
parent 541c3a0a89
commit 5c8565d9d1
4 changed files with 27 additions and 5 deletions

View file

@ -107,7 +107,7 @@ std::string buffer::read_string(uint32_t blocksize) const
std::wstring buffer::read_wstring(uint32_t blocksize) const
{
std::vector<uint16_t> data(blocksize);
_read(data.data(), data.size());
_read(data.data(), data.size() * sizeof(wchar_t));
return (const wchar_t *)data.data();
}

View file

@ -120,7 +120,7 @@ void mmp::load(const buffer &b)
void mmp::load(const std::string &fn)
{
filename = fn;
buffer b(read_file(filename, true));
buffer b(read_file(filename));
load(b);
}
@ -175,6 +175,8 @@ void mmp::process()
texmap = decltype(texmap)(h.width, h.length);
texmap_colored = decltype(texmap_colored)(h.width, h.length);
colormap = decltype(colormap)(h.width, h.length);
shadowmap = decltype(shadowmap)(h.width, h.length);
normalmap = decltype(normalmap)(h.width, h.length);
h_min = std::numeric_limits<Height>::max();
h_max = std::numeric_limits<Height>::min();
@ -208,6 +210,8 @@ void mmp::process()
texmap_colored(y_rev, x1) = textures_map_colored[t];
colormap(y_rev, x1) = data.Colormap[p];
shadowmap(y_rev, x1) = *(uint32_t*)&data.Shadowmap[p];
normalmap(y_rev, x1) = *(uint32_t*)&data.Normalmap[p];
auto length = data.Heightmap[p];
h_min = std::min(h_min, length);
@ -331,3 +335,15 @@ void mmp::writeColorMap()
auto fn = filename + ".colormap.bmp";
write_mat_bmp(fn, colormap);
}
void mmp::writeShadowMap()
{
auto fn = filename + ".shadowmap.bmp";
write_mat_bmp(fn, shadowmap);
}
void mmp::writeNormalMap()
{
auto fn = filename + ".normalmap.bmp";
write_mat_bmp(fn, normalmap);
}

View file

@ -131,7 +131,7 @@ struct segment
mini_lod mlod;
Height Heightmap[size];
info Infomap[size];
color Colormap[size];
color Colormap[size]; // diffuse color of material
shadow Shadowmap[size];
normal Normalmap[size];
};
@ -185,6 +185,8 @@ struct mmp
mat<uint32_t> texmap;
mat<uint32_t> texmap_colored;
mat<uint32_t> colormap;
mat<uint32_t> shadowmap;
mat<uint32_t> normalmap;
void load(const buffer &b);
void load(const std::string &filename);
@ -200,4 +202,6 @@ struct mmp
void writeTextureAlphaMaps();
void writeTextureMapColored();
void writeColorMap();
void writeShadowMap();
void writeNormalMap();
};

View file

@ -48,10 +48,12 @@ try
//m.writeTexturesList();
m.writeHeightMap();
//m.writeHeightMapSegmented();
/*m.writeTextureMap();
m.writeTextureMap();
m.writeTextureAlphaMaps();
m.writeTextureMapColored();
m.writeColorMap();*/
m.writeColorMap();
m.writeShadowMap();
m.writeNormalMap();
};
path p = argv[1];