All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
common/Material.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2014 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 _MATERIAL_HH_
18 #define _MATERIAL_HH_
19 
20 #include <string>
21 #include <iostream>
22 #include "gazebo/common/Color.hh"
23 #include "gazebo/util/system.hh"
24 
25 namespace gazebo
26 {
27  namespace common
28  {
31 
35  {
36  public: enum ShadeMode {FLAT, GOURAUD, PHONG, BLINN, SHADE_COUNT};
37  public: static std::string ShadeModeStr[SHADE_COUNT];
38 
39  public: enum BlendMode {ADD, MODULATE, REPLACE, BLEND_COUNT};
40  public: static std::string BlendModeStr[BLEND_COUNT];
41 
43  public: Material();
44 
46  public: virtual ~Material();
47 
50  public: Material(const Color &_clr);
51 
54  public: std::string GetName() const;
55 
59  public: void SetTextureImage(const std::string &_tex);
60 
64  public: void SetTextureImage(const std::string &_tex,
65  const std::string &_resourcePath);
66 
70  public: std::string GetTextureImage() const;
71 
74  public: void SetAmbient(const Color &_clr);
75 
78  public: Color GetAmbient() const;
79 
82  public: void SetDiffuse(const Color &_clr);
83 
86  public: Color GetDiffuse() const;
87 
90  public: void SetSpecular(const Color &_clr);
91 
94  public: Color GetSpecular() const;
95 
98  public: void SetEmissive(const Color &_clr);
99 
102  public: Color GetEmissive() const;
103 
106  public: void SetTransparency(double _t);
107 
110  public: double GetTransparency() const;
111 
114  public: void SetShininess(double _t);
115 
118  public: double GetShininess() const;
119 
124  public: void SetBlendFactors(double _srcFactor, double _dstFactor);
125 
129  public: void GetBlendFactors(double &_srcFactor, double &_dstFactor);
130 
133  public: void SetBlendMode(BlendMode _b);
134 
137  public: BlendMode GetBlendMode() const;
138 
141  public: void SetShadeMode(ShadeMode _b);
142 
145  public: ShadeMode GetShadeMode() const;
146 
149  public: void SetPointSize(double _size);
150 
153  public: double GetPointSize() const;
154 
157  public: void SetDepthWrite(bool _value);
158 
161  public: bool GetDepthWrite() const;
162 
165  public: void SetLighting(bool _value);
166 
169  public: bool GetLighting() const;
170 
174  public: friend std::ostream &operator<<(std::ostream &_out,
175  const gazebo::common::Material &_m)
176  {
177  _out << "Material:\n";
178  _out << " Name: " << _m.name << "\n";
179  _out << " Texture: " << _m.texImage << "\n";
180  _out << " Ambient: " << _m.ambient << "\n";
181  _out << " Diffuse: " << _m.diffuse << "\n";
182  _out << " Specular: " << _m.specular << "\n";
183  _out << " Emissive: " << _m.emissive << "\n";
184  _out << " Transparency: " << _m.transparency << "\n";
185  _out << " Shininess: " << _m.shininess << "\n";
186  _out << " BlendMode: " << BlendModeStr[_m.blendMode] << "\n";
187  _out << " ShadeMode: " << ShadeModeStr[_m.shadeMode] << "\n";
188  _out << " DepthWrite: " << _m.depthWrite << "\n";
189  return _out;
190  }
191 
193  protected: std::string name;
194 
196  protected: std::string texImage;
197 
199  protected: Color ambient;
200 
202  protected: Color diffuse;
203 
205  protected: Color specular;
206 
208  protected: Color emissive;
209 
211  protected: double transparency;
212 
214  protected: double shininess;
215 
217  protected: double pointSize;
218 
220  protected: BlendMode blendMode;
221 
223  protected: ShadeMode shadeMode;
224 
226  private: static unsigned int counter;
227 
229  private: bool depthWrite;
230 
231  private: bool lighting;
232 
234  private: double srcBlendFactor;
235 
237  private: double dstBlendFactor;
238  };
240  }
241 }
242 #endif
double transparency
transparency value in the range 0 to 1
Definition: common/Material.hh:211
ShadeMode
Definition: common/Material.hh:36
Color emissive
the emissive light color
Definition: common/Material.hh:208
BlendMode
Definition: common/Material.hh:39
Encapsulates description of a material.
Definition: common/Material.hh:34
double shininess
shininess value (0 to 1)
Definition: common/Material.hh:214
BlendMode blendMode
blend mode
Definition: common/Material.hh:220
std::string texImage
the texture image file name
Definition: common/Material.hh:196
std::string name
the name of the material
Definition: common/Material.hh:193
double pointSize
point size
Definition: common/Material.hh:217
Definition: common/Material.hh:39
Color ambient
the ambient light color
Definition: common/Material.hh:199
Defines a color.
Definition: Color.hh:39
ShadeMode shadeMode
the shade mode
Definition: common/Material.hh:223
Color specular
the specular light color
Definition: common/Material.hh:205
Color diffuse
the diffuse ligth color
Definition: common/Material.hh:202
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48
friend std::ostream & operator<<(std::ostream &_out, const gazebo::common::Material &_m)
Stream insertion operator param[in] _out the output stream to extract from param[out] _m the material...
Definition: common/Material.hh:174