mirror of
https://github.com/aimrebirth/tools.git
synced 2026-04-15 01:43:25 +00:00
Disable link faces by default as uvs work is not over. Restore basic link faces.
This commit is contained in:
parent
33787f94ae
commit
3b614b2da1
4 changed files with 44 additions and 33 deletions
|
|
@ -277,7 +277,7 @@ static FbxMesh *create_mesh(FbxScene *s, const block &b)
|
||||||
{
|
{
|
||||||
auto uv = m->CreateElementUV("uv", FbxLayerElement::eTextureDiffuse);
|
auto uv = m->CreateElementUV("uv", FbxLayerElement::eTextureDiffuse);
|
||||||
uv->SetMappingMode(FbxGeometryElement::eByControlPoint);
|
uv->SetMappingMode(FbxGeometryElement::eByControlPoint);
|
||||||
uv->SetReferenceMode(FbxGeometryElement::eDirect);
|
uv->SetReferenceMode(FbxGeometryElement::eDirect); // not needed?
|
||||||
for (const auto &[u,v] : b.pmd.uvs)
|
for (const auto &[u,v] : b.pmd.uvs)
|
||||||
uv->GetDirectArray().Add(FbxVector2(u, v));
|
uv->GetDirectArray().Add(FbxVector2(u, v));
|
||||||
//float f;
|
//float f;
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,8 @@ bool printMaxPolygonBlock = false;
|
||||||
|
|
||||||
cl::opt<path> p(cl::Positional, cl::desc("<MOD_ file or directory with MOD_ files or .mod file saved from AIM2 SDK viewer>"), cl::value_desc("file or directory"), cl::Required);
|
cl::opt<path> p(cl::Positional, cl::desc("<MOD_ file or directory with MOD_ files or .mod file saved from AIM2 SDK viewer>"), cl::value_desc("file or directory"), cl::Required);
|
||||||
cl::opt<bool> all_formats("af", cl::desc("All formats (.obj, .fbx)"));
|
cl::opt<bool> all_formats("af", cl::desc("All formats (.obj, .fbx)"));
|
||||||
cl::opt<bool> link_faces("lf", cl::desc("Link faces (default: true)"), cl::init(true));
|
// link_faces is not currently complete, after processing we have bad uvs
|
||||||
|
cl::opt<bool> link_faces("lf", cl::desc("Link faces (default: true)")/*, cl::init(true)*/);
|
||||||
|
|
||||||
yaml root;
|
yaml root;
|
||||||
cl::opt<bool> stats("i", cl::desc("Gather information from (models)"));
|
cl::opt<bool> stats("i", cl::desc("Gather information from (models)"));
|
||||||
|
|
|
||||||
|
|
@ -324,19 +324,25 @@ static std::string printTex(const uv &texture_coordinates)
|
||||||
std::string processed_model_data::print(int group_offset, AxisSystem as) const
|
std::string processed_model_data::print(int group_offset, AxisSystem as) const
|
||||||
{
|
{
|
||||||
std::string s;
|
std::string s;
|
||||||
|
|
||||||
|
//
|
||||||
s += "# " + std::to_string(vertices.size()) + " vertices\n";
|
s += "# " + std::to_string(vertices.size()) + " vertices\n";
|
||||||
for (auto &v : vertices)
|
for (auto &v : vertices)
|
||||||
s += printVertex(v, as) + "\n";
|
s += printVertex(v, as) + "\n";
|
||||||
s += "\n";
|
s += "\n";
|
||||||
s += "# " + std::to_string(normals.size()) + " vertex normals\n";
|
|
||||||
for (auto &n : normals)
|
//
|
||||||
s += printNormal(n, as) + "\n";
|
|
||||||
s += "\n";
|
|
||||||
s += "# " + std::to_string(uvs.size()) + " texture coords\n";
|
s += "# " + std::to_string(uvs.size()) + " texture coords\n";
|
||||||
for (auto &v : uvs)
|
for (auto &v : uvs)
|
||||||
s += printTex(v) + "\n";
|
s += printTex(v) + "\n";
|
||||||
s += "\n";
|
s += "\n";
|
||||||
|
|
||||||
|
//
|
||||||
|
s += "# " + std::to_string(normals.size()) + " vertex normals\n";
|
||||||
|
for (auto &n : normals)
|
||||||
|
s += printNormal(n, as) + "\n";
|
||||||
|
s += "\n";
|
||||||
|
|
||||||
s += "# " + std::to_string(vertices.size()) + " faces\n";
|
s += "# " + std::to_string(vertices.size()) + " faces\n";
|
||||||
for (auto &t : faces)
|
for (auto &t : faces)
|
||||||
{
|
{
|
||||||
|
|
@ -578,50 +584,52 @@ static processed_model_data linkFaces(const processed_model_data &d)
|
||||||
{
|
{
|
||||||
// reference implementation by Razum: https://pastebin.com/KewhggDj
|
// reference implementation by Razum: https://pastebin.com/KewhggDj
|
||||||
|
|
||||||
processed_model_data pmd = d;
|
processed_model_data pmd;
|
||||||
|
|
||||||
/*std::vector<vertex> vertices2;
|
pmd.vertices.reserve(d.vertices.size());
|
||||||
vertices2.reserve(vertices.size());
|
pmd.normals.reserve(d.normals.size());
|
||||||
|
pmd.uvs.reserve(d.uvs.size());
|
||||||
std::unordered_map<short, short> vrepl, trepl;
|
std::unordered_map<short, short> vrepl, trepl;
|
||||||
vrepl.reserve(vertices.size());
|
vrepl.reserve(d.vertices.size());
|
||||||
trepl.reserve(vertices.size());
|
trepl.reserve(d.vertices.size());
|
||||||
|
|
||||||
auto sz = vertices.size();
|
auto sz = d.vertices.size();
|
||||||
for (int i = 0; i < sz; i++)
|
for (int i = 0; i < sz; i++)
|
||||||
{
|
{
|
||||||
auto it = std::find_if(vertices2.begin(), vertices2.end(), [&vertices, i](auto &v1)
|
auto it = std::find(pmd.vertices.begin(), pmd.vertices.end(), d.vertices[i]);
|
||||||
|
if (it == pmd.vertices.end())
|
||||||
{
|
{
|
||||||
return (aim_vector3f&)vertices[i].coordinates == (aim_vector3f&)v1.coordinates;
|
pmd.vertices.push_back(d.vertices[i]);
|
||||||
});
|
pmd.normals.push_back(d.normals[i]); // as is for now
|
||||||
if (it == vertices2.end())
|
pmd.uvs.push_back(d.uvs[i]); // as is for now
|
||||||
{
|
vrepl[i] = pmd.vertices.size() - 1;
|
||||||
vertices2.push_back(vertices[i]);
|
|
||||||
vrepl[i] = vertices2.size() - 1;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
vrepl[i] = std::distance(vertices2.begin(), it);
|
vrepl[i] = std::distance(pmd.vertices.begin(), it);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<uv> uvs2;
|
/*uvs2.reserve(uvs.size());
|
||||||
uvs2.reserve(uvs.size());
|
|
||||||
for (auto &f : uvs)
|
for (auto &f : uvs)
|
||||||
{
|
{
|
||||||
// remove duplicates
|
// remove duplicates
|
||||||
if (std::find(uvs2.begin(), uvs2.end(), f) == uvs2.end())
|
if (std::find(uvs2.begin(), uvs2.end(), f) == uvs2.end())
|
||||||
uvs2.push_back(f);
|
uvs2.push_back(f);
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<face> faces2;
|
|
||||||
faces2.reserve(faces.size());
|
|
||||||
for (auto f : faces)
|
|
||||||
{
|
|
||||||
for (auto &v : f.vertex_list)
|
|
||||||
v = vrepl[v];
|
|
||||||
// remove duplicates
|
|
||||||
if (std::find(faces2.begin(), faces2.end(), f) == faces2.end())
|
|
||||||
faces2.push_back(f);
|
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
pmd.faces.reserve(d.faces.size());
|
||||||
|
for (auto f : d.faces)
|
||||||
|
{
|
||||||
|
for (auto &v : f.points)
|
||||||
|
{
|
||||||
|
v.vertex = vrepl[v.vertex];
|
||||||
|
v.normal = vrepl[v.normal];
|
||||||
|
v.uv = vrepl[v.uv];
|
||||||
|
}
|
||||||
|
// remove duplicates
|
||||||
|
if (std::find(pmd.faces.begin(), pmd.faces.end(), f) == pmd.faces.end())
|
||||||
|
pmd.faces.push_back(f);
|
||||||
|
}
|
||||||
|
|
||||||
return pmd;
|
return pmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -175,6 +175,8 @@ struct processed_model_data
|
||||||
};
|
};
|
||||||
|
|
||||||
point points[3];
|
point points[3];
|
||||||
|
|
||||||
|
bool operator==(const face &rhs) const { return points == rhs.points; }
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<aim_vector4> vertices;
|
std::vector<aim_vector4> vertices;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue