mirror of
https://github.com/aimrebirth/tools.git
synced 2026-04-15 01:43:25 +00:00
Improve extraction. Improve transliteration.
This commit is contained in:
parent
065732bcb6
commit
17fc9980a0
2 changed files with 55 additions and 14 deletions
|
|
@ -60,7 +60,7 @@ std::string version();
|
||||||
std::string translate(const std::string &s)
|
std::string translate(const std::string &s)
|
||||||
{
|
{
|
||||||
UErrorCode ec = UErrorCode::U_ZERO_ERROR;
|
UErrorCode ec = UErrorCode::U_ZERO_ERROR;
|
||||||
auto tr = icu::Transliterator::createInstance("Latin-Cyrillic", UTransDirection::UTRANS_REVERSE, ec);
|
auto tr = icu::Transliterator::createInstance("Any-Latin; Latin-ASCII;", UTransDirection::UTRANS_FORWARD, ec);
|
||||||
if (!tr || ec)
|
if (!tr || ec)
|
||||||
throw std::runtime_error("Cannot create translator, ec = " + std::to_string(ec));
|
throw std::runtime_error("Cannot create translator, ec = " + std::to_string(ec));
|
||||||
icu::UnicodeString s2(s.c_str());
|
icu::UnicodeString s2(s.c_str());
|
||||||
|
|
@ -319,8 +319,8 @@ void block::load(const buffer &b)
|
||||||
{
|
{
|
||||||
h.load(b);
|
h.load(b);
|
||||||
|
|
||||||
if (h.size == 0) // critical error!!! cannot survive
|
//if (h.size == 0) // critical error!!! cannot survive
|
||||||
throw std::runtime_error("model file has bad block size field (size == 0)");
|
// throw std::runtime_error("model file has bad block size field (size == 0)");
|
||||||
|
|
||||||
// data
|
// data
|
||||||
buffer data = buffer(b, h.size);
|
buffer data = buffer(b, h.size);
|
||||||
|
|
@ -328,8 +328,13 @@ void block::load(const buffer &b)
|
||||||
// we cannot process this type at the moment
|
// we cannot process this type at the moment
|
||||||
if (h.type == BlockType::ParticleEmitter)
|
if (h.type == BlockType::ParticleEmitter)
|
||||||
return;
|
return;
|
||||||
|
if (h.type == BlockType::BitmapAlpha)
|
||||||
|
return;
|
||||||
|
|
||||||
loadPayload(data);
|
// if we have size - create new buffer
|
||||||
|
// else - pass current
|
||||||
|
// no copy when buffer is created before
|
||||||
|
loadPayload(h.size == 0 ? b : data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void block::loadPayload(const buffer &data)
|
void block::loadPayload(const buffer &data)
|
||||||
|
|
@ -343,16 +348,37 @@ void block::loadPayload(const buffer &data)
|
||||||
mat.load(data);
|
mat.load(data);
|
||||||
READ(data, mat_type);
|
READ(data, mat_type);
|
||||||
|
|
||||||
|
// check mat type - warn if unknown
|
||||||
|
switch (mat_type)
|
||||||
|
{
|
||||||
|
case MaterialType::Texture:
|
||||||
|
case MaterialType::TextureWithGlareMap:
|
||||||
|
case MaterialType::TextureWithGlareMap2:
|
||||||
|
case MaterialType::TextureWithGlareMapAndMask:
|
||||||
|
case MaterialType::TextureWithDetalizationMap:
|
||||||
|
case MaterialType::TextureWithDetalizationMapWithoutModulation:
|
||||||
|
case MaterialType::TiledTexture:
|
||||||
|
case MaterialType::AlphaTextureDoubleSided:
|
||||||
|
case MaterialType::AlphaTextureNoGlare:
|
||||||
|
case MaterialType::Fire:
|
||||||
|
case MaterialType::DetalizationObjectGrass:
|
||||||
|
case MaterialType::MaterialOnly:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
std::cout << h.name << ": " << "warning: unknown material type " << (int)mat_type << " \n";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// unk
|
// unk
|
||||||
READ(data, unk7);
|
READ(data, unk7);
|
||||||
READ(data, unk9);
|
READ(data, unk9); // scale?
|
||||||
READ(data, unk10);
|
READ(data, unk10);
|
||||||
READ(data, auto_animation);
|
READ(data, auto_animation);
|
||||||
READ(data, animation_cycle);
|
READ(data, animation_cycle);
|
||||||
READ(data, unk8);
|
READ(data, unk8);
|
||||||
READ(data, unk11);
|
READ(data, unk11);
|
||||||
READ(data, unk12);
|
READ(data, unk12);
|
||||||
READ(data, triangles_mult_7);
|
READ(data, triangles_mult_7); // additional params?!
|
||||||
//
|
//
|
||||||
|
|
||||||
READ(data, additional_params);
|
READ(data, additional_params);
|
||||||
|
|
@ -366,7 +392,10 @@ void block::loadPayload(const buffer &data)
|
||||||
READ(data, n_vertex);
|
READ(data, n_vertex);
|
||||||
vertices.resize(n_vertex);
|
vertices.resize(n_vertex);
|
||||||
READ(data, n_faces);
|
READ(data, n_faces);
|
||||||
if (triangles_mult_7 && (flags & F_USE_W_COORDINATE) && !unk11)
|
if (triangles_mult_7 && (
|
||||||
|
(flags & F_USE_W_COORDINATE) ||
|
||||||
|
flags == 0x112
|
||||||
|
) && !unk11)
|
||||||
n_faces *= 7;
|
n_faces *= 7;
|
||||||
for (auto &v : vertices)
|
for (auto &v : vertices)
|
||||||
v.load(data, flags);
|
v.load(data, flags);
|
||||||
|
|
@ -380,7 +409,7 @@ void block::loadPayload(const buffer &data)
|
||||||
for (auto &dm : damage_models)
|
for (auto &dm : damage_models)
|
||||||
dm.load(data);
|
dm.load(data);
|
||||||
|
|
||||||
std::string s = "extraction error: block #" + std::string(h.name);
|
std::string s = "extraction error: block: " + std::string(h.name);
|
||||||
/*if (!data.eof())
|
/*if (!data.eof())
|
||||||
{
|
{
|
||||||
cerr << s << "\n";
|
cerr << s << "\n";
|
||||||
|
|
@ -395,6 +424,9 @@ void block::loadPayload(const buffer &data)
|
||||||
triangles2.resize((data.size() - data.index()) / sizeof(face));
|
triangles2.resize((data.size() - data.index()) / sizeof(face));
|
||||||
for (auto &t : triangles2)
|
for (auto &t : triangles2)
|
||||||
READ(data, t);
|
READ(data, t);
|
||||||
|
uint16_t t;
|
||||||
|
while (!data.eof())
|
||||||
|
READ(data, t);
|
||||||
}
|
}
|
||||||
if (!data.eof())
|
if (!data.eof())
|
||||||
throw std::logic_error(s);
|
throw std::logic_error(s);
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ class buffer;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
F_USE_W_COORDINATE = 0x4, // F_USE_QUANTERNION?
|
F_USE_W_COORDINATE = 0x4, // F_USE_QUANTERNION/F_QUANTERNION?
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class AdditionalParameter : uint32_t
|
enum class AdditionalParameter : uint32_t
|
||||||
|
|
@ -57,11 +57,20 @@ enum class BlockType : uint32_t
|
||||||
|
|
||||||
enum class MaterialType : uint32_t
|
enum class MaterialType : uint32_t
|
||||||
{
|
{
|
||||||
Texture = 0x0,
|
Texture = 0x0,
|
||||||
TextureWithGlareMap = 0x1,
|
TextureWithGlareMap = 0x1,
|
||||||
TextureWithGlareMapAndMask = 0x32,
|
AlphaTextureNoGlare = 0x2, // TextureWithoutGlareMap
|
||||||
AlphaTextureDoubleSided = 0x6,
|
TextureWithGlareMap2 = 0x4, // ??? also <- 4
|
||||||
MaterialOnly = 0x14,
|
AlphaTextureDoubleSided = 0x6,
|
||||||
|
DetalizationObjectGrass = 0x8,
|
||||||
|
//DetalizationObjectStone = 0x8,
|
||||||
|
Fire = 0x9,
|
||||||
|
//Fire2 = 0x9,
|
||||||
|
MaterialOnly = 0x14,
|
||||||
|
TextureWithDetalizationMap = 0x1A, // from Viewer: (AdditionalParameter 1)
|
||||||
|
TextureWithDetalizationMapWithoutModulation = 0x20, // from Viewer: (AdditionalParameter 1)
|
||||||
|
TiledTexture = 0x22,
|
||||||
|
TextureWithGlareMapAndMask = 0x32,
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue