Support normals in ply format
git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@463 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
@@ -179,7 +179,7 @@ bool _PLYReader_::read_ascii(std::istream& _in, BaseImporter& _bi) const {
|
|||||||
|
|
||||||
unsigned int i, j, k, l, idx;
|
unsigned int i, j, k, l, idx;
|
||||||
unsigned int nV;
|
unsigned int nV;
|
||||||
OpenMesh::Vec3f v;
|
OpenMesh::Vec3f v, n;
|
||||||
std::string trash;
|
std::string trash;
|
||||||
OpenMesh::Vec2f t;
|
OpenMesh::Vec2f t;
|
||||||
OpenMesh::Vec4i c;
|
OpenMesh::Vec4i c;
|
||||||
@@ -200,6 +200,10 @@ bool _PLYReader_::read_ascii(std::istream& _in, BaseImporter& _bi) const {
|
|||||||
v[1] = 0.0;
|
v[1] = 0.0;
|
||||||
v[2] = 0.0;
|
v[2] = 0.0;
|
||||||
|
|
||||||
|
n[0] = 0.0;
|
||||||
|
n[1] = 0.0;
|
||||||
|
n[2] = 0.0;
|
||||||
|
|
||||||
t[0] = 0.0;
|
t[0] = 0.0;
|
||||||
t[1] = 0.0;
|
t[1] = 0.0;
|
||||||
|
|
||||||
@@ -219,6 +223,15 @@ bool _PLYReader_::read_ascii(std::istream& _in, BaseImporter& _bi) const {
|
|||||||
case ZCOORD:
|
case ZCOORD:
|
||||||
_in >> v[2];
|
_in >> v[2];
|
||||||
break;
|
break;
|
||||||
|
case XNORM:
|
||||||
|
_in >> n[0];
|
||||||
|
break;
|
||||||
|
case YNORM:
|
||||||
|
_in >> n[1];
|
||||||
|
break;
|
||||||
|
case ZNORM:
|
||||||
|
_in >> n[2];
|
||||||
|
break;
|
||||||
case TEXX:
|
case TEXX:
|
||||||
_in >> t[0];
|
_in >> t[0];
|
||||||
break;
|
break;
|
||||||
@@ -264,6 +277,7 @@ bool _PLYReader_::read_ascii(std::istream& _in, BaseImporter& _bi) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
vh = _bi.add_vertex(v);
|
vh = _bi.add_vertex(v);
|
||||||
|
_bi.set_normal(vh, n);
|
||||||
_bi.set_texcoord(vh, t);
|
_bi.set_texcoord(vh, t);
|
||||||
_bi.set_color(vh, Vec4uc(c));
|
_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 i, j, k, l, idx;
|
||||||
unsigned int nV;
|
unsigned int nV;
|
||||||
OpenMesh::Vec3f v; // Vertex
|
OpenMesh::Vec3f v, n; // Vertex
|
||||||
OpenMesh::Vec2f t; // TexCoords
|
OpenMesh::Vec2f t; // TexCoords
|
||||||
BaseImporter::VHandles vhandles;
|
BaseImporter::VHandles vhandles;
|
||||||
VertexHandle vh;
|
VertexHandle vh;
|
||||||
@@ -328,6 +342,10 @@ bool _PLYReader_::read_binary(std::istream& _in, BaseImporter& _bi, bool /*_swap
|
|||||||
v[1] = 0.0;
|
v[1] = 0.0;
|
||||||
v[2] = 0.0;
|
v[2] = 0.0;
|
||||||
|
|
||||||
|
n[0] = 0.0;
|
||||||
|
n[1] = 0.0;
|
||||||
|
n[2] = 0.0;
|
||||||
|
|
||||||
t[0] = 0.0;
|
t[0] = 0.0;
|
||||||
t[1] = 0.0;
|
t[1] = 0.0;
|
||||||
|
|
||||||
@@ -347,6 +365,15 @@ bool _PLYReader_::read_binary(std::istream& _in, BaseImporter& _bi, bool /*_swap
|
|||||||
case ZCOORD:
|
case ZCOORD:
|
||||||
readValue(vertexPropertyMap_[propertyIndex].second, _in, v[2]);
|
readValue(vertexPropertyMap_[propertyIndex].second, _in, v[2]);
|
||||||
break;
|
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:
|
case TEXX:
|
||||||
readValue(vertexPropertyMap_[propertyIndex].second, _in, t[0]);
|
readValue(vertexPropertyMap_[propertyIndex].second, _in, t[0]);
|
||||||
break;
|
break;
|
||||||
@@ -399,6 +426,7 @@ bool _PLYReader_::read_binary(std::istream& _in, BaseImporter& _bi, bool /*_swap
|
|||||||
}
|
}
|
||||||
|
|
||||||
vh = _bi.add_vertex(v);
|
vh = _bi.add_vertex(v);
|
||||||
|
_bi.set_normal(vh, n);
|
||||||
_bi.set_texcoord(vh, t);
|
_bi.set_texcoord(vh, t);
|
||||||
_bi.set_color(vh, Vec4uc(c));
|
_bi.set_color(vh, Vec4uc(c));
|
||||||
}
|
}
|
||||||
@@ -936,6 +964,18 @@ bool _PLYReader_::can_u_read(std::istream& _is) const {
|
|||||||
std::pair<VertexProperty, ValueType> entry(ZCOORD, valueType);
|
std::pair<VertexProperty, ValueType> entry(ZCOORD, valueType);
|
||||||
vertexPropertyMap_[vertexPropertyCount_] = entry;
|
vertexPropertyMap_[vertexPropertyCount_] = entry;
|
||||||
vertexDimension_++;
|
vertexDimension_++;
|
||||||
|
} else if (propertyName == "nx") {
|
||||||
|
std::pair<VertexProperty, ValueType> entry(XNORM, valueType);
|
||||||
|
vertexPropertyMap_[vertexPropertyCount_] = entry;
|
||||||
|
options_ += Options::VertexNormal;
|
||||||
|
} else if (propertyName == "ny") {
|
||||||
|
std::pair<VertexProperty, ValueType> entry(YNORM, valueType);
|
||||||
|
vertexPropertyMap_[vertexPropertyCount_] = entry;
|
||||||
|
options_ += Options::VertexNormal;
|
||||||
|
} else if (propertyName == "nz") {
|
||||||
|
std::pair<VertexProperty, ValueType> entry(ZNORM, valueType);
|
||||||
|
vertexPropertyMap_[vertexPropertyCount_] = entry;
|
||||||
|
options_ += Options::VertexNormal;
|
||||||
} else if (propertyName == "u" || propertyName == "s") {
|
} else if (propertyName == "u" || propertyName == "s") {
|
||||||
std::pair<VertexProperty, ValueType> entry(TEXX, valueType);
|
std::pair<VertexProperty, ValueType> entry(TEXX, valueType);
|
||||||
vertexPropertyMap_[vertexPropertyCount_] = entry;
|
vertexPropertyMap_[vertexPropertyCount_] = entry;
|
||||||
|
|||||||
@@ -164,6 +164,7 @@ private:
|
|||||||
XCOORD,YCOORD,ZCOORD,
|
XCOORD,YCOORD,ZCOORD,
|
||||||
TEXX,TEXY,
|
TEXX,TEXY,
|
||||||
COLORRED,COLORGREEN,COLORBLUE,COLORALPHA,
|
COLORRED,COLORGREEN,COLORBLUE,COLORALPHA,
|
||||||
|
XNORM,YNORM,ZNORM,
|
||||||
UNSUPPORTED
|
UNSUPPORTED
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user