From 28105bacc15c7bf136046b81cc804e47389d0a49 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 17 Mar 2010 14:32:32 +0000 Subject: [PATCH] From Glenn Waldron, "The PLY plugin only works for a file that includes both vertices and faces. This patch adds support for PLY files that include only vertices (a point cloud)." --- src/osgPlugins/ply/vertexData.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/osgPlugins/ply/vertexData.cpp b/src/osgPlugins/ply/vertexData.cpp index 0dc784d99..13ad93b64 100644 --- a/src/osgPlugins/ply/vertexData.cpp +++ b/src/osgPlugins/ply/vertexData.cpp @@ -252,6 +252,8 @@ osg::Node* VertexData::readPlyFile( const char* filename, const bool ignoreColor { MESHASSERT( _colors->size() == static_cast< size_t >( nElems ) ); } + + result = true; } catch( exception& e ) { @@ -305,16 +307,21 @@ osg::Node* VertexData::readPlyFile( const char* filename, const bool ignoreColor geom->setVertexArray(_vertices.get()); // If the normals are not calculated calculate the normals for faces - if(!_normals.valid()) - _calculateNormals(); + if(_triangles.valid()) + { + if(!_normals.valid()) + _calculateNormals(); - - // set the normals - geom->setNormalArray(_normals.get()); - geom->setNormalBinding(osg::Geometry::BIND_PER_VERTEX); + // set the normals + geom->setNormalArray(_normals.get()); + geom->setNormalBinding(osg::Geometry::BIND_PER_VERTEX); + } // Add the premetive set - geom->addPrimitiveSet(_triangles.get()); + if (_triangles.valid() && _triangles->size() > 0 ) + geom->addPrimitiveSet(_triangles.get()); + else + geom->addPrimitiveSet(new osg::DrawArrays(GL_POINTS, 0, _vertices->size())); // if color info is given set the color array if(_colors.valid())