Skip to content

Commit

Permalink
support proper per vertex texture.
Browse files Browse the repository at this point in the history
  • Loading branch information
ponchio committed Oct 3, 2024
1 parent ae6bf86 commit a0558ea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/nxsbuild/plyloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,10 @@ void PlyLoader::init() {
error = pf.AddToRead(plyprop1[13]);
pf.AddToRead(plyprop1[14]);

if(error == vcg::ply::E_NOERROR)
if(error == vcg::ply::E_NOERROR) {
has_textures = true;
has_vertex_tex_coords = true;
}

//these calls will fail silently if no normal is present
if(!has_faces) { //skip normals for triangle mesh
Expand Down Expand Up @@ -303,14 +305,15 @@ quint32 PlyLoader::getTriangles(quint32 size, Triangle *buffer) {
if(v < 0 || v >= nVertices())
throw QString("Bad index in triangle list.");
Vertex &vertex = vertices[face.f[k]];
vertex.t[0] = face.t[k*2];
vertex.t[1] = face.t[k*2+1];
if(!has_vertex_tex_coords) {
vertex.t[0] = face.t[k*2];
vertex.t[1] = face.t[k*2+1];
}

if (has_textures) {
float n;
vertex.t[0] = modf(vertex.t[0], &n);
vertex.t[1] = modf(vertex.t[1], &n);

}

current.vertices[k] = vertex;
Expand Down
1 change: 1 addition & 0 deletions src/nxsbuild/plyloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class PlyLoader: public MeshLoader {
private:
vcg::ply::PlyFile pf;
bool double_coords = false;
bool has_vertex_tex_coords = false;
qint64 vertices_element;
qint64 faces_element;

Expand Down

0 comments on commit a0558ea

Please sign in to comment.