MeshBuffer.hpp
Go to the documentation of this file.
1 
28 #ifndef MESHBUFFER2_HPP
29 #define MESHBUFFER2_HPP
30 
32 #include "lvr2/texture/Texture.hpp"
34 
35 namespace lvr2
36 {
37 
41 class MeshBuffer : public BaseBuffer
42 {
43  using base = BaseBuffer;
44 public:
45 
50  MeshBuffer();
51 
53  return this->removeFloatChannel("vertices");
54  }
55 
61  void setVertices(floatArr vertices, size_t n);
62 
67  void setVertexNormals(floatArr normals);
68 
74  void setVertexColors(ucharArr colors, size_t w = 3);
75 
80  void setTextureCoordinates(floatArr coordinates);
81 
88  void setFaceIndices(indexArray indices, size_t n);
89 
96  void setFaceMaterialIndices(indexArray indices);
97 
104  void setFaceNormals(floatArr normals);
105 
111  void setFaceColors(ucharArr colors, size_t w = 3);
112 
113  void setTextures(std::vector<Texture>& textures)
114  {
115  m_textures = std::move(textures);
116  }
117 
118  void setMaterials(std::vector<Material>& materials)
119  {
120  m_materials = std::move(materials);
121  }
122 
126  size_t numVertices() const;
127 
131  size_t numFaces() const;
132 
133 
138 
145  ucharArr getVertexColors(size_t& width);
146 
152 
159 
165 
170 
177  ucharArr getFaceColors(size_t& width);
178 
183 
187  std::vector<Texture>& getTextures();
188 
192  std::vector<Material>& getMaterials();
193 
194  bool hasVertices() const;
195 
196  bool hasFaces() const;
197 
198  bool hasFaceColors() const;
199 
200  bool hasVertexColors() const;
201 
202  bool hasFaceNormals() const;
203 
204  bool hasVertexNormals() const;
205 
207 
208 private:
209 
211  std::vector<Material> m_materials;
212 
214  std::vector<Texture> m_textures;
215 };
216 
217 using MeshBufferPtr = std::shared_ptr<MeshBuffer>;
218 
219 }
220 #endif // MESHBUFFER2_HPP
void setFaceIndices(indexArray indices, size_t n)
addFaceIndices Adds the face index array that references to the vertex array
Definition: MeshBuffer.cpp:91
void setMaterials(std::vector< Material > &materials)
Definition: MeshBuffer.hpp:118
bool removeVertices()
Definition: MeshBuffer.hpp:52
std::shared_ptr< MeshBuffer > MeshBufferPtr
Definition: MeshBuffer.hpp:217
void setFaceNormals(floatArr normals)
addFaceNormals Adds face normal information. The number of normals in the array are exspected to matc...
Definition: MeshBuffer.cpp:112
ucharArr getFaceColors(size_t &width)
getFaceColors Returns an array with wrgb colors
Definition: MeshBuffer.cpp:206
std::vector< Material > & getMaterials()
getTextures Returns a vector with materials
Definition: MeshBuffer.cpp:225
floatArr getTextureCoordinates()
getTextureCoordinates Returns an array with texture coordinates. Two normalized floats per vertex...
Definition: MeshBuffer.cpp:192
void setVertexColors(ucharArr colors, size_t w=3)
addVertexColors Adds vertex color information.
Definition: MeshBuffer.cpp:65
std::vector< Texture > & getTextures()
getTextures Returns a vector with textures
Definition: MeshBuffer.cpp:220
void setTextureCoordinates(floatArr coordinates)
addTextureCoordinates Adds texture coordinates for vertices
Definition: MeshBuffer.cpp:78
ucharArr getVertexColors(size_t &width)
getVertexColors Returns vertex color information or an empty array if vertex colors are not available...
Definition: MeshBuffer.cpp:171
indexArray getFaceIndices()
getFaceIndices Returns an array with face definitions, i.e., three vertex indices per face...
Definition: MeshBuffer.cpp:199
boost::shared_array< unsigned char > ucharArr
Definition: DataStruct.hpp:137
void setTextures(std::vector< Texture > &textures)
Definition: MeshBuffer.hpp:113
floatArr getVertices()
getVertices Return the vertex array.
Definition: MeshBuffer.cpp:164
bool hasFaceNormals() const
Definition: MeshBuffer.cpp:270
std::vector< Texture > m_textures
Vector containing all textures.
Definition: MeshBuffer.hpp:214
bool hasVertices() const
Definition: MeshBuffer.cpp:230
void setFaceMaterialIndices(indexArray indices)
addFaceMaterialIndices Adds face material indices. The array references to material definitions in m_...
Definition: MeshBuffer.cpp:99
bool hasVertexNormals() const
Definition: MeshBuffer.cpp:280
boost::shared_array< unsigned int > indexArray
Definition: DataStruct.hpp:128
boost::shared_array< float > floatArr
Definition: DataStruct.hpp:133
void setFaceColors(ucharArr colors, size_t w=3)
addFaceColors Adds face colors the the buffer
Definition: MeshBuffer.cpp:125
MeshBuffer()
MeshBuffer Contructor. Builds an empty buffer. Fill elements with add-Methods.
Definition: MeshBuffer.cpp:38
size_t numFaces() const
numFaces Number of faces in the mesh
Definition: MeshBuffer.cpp:151
void setVertexNormals(floatArr normals)
addVertexNormals Adds vertex normals.
Definition: MeshBuffer.cpp:52
indexArray getFaceMaterialIndices()
getFaceMaterialIndices Returns an array with face material indices
Definition: MeshBuffer.cpp:213
bool removeFloatChannel(const std::string &name)
Removes a float channel. If the type is not required use: erase.
Definition: BaseBuffer.hpp:306
std::vector< Material > m_materials
TODO: CHANNEL BASED SETTER / GETTER!
Definition: MeshBuffer.hpp:211
bool hasVertexColors() const
Definition: MeshBuffer.cpp:260
void setVertices(floatArr vertices, size_t n)
addVertices Adds the vertex array. Three floats per vertex
Definition: MeshBuffer.cpp:44
The MeshBuffer Mesh representation for I/O modules.
Definition: MeshBuffer.hpp:41
bool hasFaceColors() const
Definition: MeshBuffer.cpp:250
floatArr getFaceNormals()
getFaceNormas Returns an array containing face normals, i.e., three float values per face...
Definition: MeshBuffer.cpp:185
size_t numVertices() const
numVertices Number of vertices in the mesh
Definition: MeshBuffer.cpp:138
ChannelManager class Store and access AttributeChannels. It expands the MultiChannelMap with downwoar...
Definition: BaseBuffer.hpp:54
floatArr getVertexNormals()
getVertexNormals Returns an array with vertex normals or an empty array if no normals are present...
Definition: MeshBuffer.cpp:178
bool hasFaces() const
Definition: MeshBuffer.cpp:240


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Mon Feb 28 2022 22:46:08