GPU-Accelerated Coverage  0.1.0
Compute coverage tours for known environment with articulated objects on GPU
Mesh.h
1 /*
2  * Copyright (c) 2018, Stefan Osswald
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright notice, this
9  * list of conditions and the following disclaimer.
10  *
11  * * Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * * Neither the name of the copyright holder nor the names of its
16  * contributors may be used to endorse or promote products derived from
17  * this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #ifndef MESH_H_
32 #define MESH_H_
33 
34 #include GL_INCLUDE
35 #include <gpu_coverage/Bone.h>
36 #include <gpu_coverage/Programs.h>
37 
38 #include <assimp/scene.h>
39 #include <assimp/mesh.h>
40 
41 #include <vector>
42 
43 namespace gpu_coverage {
44 
45 // Forward declarations
46 struct LocationsCommonRender;
47 class Material;
48 
52 class Mesh {
53 public:
60  enum BUFFERS {
61  VERTEX_BUFFER, COLOR_BUFFER, TEXCOORD_BUFFER, NORMAL_BUFFER, INDEX_BUFFER
62  };
63  typedef std::vector<Bone*> Bones;
64 
71  Mesh(const aiMesh * const mesh, const size_t id, const std::vector<Material*>& materials);
72 
76  ~Mesh();
77 
83  void render(const LocationsMaterial * const locations, const bool hasTesselationShader) const;
84 
89  void toDot(FILE *dot) const;
90 
95  inline size_t getId() {
96  return id;
97  }
98 
106  inline const std::string& getName() {
107  return name;
108  }
109 
114  inline Bones& getBones() {
115  return bones;
116  }
117 
122  inline Material *getMaterial() {
123  return material;
124  }
125 
126 protected:
127  const size_t id;
128  const std::string name;
130  GLuint vao;
131  GLuint vbo[5];
132 
133  unsigned int elementCount;
134  Bones bones;
135 };
136 
137 }
138 
139 #endif
Class representing a mesh, corresponding to Assimp&#39;s aiMesh.
Definition: Mesh.h:52
void toDot(FILE *dot) const
Write Graphviz Dot node representing this mesh to file for debugging.
GLuint vao
Vertex array object.
Definition: Mesh.h:130
void render(const LocationsMaterial *const locations, const bool hasTesselationShader) const
Renders the mesh.
Bones bones
Bones associated with this mesh.
Definition: Mesh.h:134
Material * material
Material associated with this mesh, see getMaterial().
Definition: Mesh.h:129
Locations of material shader variables.
Definition: Programs.h:142
const std::string & getName()
Returns the name of this mesh for logging.
Definition: Mesh.h:106
Mesh(const aiMesh *const mesh, const size_t id, const std::vector< Material * > &materials)
Constructor.
Definition: AbstractCamera.h:41
Bones & getBones()
Definition: Mesh.h:114
const size_t id
Unique ID, see getId().
Definition: Mesh.h:127
Represents a mesh material corresponding to Assimp&#39;s aiMaterial.
Definition: Material.h:43
std::vector< Bone * > Bones
Vector of bones attached to this mesh.
Definition: Mesh.h:63
GLuint vbo[5]
Vertex buffers (vertex position, color, texture coordinate, normal, index)
Definition: Mesh.h:131
~Mesh()
Destructor.
size_t getId()
Returns the unique ID of this mesh.
Definition: Mesh.h:95
BUFFERS
Buffer semantics.
Definition: Mesh.h:60
Material * getMaterial()
Definition: Mesh.h:122
const std::string name
Name of this mesh, see getName().
Definition: Mesh.h:128
unsigned int elementCount
Number of indices used in the primitives to draw.
Definition: Mesh.h:133