root/OpenSceneGraph/branches/OpenSceneGraph-2.8/src/osgPlugins/ply/vertexData.h
@
11274
| Revision 11274, 2.1 kB (checked in by paulmartz, 3 years ago) |
|---|
| Line | |
|---|---|
| 1 | /* |
| 2 | vertexData.h |
| 3 | Copyright (c) 2007, Tobias Wolf <twolf@access.unizh.ch> |
| 4 | All rights reserved. |
| 5 | |
| 6 | Header file of the VertexData class. |
| 7 | */ |
| 8 | |
| 9 | /** note, derived from Equalizer LGPL source.*/ |
| 10 | |
| 11 | |
| 12 | #ifndef MESH_VERTEXDATA_H |
| 13 | #define MESH_VERTEXDATA_H |
| 14 | |
| 15 | |
| 16 | #include <osg/Node> |
| 17 | #include <osg/PrimitiveSet> |
| 18 | |
| 19 | #include <vector> |
| 20 | |
| 21 | /////////////////////////////////////////////////////////////////////////////// |
| 22 | //! |
| 23 | //! \class VertexData |
| 24 | //! \brief helps to read ply file and converts in to osg::Node format |
| 25 | //! |
| 26 | /////////////////////////////////////////////////////////////////////////////// |
| 27 | |
| 28 | // defined elsewhere |
| 29 | struct PlyFile; |
| 30 | |
| 31 | namespace ply |
| 32 | { |
| 33 | /* Holds the flat data and offers routines to read, scale and sort it. */ |
| 34 | class VertexData |
| 35 | { |
| 36 | public: |
| 37 | // Default constructor |
| 38 | VertexData(); |
| 39 | |
| 40 | // Reads ply file and convert in to osg::Node and returns the same |
| 41 | osg::Node* readPlyFile( const char* file, const bool ignoreColors = false ); |
| 42 | |
| 43 | // to set the flag for using inverted face |
| 44 | void useInvertedFaces() { _invertFaces = true; } |
| 45 | |
| 46 | private: |
| 47 | // Function which reads all the vertices and colors if color info is |
| 48 | // given and also if the user wants that information |
| 49 | void readVertices( PlyFile* file, const int nVertices, |
| 50 | const bool readColors ); |
| 51 | |
| 52 | // Reads the triangle indices from the ply file |
| 53 | void readTriangles( PlyFile* file, const int nFaces ); |
| 54 | |
| 55 | // Calculates the normals according to passed flag |
| 56 | // if vertexNormals is true then computes normal per vertices |
| 57 | // otherwise per triangle means per face |
| 58 | void _calculateNormals( const bool vertexNormals = true ); |
| 59 | |
| 60 | bool _invertFaces; |
| 61 | |
| 62 | // Vertex array in osg format |
| 63 | osg::ref_ptr<osg::Vec3Array> _vertices; |
| 64 | // Color array in osg format |
| 65 | osg::ref_ptr<osg::Vec4Array> _colors; |
| 66 | // Normals in osg format |
| 67 | osg::ref_ptr<osg::Vec3Array> _normals; |
| 68 | // The indices of the faces in premitive set |
| 69 | osg::ref_ptr<osg::DrawElementsUInt> _triangles; |
| 70 | }; |
| 71 | } |
| 72 | |
| 73 | |
| 74 | #endif // MESH_VERTEXDATA_H |
Note: See TracBrowser
for help on using the browser.
