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 2011 Nate Koenig
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 
32  class Material
33  {
35  public: static std::string ShadeModeStr[SHADE_COUNT];
36 
38  public: static std::string BlendModeStr[BLEND_COUNT];
39 
41  public: Material();
42 
44  public: virtual ~Material();
45 
48  public: Material(const Color &_clr);
49 
52  public: std::string GetName() const;
53 
57  public: void SetTextureImage(const std::string &_tex);
58 
62  public: void SetTextureImage(const std::string &_tex,
63  const std::string &_resourcePath);
64 
68  public: std::string GetTextureImage() const;
69 
72  public: void SetAmbient(const Color &_clr);
73 
76  public: Color GetAmbient() const;
77 
80  public: void SetDiffuse(const Color &_clr);
81 
84  public: Color GetDiffuse() const;
85 
88  public: void SetSpecular(const Color &_clr);
89 
92  public: Color GetSpecular() const;
93 
96  public: void SetEmissive(const Color &_clr);
97 
100  public: Color GetEmissive() const;
101 
104  public: void SetTransparency(double _t);
105 
108  public: double GetTransparency() const;
109 
112  public: void SetShininess(double _t);
113 
116  public: double GetShininess() const;
117 
122  public: void SetBlendFactors(double _srcFactor, double _dstFactor);
123 
127  public: void GetBlendFactors(double &_srcFactor, double &_dstFactor);
128 
131  public: void SetBlendMode(BlendMode _b);
132 
135  public: BlendMode GetBlendMode() const;
136 
139  public: void SetShadeMode(ShadeMode _b);
140 
143  public: ShadeMode GetShadeMode() const;
144 
147  public: void SetPointSize(double _size);
148 
151  public: double GetPointSize() const;
152 
155  public: void SetDepthWrite(bool _value);
156 
159  public: bool GetDepthWrite() const;
160 
163  public: void SetLighting(bool _value);
164 
167  public: bool GetLighting() const;
168 
172  public: friend std::ostream &operator<<(std::ostream &_out,
173  const gazebo::common::Material &_m)
174  {
175  _out << "Material:\n";
176  _out << " Name: " << _m.name << "\n";
177  _out << " Texture: " << _m.texImage << "\n";
178  _out << " Ambient: " << _m.ambient << "\n";
179  _out << " Diffuse: " << _m.diffuse << "\n";
180  _out << " Specular: " << _m.specular << "\n";
181  _out << " Emissive: " << _m.emissive << "\n";
182  _out << " Transparency: " << _m.transparency << "\n";
183  _out << " Shininess: " << _m.shininess << "\n";
184  _out << " BlendMode: " << BlendModeStr[_m.blendMode] << "\n";
185  _out << " ShadeMode: " << ShadeModeStr[_m.shadeMode] << "\n";
186  _out << " DepthWrite: " << _m.depthWrite << "\n";
187  return _out;
188  }
189 
191  protected: std::string name;
192 
194  protected: std::string texImage;
195 
197  protected: Color ambient;
198 
200  protected: Color diffuse;
201 
203  protected: Color specular;
204 
206  protected: Color emissive;
207 
209  protected: double transparency;
210 
212  protected: double shininess;
213 
215  protected: double pointSize;
216 
218  protected: BlendMode blendMode;
219 
221  protected: ShadeMode shadeMode;
222 
224  private: static unsigned int counter;
225 
227  private: bool depthWrite;
228 
229  private: bool lighting;
230 
232  private: double srcBlendFactor;
233 
235  private: double dstBlendFactor;
236  };
238  }
239 }
240 #endif