Commit 73f5a1fe authored by Jan Möbius's avatar Jan Möbius

PLY Writer normal support (Thanks to Bruno Dutailly)


git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@478 fdac6126-5c0c-442c-9429-916003d36597
parent 7d092c74
......@@ -326,12 +326,12 @@ bool _PLYReader_::read_binary(std::istream& _in, BaseImporter& _bi, bool /*_swap
unsigned int i, j, k, l, idx;
unsigned int nV;
OpenMesh::Vec3f v, n; // Vertex
OpenMesh::Vec2f t; // TexCoords
OpenMesh::Vec3f v, n; // Vertex
OpenMesh::Vec2f t; // TexCoords
BaseImporter::VHandles vhandles;
VertexHandle vh;
OpenMesh::Vec4i c; // Color
float tmp;
VertexHandle vh;
OpenMesh::Vec4i c; // Color
float tmp;
_bi.reserve(vertexCount_, 3* vertexCount_ , faceCount_);
......
......@@ -187,6 +187,12 @@ write_ascii(std::ostream& _out, BaseExporter& _be, Options _opt) const
_out << "property float32 y" << std::endl;
_out << "property float32 z" << std::endl;
if ( _opt.vertex_has_normal() ){
_out << "property float32 nx" << std::endl;
_out << "property float32 ny" << std::endl;
_out << "property float32 nz" << std::endl;
}
if ( _opt.vertex_has_texcoord() ){
_out << "property float32 u" << std::endl;
_out << "property float32 v" << std::endl;
......@@ -214,6 +220,12 @@ write_ascii(std::ostream& _out, BaseExporter& _be, Options _opt) const
//Vertex
_out << v[0] << " " << v[1] << " " << v[2];
// Vertex Normals
if ( _opt.vertex_has_normal() ){
n = _be.normal(vh);
_out << " " << n[0] << " " << n[1] << " " << n[2];
}
// Vertex TexCoords
if ( _opt.vertex_has_texcoord() ) {
t = _be.texcoord(vh);
......@@ -384,6 +396,12 @@ write_binary(std::ostream& _out, BaseExporter& _be, Options _opt) const
_out << "property float32 x" << std::endl;
_out << "property float32 y" << std::endl;
_out << "property float32 z" << std::endl;
if ( _opt.vertex_has_normal() ){
_out << "property float32 nx" << std::endl;
_out << "property float32 ny" << std::endl;
_out << "property float32 nz" << std::endl;
}
if ( _opt.vertex_has_texcoord() ){
_out << "property float32 u" << std::endl;
......@@ -414,6 +432,14 @@ write_binary(std::ostream& _out, BaseExporter& _be, Options _opt) const
writeValue(ValueTypeFLOAT, _out, v[1]);
writeValue(ValueTypeFLOAT, _out, v[2]);
// Vertex Normal
if ( _opt.vertex_has_normal() ){
n = _be.normal(vh);
writeValue(ValueTypeFLOAT, _out, n[0]);
writeValue(ValueTypeFLOAT, _out, n[1]);
writeValue(ValueTypeFLOAT, _out, n[2]);
}
// Vertex TexCoords
if ( _opt.vertex_has_texcoord() ) {
t = _be.texcoord(vh);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment