Gazebo Rendering

API Reference

8.2.1
Material.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 #ifndef GZ_RENDERING_MATERIAL_HH_
18 #define GZ_RENDERING_MATERIAL_HH_
19 
20 #include <memory>
21 #include <string>
22 #include <gz/math/Color.hh>
23 #include <gz/common/Material.hh>
24 #include "gz/rendering/config.hh"
26 #include "gz/rendering/Object.hh"
28 #include "gz/rendering/Export.hh"
29 
30 namespace gz
31 {
32  namespace rendering
33  {
34  inline namespace GZ_RENDERING_VERSION_NAMESPACE {
35  //
37  enum GZ_RENDERING_VISIBLE MaterialType
38  {
41 
43  MT_PBS = 1
44  };
45 
48  class GZ_RENDERING_VISIBLE Material :
49  public virtual Object
50  {
52  public: virtual ~Material();
53 
56  public: virtual bool LightingEnabled() const = 0;
57 
60  public: virtual void SetLightingEnabled(const bool _enabled) = 0;
61 
64  public: virtual void SetDepthCheckEnabled(bool _enabled) = 0;
65 
68  public: virtual bool DepthCheckEnabled() const = 0;
69 
72  public: virtual void SetDepthWriteEnabled(bool _enabled) = 0;
73 
76  public: virtual bool DepthWriteEnabled() const = 0;
77 
80  public: virtual math::Color Ambient() const = 0;
81 
87  public: virtual void SetAmbient(const double _r, const double _g,
88  const double _b, const double _a = 1.0) = 0;
89 
92  public: virtual void SetAmbient(const math::Color &_color) = 0;
93 
96  public: virtual math::Color Diffuse() const = 0;
97 
103  public: virtual void SetDiffuse(const double _r, const double _g,
104  const double _b, const double _a = 1.0) = 0;
105 
108  public: virtual void SetDiffuse(const math::Color &_color) = 0;
109 
112  public: virtual math::Color Specular() const = 0;
113 
119  public: virtual void SetSpecular(const double _r, const double _g,
120  const double _b, const double _a = 1.0) = 0;
121 
124  public: virtual void SetSpecular(const math::Color &_color) = 0;
125 
128  public: virtual math::Color Emissive() const = 0;
129 
135  public: virtual void SetEmissive(const double _r, const double _g,
136  const double _b, const double _a = 1.0) = 0;
137 
140  public: virtual void SetEmissive(const math::Color &_color) = 0;
141 
144  public: virtual double Shininess() const = 0;
145 
148  public: virtual void SetShininess(const double _shininess) = 0;
149 
152  public: virtual double Transparency() const = 0;
153 
157  public: virtual void SetDepthMaterial(const double far,
158  const double near) = 0;
159 
162  public: virtual void SetTransparency(const double _transparency) = 0;
163 
168  public: virtual void SetAlphaFromTexture(bool _enabled,
169  double _alpha = 0.5, bool _twoSided = true) = 0;
170 
173  public: virtual bool TextureAlphaEnabled() const = 0;
174 
177  public: virtual double AlphaThreshold() const = 0;
178 
181  public: virtual bool TwoSidedEnabled() const = 0;
182 
185  public: virtual double Reflectivity() const = 0;
186 
189  public: virtual void SetReflectivity(const double _reflectivity) = 0;
190 
193  public: virtual bool CastShadows() const = 0;
194 
197  public: virtual void SetCastShadows(const bool _castShadows) = 0;
198 
201  public: virtual bool ReceiveShadows() const = 0;
202 
205  public: virtual void SetReceiveShadows(const bool _receiveShadows) = 0;
206 
209  public: virtual bool ReflectionEnabled() const = 0;
210 
213  public: virtual void SetReflectionEnabled(const bool _enabled) = 0;
214 
217  public: virtual bool HasTexture() const = 0;
218 
221  public: virtual std::string Texture() const = 0;
222 
226  public: virtual void SetTexture(const std::string &_texture)
227  {
228  this->SetTexture(_texture, nullptr);
229  }
230 
236  public: virtual void SetTexture(const std::string &_texture,
238  {
239  (void)_texture;
240  (void)_img;
241  }
242 
247  const = 0;
248 
250  public: virtual void ClearTexture() = 0;
251 
254  public: virtual bool HasNormalMap() const = 0;
255 
258  public: virtual std::string NormalMap() const = 0;
259 
264  const = 0;
265 
268  public: virtual void SetNormalMap(const std::string &_normalMap)
269  {
270  this->SetNormalMap(_normalMap, nullptr);
271  }
272 
278  public: virtual void SetNormalMap(const std::string &_normalMap,
280  {
281  (void)_normalMap;
282  (void)_img;
283  }
284 
286  public: virtual void ClearNormalMap() = 0;
287 
290  public: virtual bool HasRoughnessMap() const = 0;
291 
294  public: virtual std::string RoughnessMap() const = 0;
295 
300  const = 0;
301 
304  public: virtual void SetRoughnessMap(const std::string &_roughnessMap)
305  {
306  this->SetRoughnessMap(_roughnessMap, nullptr);
307  }
308 
314  public: virtual void SetRoughnessMap(
315  const std::string &_roughnessMap,
317  {
318  (void)_roughnessMap;
319  (void)_img;
320  }
321 
323  public: virtual void ClearRoughnessMap() = 0;
324 
327  public: virtual bool HasMetalnessMap() const = 0;
328 
331  public: virtual std::string MetalnessMap() const = 0;
332 
337  const = 0;
338 
341  public: virtual void SetMetalnessMap(const std::string &_metalnessMap)
342  {
343  this->SetMetalnessMap(_metalnessMap, nullptr);
344  }
345 
351  public: virtual void SetMetalnessMap(
352  const std::string &_metalnessMap,
354  {
355  (void)_metalnessMap;
356  (void)_img;
357  }
358 
360  public: virtual void ClearMetalnessMap() = 0;
361 
364  public: virtual bool HasEnvironmentMap() const = 0;
365 
368  public: virtual std::string EnvironmentMap() const = 0;
369 
374  const = 0;
375 
378  public: virtual void SetEnvironmentMap(const std::string &_environmentMap)
379  {
380  this->SetEnvironmentMap(_environmentMap, nullptr);
381  }
382 
388  public: virtual void SetEnvironmentMap(
389  const std::string &_environmentMap,
391  {
392  (void)_environmentMap;
393  (void)_img;
394  }
395 
397  public: virtual void ClearEnvironmentMap() = 0;
398 
401  public: virtual bool HasEmissiveMap() const = 0;
402 
405  public: virtual std::string EmissiveMap() const = 0;
406 
411  const = 0;
412 
415  public: virtual void SetEmissiveMap(const std::string &_emissiveMap)
416  {
417  this->SetEmissiveMap(_emissiveMap, nullptr);
418  }
419 
425  public: virtual void SetEmissiveMap(
426  const std::string &_emissiveMap,
428  {
429  (void)_emissiveMap;
430  (void)_img;
431  }
432 
434  public: virtual void ClearEmissiveMap() = 0;
435 
438  public: virtual bool HasLightMap() const = 0;
439 
442  public: virtual std::string LightMap() const = 0;
443 
446  public: virtual unsigned int LightMapTexCoordSet() const = 0;
447 
451  public: virtual void SetLightMap(const std::string &_lightMap,
452  unsigned int _uvSet = 0u)
453  {
454  this->SetLightMap(_lightMap, nullptr, _uvSet);
455  }
456 
462  public: virtual void SetLightMap(const std::string &_lightMap,
464  unsigned int _uvSet = 0)
465  {
466  (void)_lightMap;
467  (void)_img;
468  (void)_uvSet;
469  }
470 
475  const = 0;
476 
478  public: virtual void ClearLightMap() = 0;
479 
485  public: virtual void SetRenderOrder(const float _renderOrder) = 0;
486 
489  public: virtual float RenderOrder() const = 0;
490 
493  public: virtual void SetRoughness(const float _roughness) = 0;
494 
497  public: virtual float Roughness() const = 0;
498 
501  public: virtual void SetMetalness(const float _metalness) = 0;
502 
505  public: virtual float Metalness() const = 0;
506 
508  public: virtual enum MaterialType Type() const = 0;
509 
512  public: virtual enum ShaderType ShaderType() const = 0;
513 
516  public: virtual void SetShaderType(enum ShaderType _type) = 0;
517 
520  public: virtual MaterialPtr Clone(const std::string &_name = "")
521  const = 0;
522 
525  public: virtual void CopyFrom(ConstMaterialPtr _material) = 0;
526 
529  public: virtual void CopyFrom(const common::Material &_material) = 0;
530 
533  public: virtual std::string VertexShader() const = 0;
534 
537  public: virtual ShaderParamsPtr VertexShaderParams() = 0;
538 
541  public: virtual void SetVertexShader(const std::string &_path) = 0;
542 
545  public: virtual std::string FragmentShader() const = 0;
546 
549  public: virtual ShaderParamsPtr FragmentShaderParams() = 0;
550 
553  public: virtual void SetFragmentShader(const std::string &_path) = 0;
554  };
555  }
556  }
557 }
558 #endif