All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
common/Material.hh
Go to the documentation of this file.
1 /*
2  * Copyright 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 _MATERIAL_HH_
18 #define _MATERIAL_HH_
19 
20 #include <string>
21 #include <iostream>
22 #include "common/Color.hh"
23 
24 namespace gazebo
25 {
26  namespace common
27  {
30 
33  class Material
34  {
36  public: static std::string ShadeModeStr[SHADE_COUNT];
37 
39  public: static std::string BlendModeStr[BLEND_COUNT];
40 
42  public: Material();
43 
45  public: virtual ~Material();
46 
49  public: Material(const Color &_clr);
50 
53  public: std::string GetName() const;
54 
58  public: void SetTextureImage(const std::string &_tex);
59 
63  public: void SetTextureImage(const std::string &_tex,
64  const std::string &_resourcePath);
65 
69  public: std::string GetTextureImage() const;
70 
73  public: void SetAmbient(const Color &_clr);
74 
77  public: Color GetAmbient() const;
78 
81  public: void SetDiffuse(const Color &_clr);
82 
85  public: Color GetDiffuse() const;
86 
89  public: void SetSpecular(const Color &_clr);
90 
93  public: Color GetSpecular() const;
94 
97  public: void SetEmissive(const Color &_clr);
98 
101  public: Color GetEmissive() const;
102 
105  public: void SetTransparency(double _t);
106 
109  public: double GetTransparency() const;
110 
113  public: void SetShininess(double _t);
114 
117  public: double GetShininess() const;
118 
123  public: void SetBlendFactors(double _srcFactor, double _dstFactor);
124 
128  public: void GetBlendFactors(double &_srcFactor, double &_dstFactor);
129 
132  public: void SetBlendMode(BlendMode _b);
133 
136  public: BlendMode GetBlendMode() const;
137 
140  public: void SetShadeMode(ShadeMode _b);
141 
144  public: ShadeMode GetShadeMode() const;
145 
148  public: void SetPointSize(double _size);
149 
152  public: double GetPointSize() const;
153 
156  public: void SetDepthWrite(bool _value);
157 
160  public: bool GetDepthWrite() const;
161 
164  public: void SetLighting(bool _value);
165 
168  public: bool GetLighting() const;
169 
173  public: friend std::ostream &operator<<(std::ostream &_out,
174  const gazebo::common::Material &_m)
175  {
176  _out << "Material:\n";
177  _out << " Name: " << _m.name << "\n";
178  _out << " Texture: " << _m.texImage << "\n";
179  _out << " Ambient: " << _m.ambient << "\n";
180  _out << " Diffuse: " << _m.diffuse << "\n";
181  _out << " Specular: " << _m.specular << "\n";
182  _out << " Emissive: " << _m.emissive << "\n";
183  _out << " Transparency: " << _m.transparency << "\n";
184  _out << " Shininess: " << _m.shininess << "\n";
185  _out << " BlendMode: " << BlendModeStr[_m.blendMode] << "\n";
186  _out << " ShadeMode: " << ShadeModeStr[_m.shadeMode] << "\n";
187  _out << " DepthWrite: " << _m.depthWrite << "\n";
188  return _out;
189  }
190 
192  protected: std::string name;
193 
195  protected: std::string texImage;
196 
198  protected: Color ambient;
199 
201  protected: Color diffuse;
202 
204  protected: Color specular;
205 
207  protected: Color emissive;
208 
210  protected: double transparency;
211 
213  protected: double shininess;
214 
216  protected: double pointSize;
217 
219  protected: BlendMode blendMode;
220 
222  protected: ShadeMode shadeMode;
223 
225  private: static unsigned int counter;
226 
228  private: bool depthWrite;
229 
230  private: bool lighting;
231 
233  private: double srcBlendFactor;
234 
236  private: double dstBlendFactor;
237  };
239  }
240 }
241 #endif