GPU-Accelerated Coverage  0.1.0
Compute coverage tours for known environment with articulated objects on GPU
Material.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 INCLUDE_ARTICULATION_MATERIAL_H_
32 #define INCLUDE_ARTICULATION_MATERIAL_H_
33 
34 #include <gpu_coverage/Texture.h>
35 #include <assimp/scene.h>
36 #include <vector>
37 
38 namespace gpu_coverage {
39 
43 class Material {
44 public:
51  Material(const aiMaterial * const material, size_t id, const std::string& dir);
55  virtual ~Material();
56 
61  inline const float * getAmbient() const {
62  return ambient;
63  }
64 
69  inline const float * getDiffuse() const {
70  return diffuse;
71  }
72 
77  inline const float * getSpecular() const {
78  return specular;
79  }
80 
85  inline float getShininess() const {
86  return shininess;
87  }
88 
95  inline const std::string& getName() const {
96  return name;
97  }
98 
103  inline bool hasTexture() const {
104  return diffuseTexture != NULL;
105  }
106 
111  inline const Texture * getTexture() const {
112  return diffuseTexture;
113  }
114 
119  inline void setTexture(const Texture * const texture) {
121  delete diffuseTexture;
122  allocatedDiffuseTexture = false;
123  }
124  diffuseTexture = texture;
125  }
126 
131  static void loadMaterialsFile(const char * const filename);
132 
137  const size_t& getId() const {
138  return id;
139  }
140 
141 protected:
142  const size_t id;
143  const std::string name;
144  float ambient[4];
145  float diffuse[4];
146  float specular[4];
147  float shininess;
150 };
151 
152 } /* namespace gpu_coverage */
153 
154 #endif /* INCLUDE_ARTICULATION_MATERIAL_H_ */
float diffuse[4]
Diffuse color RGBA.
Definition: Material.h:145
Material(const aiMaterial *const material, size_t id, const std::string &dir)
Constructor.
const Texture * diffuseTexture
Diffuse texture if available, NULL otherwise.
Definition: Material.h:148
const std::string & getName() const
Returns the name of this material for logging.
Definition: Material.h:95
const float * getAmbient() const
Returns the ambient material color.
Definition: Material.h:61
float ambient[4]
Ambient color RGBA.
Definition: Material.h:144
static void loadMaterialsFile(const char *const filename)
Loads a supplement file mapping material names to texture images.
const std::string name
Name of this animation, see getName().
Definition: Material.h:143
float specular[4]
Specular color RGBA.
Definition: Material.h:146
Texture object.
Definition: Texture.h:46
bool hasTexture() const
Returns true if a diffuse texture is assigned to the material.
Definition: Material.h:103
const size_t id
Unique ID, see getId().
Definition: Material.h:142
const Texture * getTexture() const
Returns the diffuse texture if present, NULL otherwise.
Definition: Material.h:111
Definition: AbstractCamera.h:41
const float * getDiffuse() const
Returns the diffuse material color.
Definition: Material.h:69
void setTexture(const Texture *const texture)
Sets the texture.
Definition: Material.h:119
virtual ~Material()
Destructor.
const size_t & getId() const
Returns the unique ID of this material.
Definition: Material.h:137
float getShininess() const
Returns the material&#39;s shininess coefficient.
Definition: Material.h:85
Represents a mesh material corresponding to Assimp&#39;s aiMaterial.
Definition: Material.h:43
const float * getSpecular() const
Returns the specular material color.
Definition: Material.h:77
bool allocatedDiffuseTexture
True if this instance has allocated the texture and is responsible for deleting it later...
Definition: Material.h:149
float shininess
Shininess factor.
Definition: Material.h:147