mirror of
https://github.com/aimrebirth/tools.git
synced 2026-04-15 01:43:25 +00:00
Improve groups printing.
This commit is contained in:
parent
eec6fb3ded
commit
91c0463604
2 changed files with 38 additions and 24 deletions
|
|
@ -106,6 +106,7 @@ const map<char, string> transliteration =
|
||||||
|
|
||||||
std::string version();
|
std::string version();
|
||||||
|
|
||||||
|
// UE does not recognize russian strings in .obj
|
||||||
string translate(const string &s)
|
string translate(const string &s)
|
||||||
{
|
{
|
||||||
string o;
|
string o;
|
||||||
|
|
@ -152,7 +153,12 @@ void vertex::load(const buffer &b, uint32_t flags)
|
||||||
std::string vertex::printVertex() const
|
std::string vertex::printVertex() const
|
||||||
{
|
{
|
||||||
string s;
|
string s;
|
||||||
s = "v " + to_string(-coordinates.x) + " " + to_string(coordinates.y) + " " + to_string(-coordinates.z);
|
s = "v " +
|
||||||
|
to_string(-coordinates.x) + " " +
|
||||||
|
to_string(coordinates.y) + " " +
|
||||||
|
to_string(-coordinates.z) + " " +
|
||||||
|
to_string(coordinates.w)
|
||||||
|
;
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -166,7 +172,10 @@ std::string vertex::printNormal() const
|
||||||
std::string vertex::printTex() const
|
std::string vertex::printTex() const
|
||||||
{
|
{
|
||||||
string s;
|
string s;
|
||||||
s = "vt " + to_string(texture_coordinates.u) + " " + to_string(1 - texture_coordinates.v);
|
float i;
|
||||||
|
auto u = modf(fabs(texture_coordinates.u), &i);
|
||||||
|
auto v = modf(fabs(texture_coordinates.v), &i);
|
||||||
|
s = "vt " + to_string(u) + " " + to_string(1 - v);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -258,16 +267,13 @@ std::string block::printMtl() const
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string block::printObj() const
|
std::string block::printObj(int group_offset) const
|
||||||
{
|
{
|
||||||
string s;
|
string s;
|
||||||
s += "usemtl " + name + "\n";
|
s += "usemtl " + name + "\n";
|
||||||
s += "\n";
|
s += "\n";
|
||||||
// UE does not recognize russian strings in .obj
|
|
||||||
//s += string("o ") + name + "\n";
|
|
||||||
//s += string("g ") + name + "\n";
|
|
||||||
s += "g " + name + "\n";
|
s += "g " + name + "\n";
|
||||||
s += "s 1\n";
|
s += "s 1\n"; // still unk how to use
|
||||||
s += "\n";
|
s += "\n";
|
||||||
|
|
||||||
for (auto &v : vertices)
|
for (auto &v : vertices)
|
||||||
|
|
@ -284,9 +290,9 @@ std::string block::printObj() const
|
||||||
{
|
{
|
||||||
for (auto &t : faces)
|
for (auto &t : faces)
|
||||||
{
|
{
|
||||||
auto x = to_string(t.x + 1);
|
auto x = to_string(t.x + 1 + group_offset);
|
||||||
auto y = to_string(t.y + 1);
|
auto y = to_string(t.y + 1 + group_offset);
|
||||||
auto z = to_string(t.z + 1);
|
auto z = to_string(t.z + 1 + group_offset);
|
||||||
x += "/" + x + "/" + x;
|
x += "/" + x + "/" + x;
|
||||||
y += "/" + y + "/" + y;
|
y += "/" + y + "/" + y;
|
||||||
z += "/" + z + "/" + z;
|
z += "/" + z + "/" + z;
|
||||||
|
|
@ -309,7 +315,7 @@ void block::load(const buffer &b)
|
||||||
READ_STRING(b, tex_spec);
|
READ_STRING(b, tex_spec);
|
||||||
READ_STRING(b, tex3);
|
READ_STRING(b, tex3);
|
||||||
READ_STRING(b, tex4);
|
READ_STRING(b, tex4);
|
||||||
READ(b, LODs);
|
READ(b, all_lods);
|
||||||
READ(b, unk2);
|
READ(b, unk2);
|
||||||
READ(b, unk3);
|
READ(b, unk3);
|
||||||
READ(b, size);
|
READ(b, size);
|
||||||
|
|
@ -414,11 +420,18 @@ void model::print(const std::string &fn)
|
||||||
auto mtl_fn = fn + ".mtl";
|
auto mtl_fn = fn + ".mtl";
|
||||||
ofstream m(mtl_fn);
|
ofstream m(mtl_fn);
|
||||||
title(m);
|
title(m);
|
||||||
|
|
||||||
|
int n_vert = 0;
|
||||||
for (auto &b : blocks)
|
for (auto &b : blocks)
|
||||||
{
|
{
|
||||||
if (b.type == BlockType::ParticleEmitter)
|
if (b.type == BlockType::ParticleEmitter)
|
||||||
return;
|
continue;
|
||||||
o << b.printObj() << "\n";
|
if (b.type != BlockType::VisibleObject)
|
||||||
|
continue;
|
||||||
|
if (!(b.all_lods == 15 || b.LODs.lod1))
|
||||||
|
continue;
|
||||||
|
o << b.printObj(n_vert) << "\n";
|
||||||
m << b.printMtl() << "\n";
|
m << b.printMtl() << "\n";
|
||||||
|
n_vert += b.n_vertex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ enum
|
||||||
enum class AdditionalParameter : uint32_t
|
enum class AdditionalParameter : uint32_t
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
DetalizationCoefficient
|
DetalizationCoefficient,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class ModelRotation : uint32_t
|
enum class ModelRotation : uint32_t
|
||||||
|
|
@ -40,7 +40,7 @@ enum class ModelRotation : uint32_t
|
||||||
None,
|
None,
|
||||||
Vertical,
|
Vertical,
|
||||||
Horizontal,
|
Horizontal,
|
||||||
Other
|
Other,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class BlockType : uint32_t
|
enum class BlockType : uint32_t
|
||||||
|
|
@ -49,7 +49,7 @@ enum class BlockType : uint32_t
|
||||||
HelperObject,
|
HelperObject,
|
||||||
BitmapAlpha,
|
BitmapAlpha,
|
||||||
BitmapGrass,
|
BitmapGrass,
|
||||||
ParticleEmitter
|
ParticleEmitter,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class EffectType : uint32_t
|
enum class EffectType : uint32_t
|
||||||
|
|
@ -62,12 +62,16 @@ enum class EffectType : uint32_t
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct aim_vector3
|
struct vector3
|
||||||
{
|
{
|
||||||
T x;
|
T x;
|
||||||
T y;
|
T y;
|
||||||
T z;
|
T z;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct aim_vector3 : vector3<T>
|
||||||
|
{
|
||||||
void load(const buffer &b);
|
void load(const buffer &b);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -161,10 +165,7 @@ struct rotation
|
||||||
{
|
{
|
||||||
ModelRotation type;
|
ModelRotation type;
|
||||||
float speed;
|
float speed;
|
||||||
// center of rotating axis
|
vector3<float> center_of_rotating_axis;
|
||||||
float x;
|
|
||||||
float y; // z?
|
|
||||||
float z; // y?
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct additional_parameters
|
struct additional_parameters
|
||||||
|
|
@ -191,8 +192,8 @@ struct block
|
||||||
uint8_t lod3 : 1;
|
uint8_t lod3 : 1;
|
||||||
uint8_t lod4 : 1;
|
uint8_t lod4 : 1;
|
||||||
uint8_t : 4;
|
uint8_t : 4;
|
||||||
} _;
|
} LODs;
|
||||||
uint32_t LODs;
|
uint32_t all_lods;
|
||||||
};
|
};
|
||||||
|
|
||||||
// data
|
// data
|
||||||
|
|
@ -235,7 +236,7 @@ struct block
|
||||||
|
|
||||||
void load(const buffer &b);
|
void load(const buffer &b);
|
||||||
std::string printMtl() const;
|
std::string printMtl() const;
|
||||||
std::string printObj() const;
|
std::string printObj(int group_offset) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct model
|
struct model
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue