PLY Writer normal support (Thanks to Bruno Dutailly)
git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@478 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
@@ -326,12 +326,12 @@ 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, n; // Vertex
|
OpenMesh::Vec3f v, n; // Vertex
|
||||||
OpenMesh::Vec2f t; // TexCoords
|
OpenMesh::Vec2f t; // TexCoords
|
||||||
BaseImporter::VHandles vhandles;
|
BaseImporter::VHandles vhandles;
|
||||||
VertexHandle vh;
|
VertexHandle vh;
|
||||||
OpenMesh::Vec4i c; // Color
|
OpenMesh::Vec4i c; // Color
|
||||||
float tmp;
|
float tmp;
|
||||||
|
|
||||||
_bi.reserve(vertexCount_, 3* vertexCount_ , faceCount_);
|
_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 y" << std::endl;
|
||||||
_out << "property float32 z" << 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() ){
|
if ( _opt.vertex_has_texcoord() ){
|
||||||
_out << "property float32 u" << std::endl;
|
_out << "property float32 u" << std::endl;
|
||||||
_out << "property float32 v" << std::endl;
|
_out << "property float32 v" << std::endl;
|
||||||
@@ -214,6 +220,12 @@ write_ascii(std::ostream& _out, BaseExporter& _be, Options _opt) const
|
|||||||
//Vertex
|
//Vertex
|
||||||
_out << v[0] << " " << v[1] << " " << v[2];
|
_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
|
// Vertex TexCoords
|
||||||
if ( _opt.vertex_has_texcoord() ) {
|
if ( _opt.vertex_has_texcoord() ) {
|
||||||
t = _be.texcoord(vh);
|
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 x" << std::endl;
|
||||||
_out << "property float32 y" << std::endl;
|
_out << "property float32 y" << std::endl;
|
||||||
_out << "property float32 z" << 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() ){
|
if ( _opt.vertex_has_texcoord() ){
|
||||||
_out << "property float32 u" << std::endl;
|
_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[1]);
|
||||||
writeValue(ValueTypeFLOAT, _out, v[2]);
|
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
|
// Vertex TexCoords
|
||||||
if ( _opt.vertex_has_texcoord() ) {
|
if ( _opt.vertex_has_texcoord() ) {
|
||||||
t = _be.texcoord(vh);
|
t = _be.texcoord(vh);
|
||||||
|
|||||||
Reference in New Issue
Block a user