root/OpenSceneGraph/trunk/src/osgPlugins/ply/vertexData.h
@
13041
| Revision 13041, 2.4 kB (checked in by robert, 14 months 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 | |
| 41 | // Reads ply file and convert in to osg::Node and returns the same |
| 42 | osg::Node* readPlyFile( const char* file, const bool ignoreColors = false ); |
| 43 | |
| 44 | // to set the flag for using inverted face |
| 45 | void useInvertedFaces() { _invertFaces = true; } |
| 46 | |
| 47 | private: |
| 48 | |
| 49 | enum VertexFields |
| 50 | { |
| 51 | NONE = 0, |
| 52 | XYZ = 1, |
| 53 | NORMALS = 2, |
| 54 | RGB = 4, |
| 55 | AMBIENT = 8, |
| 56 | DIFFUSE = 16, |
| 57 | SPECULAR = 32 |
| 58 | }; |
| 59 | |
| 60 | // Function which reads all the vertices and colors if color info is |
| 61 | // given and also if the user wants that information |
| 62 | void readVertices( PlyFile* file, const int nVertices, |
| 63 | const int vertexFields ); |
| 64 | |
| 65 | // Reads the triangle indices from the ply file |
| 66 | void readTriangles( PlyFile* file, const int nFaces ); |
| 67 | |
| 68 | // Calculates the normals according to passed flag |
| 69 | // if vertexNormals is true then computes normal per vertices |
| 70 | // otherwise per triangle means per face |
| 71 | void _calculateNormals( const bool vertexNormals = true ); |
| 72 | |
| 73 | bool _invertFaces; |
| 74 | |
| 75 | // Vertex array in osg format |
| 76 | osg::ref_ptr<osg::Vec3Array> _vertices; |
| 77 | // Color array in osg format |
| 78 | osg::ref_ptr<osg::Vec4Array> _colors; |
| 79 | osg::ref_ptr<osg::Vec4Array> _ambient; |
| 80 | osg::ref_ptr<osg::Vec4Array> _diffuse; |
| 81 | osg::ref_ptr<osg::Vec4Array> _specular; |
| 82 | |
| 83 | // Normals in osg format |
| 84 | osg::ref_ptr<osg::Vec3Array> _normals; |
| 85 | // The indices of the faces in premitive set |
| 86 | osg::ref_ptr<osg::DrawElementsUInt> _triangles; |
| 87 | }; |
| 88 | } |
| 89 | |
| 90 | |
| 91 | #endif // MESH_VERTEXDATA_H |
Note: See TracBrowser
for help on using the browser.
