common/Material.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 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 GAZEBO_COMMON_MATERIAL_HH_
18 #define GAZEBO_COMMON_MATERIAL_HH_
19 
20 #include <string>
21 #include <iostream>
22 #include <ignition/math/Color.hh>
23 #include "gazebo/common/Color.hh"
24 #include "gazebo/util/system.hh"
25 
26 namespace gazebo
27 {
28  namespace common
29  {
32 
35  class GZ_COMMON_VISIBLE Material
36  {
37  public: enum ShadeMode {FLAT, GOURAUD, PHONG, BLINN, SHADE_COUNT};
38  public: static std::string ShadeModeStr[SHADE_COUNT];
39 
40  public: enum BlendMode {ADD, MODULATE, REPLACE, BLEND_COUNT};
41  public: static std::string BlendModeStr[BLEND_COUNT];
42 
44  public: Material();
45 
47  public: virtual ~Material();
48 
52  public: explicit Material(const Color &_clr) GAZEBO_DEPRECATED(9.0);
53 
56  public: explicit Material(const ignition::math::Color &_clr);
57 
60  public: std::string GetName() const;
61 
65  public: void SetTextureImage(const std::string &_tex);
66 
70  public: void SetTextureImage(const std::string &_tex,
71  const std::string &_resourcePath);
72 
76  public: std::string GetTextureImage() const;
77 
81  public: void SetAmbient(const Color &_clr) GAZEBO_DEPRECATED(9.0);
82 
85  public: void SetAmbient(const ignition::math::Color &_clr);
86 
90  public: Color GetAmbient() const GAZEBO_DEPRECATED(9.0);
91 
94  public: ignition::math::Color Ambient() const;
95 
99  public: void SetDiffuse(const Color &_clr) GAZEBO_DEPRECATED(9.0);
100 
103  public: void SetDiffuse(const ignition::math::Color &_clr);
104 
108  public: Color GetDiffuse() const GAZEBO_DEPRECATED(9.0);
109 
112  public: ignition::math::Color Diffuse() const;
113 
117  public: void SetSpecular(const Color &_clr) GAZEBO_DEPRECATED(9.0);
118 
121  public: void SetSpecular(const ignition::math::Color &_clr);
122 
126  public: Color GetSpecular() const GAZEBO_DEPRECATED(9.0);
127 
130  public: ignition::math::Color Specular() const;
131 
135  public: void SetEmissive(const Color &_clr) GAZEBO_DEPRECATED(9.0);
136 
139  public: void SetEmissive(const ignition::math::Color &_clr);
140 
144  public: Color GetEmissive() const GAZEBO_DEPRECATED(9.0);
145 
148  public: ignition::math::Color Emissive() const;
149 
152  public: void SetTransparency(double _t);
153 
156  public: double GetTransparency() const;
157 
160  public: void SetShininess(double _t);
161 
164  public: double GetShininess() const;
165 
170  public: void SetBlendFactors(double _srcFactor, double _dstFactor);
171 
175  public: void GetBlendFactors(double &_srcFactor, double &_dstFactor)
176  const;
177 
180  public: void SetBlendMode(BlendMode _b);
181 
184  public: BlendMode GetBlendMode() const;
185 
188  public: void SetShadeMode(ShadeMode _b);
189 
192  public: ShadeMode GetShadeMode() const;
193 
196  public: void SetPointSize(double _size);
197 
200  public: double GetPointSize() const;
201 
204  public: void SetDepthWrite(bool _value);
205 
208  public: bool GetDepthWrite() const;
209 
212  public: void SetLighting(bool _value);
213 
216  public: bool GetLighting() const;
217 
221  public: friend std::ostream &operator<<(std::ostream &_out,
222  const gazebo::common::Material &_m)
223  {
224  _out << "Material:\n";
225  _out << " Name: " << _m.name << "\n";
226  _out << " Texture: " << _m.texImage << "\n";
227  _out << " Ambient: " << _m.ambient << "\n";
228  _out << " Diffuse: " << _m.diffuse << "\n";
229  _out << " Specular: " << _m.specular << "\n";
230  _out << " Emissive: " << _m.emissive << "\n";
231  _out << " Transparency: " << _m.transparency << "\n";
232  _out << " Shininess: " << _m.shininess << "\n";
233  _out << " BlendMode: " << BlendModeStr[_m.blendMode] << "\n";
234  _out << " ShadeMode: " << ShadeModeStr[_m.shadeMode] << "\n";
235  _out << " DepthWrite: " << _m.depthWrite << "\n";
236  return _out;
237  }
238 
240  protected: std::string name;
241 
243  protected: std::string texImage;
244 
246  protected: ignition::math::Color ambient;
247 
249  protected: ignition::math::Color diffuse;
250 
252  protected: ignition::math::Color specular;
253 
255  protected: ignition::math::Color emissive;
256 
258  protected: double transparency = 0.0;
259 
261  protected: double shininess = 0.0;
262 
264  protected: double pointSize;
265 
267  protected: BlendMode blendMode;
268 
270  protected: ShadeMode shadeMode;
271 
273  private: static unsigned int counter;
274 
276  private: bool depthWrite = true;
277 
278  private: bool lighting = true;
279 
281  private: double srcBlendFactor;
282 
284  private: double dstBlendFactor;
285  };
287  }
288 }
289 #endif
ShadeMode shadeMode
the shade mode
Definition: common/Material.hh:270
Encapsulates description of a material.
Definition: common/Material.hh:35
std::string texImage
the texture image file name
Definition: common/Material.hh:243
ignition::math::Color diffuse
the diffuse ligth color
Definition: common/Material.hh:249
Definition: common/Material.hh:40
ShadeMode
Definition: common/Material.hh:37
ignition::math::Color emissive
the emissive light color
Definition: common/Material.hh:255
std::string name
the name of the material
Definition: common/Material.hh:240
double pointSize
point size
Definition: common/Material.hh:264
Defines a color.
Definition: Color.hh:36
BlendMode
Definition: common/Material.hh:40
#define GAZEBO_DEPRECATED(version)
Definition: system.hh:328
ignition::math::Color ambient
the ambient light color
Definition: common/Material.hh:246
ignition::math::Color specular
the specular light color
Definition: common/Material.hh:252
BlendMode blendMode
blend mode
Definition: common/Material.hh:267