diff --git a/src/OpenMesh/Core/IO/reader/PLYReader.cc b/src/OpenMesh/Core/IO/reader/PLYReader.cc index b64f3fc0..f7497069 100644 --- a/src/OpenMesh/Core/IO/reader/PLYReader.cc +++ b/src/OpenMesh/Core/IO/reader/PLYReader.cc @@ -179,7 +179,7 @@ bool _PLYReader_::read_ascii(std::istream& _in, BaseImporter& _bi) const { unsigned int i, j, k, l, idx; unsigned int nV; - OpenMesh::Vec3f v; + OpenMesh::Vec3f v, n; std::string trash; OpenMesh::Vec2f t; OpenMesh::Vec4i c; @@ -200,6 +200,10 @@ bool _PLYReader_::read_ascii(std::istream& _in, BaseImporter& _bi) const { v[1] = 0.0; v[2] = 0.0; + n[0] = 0.0; + n[1] = 0.0; + n[2] = 0.0; + t[0] = 0.0; t[1] = 0.0; @@ -219,6 +223,15 @@ bool _PLYReader_::read_ascii(std::istream& _in, BaseImporter& _bi) const { case ZCOORD: _in >> v[2]; break; + case XNORM: + _in >> n[0]; + break; + case YNORM: + _in >> n[1]; + break; + case ZNORM: + _in >> n[2]; + break; case TEXX: _in >> t[0]; break; @@ -264,6 +277,7 @@ bool _PLYReader_::read_ascii(std::istream& _in, BaseImporter& _bi) const { } vh = _bi.add_vertex(v); + _bi.set_normal(vh, n); _bi.set_texcoord(vh, t); _bi.set_color(vh, Vec4uc(c)); } @@ -313,7 +327,7 @@ bool _PLYReader_::read_binary(std::istream& _in, BaseImporter& _bi, bool /*_swap unsigned int i, j, k, l, idx; unsigned int nV; - OpenMesh::Vec3f v; // Vertex + OpenMesh::Vec3f v, n; // Vertex OpenMesh::Vec2f t; // TexCoords BaseImporter::VHandles vhandles; VertexHandle vh; @@ -328,6 +342,10 @@ bool _PLYReader_::read_binary(std::istream& _in, BaseImporter& _bi, bool /*_swap v[1] = 0.0; v[2] = 0.0; + n[0] = 0.0; + n[1] = 0.0; + n[2] = 0.0; + t[0] = 0.0; t[1] = 0.0; @@ -347,6 +365,15 @@ bool _PLYReader_::read_binary(std::istream& _in, BaseImporter& _bi, bool /*_swap case ZCOORD: readValue(vertexPropertyMap_[propertyIndex].second, _in, v[2]); break; + case XNORM: + readValue(vertexPropertyMap_[propertyIndex].second, _in, n[0]); + break; + case YNORM: + readValue(vertexPropertyMap_[propertyIndex].second, _in, n[1]); + break; + case ZNORM: + readValue(vertexPropertyMap_[propertyIndex].second, _in, n[2]); + break; case TEXX: readValue(vertexPropertyMap_[propertyIndex].second, _in, t[0]); break; @@ -399,6 +426,7 @@ bool _PLYReader_::read_binary(std::istream& _in, BaseImporter& _bi, bool /*_swap } vh = _bi.add_vertex(v); + _bi.set_normal(vh, n); _bi.set_texcoord(vh, t); _bi.set_color(vh, Vec4uc(c)); } @@ -936,6 +964,18 @@ bool _PLYReader_::can_u_read(std::istream& _is) const { std::pair entry(ZCOORD, valueType); vertexPropertyMap_[vertexPropertyCount_] = entry; vertexDimension_++; + } else if (propertyName == "nx") { + std::pair entry(XNORM, valueType); + vertexPropertyMap_[vertexPropertyCount_] = entry; + options_ += Options::VertexNormal; + } else if (propertyName == "ny") { + std::pair entry(YNORM, valueType); + vertexPropertyMap_[vertexPropertyCount_] = entry; + options_ += Options::VertexNormal; + } else if (propertyName == "nz") { + std::pair entry(ZNORM, valueType); + vertexPropertyMap_[vertexPropertyCount_] = entry; + options_ += Options::VertexNormal; } else if (propertyName == "u" || propertyName == "s") { std::pair entry(TEXX, valueType); vertexPropertyMap_[vertexPropertyCount_] = entry; diff --git a/src/OpenMesh/Core/IO/reader/PLYReader.hh b/src/OpenMesh/Core/IO/reader/PLYReader.hh index 5332fcb3..560b7ab2 100644 --- a/src/OpenMesh/Core/IO/reader/PLYReader.hh +++ b/src/OpenMesh/Core/IO/reader/PLYReader.hh @@ -164,6 +164,7 @@ private: XCOORD,YCOORD,ZCOORD, TEXX,TEXY, COLORRED,COLORGREEN,COLORBLUE,COLORALPHA, + XNORM,YNORM,ZNORM, UNSUPPORTED };