Ignition Common

API Reference

3.0.0
Material.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 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 IGNITION_COMMON_MATERIAL_HH_
18 #define IGNITION_COMMON_MATERIAL_HH_
19 
20 #include <iostream>
21 #include <memory>
22 #include <string>
23 
24 #include <ignition/math/Color.hh>
25 #include <ignition/common/graphics/Export.hh>
28 
29 namespace ignition
30 {
31  namespace common
32  {
33  // Forward declare private data class
34  class MaterialPrivate;
35 
37  class IGNITION_COMMON_GRAPHICS_VISIBLE Material
38  {
41  public: enum ShadeMode
42  {
46  SHADE_MODE_BEGIN = 0,
47 
49  FLAT = 0,
50 
52  GOURAUD = 1,
53 
55  PHONG = 2,
56 
58  BLINN = 3,
59 
63  SHADE_MODE_END
64  };
65 
68  public: enum BlendMode
69  {
73  BLEND_MODE_BEGIN = 0,
74 
76  ADD = 0,
77 
79  MODULATE = 1,
80 
82  REPLACE = 2,
83 
87  BLEND_MODE_END
88  };
89 
91  public: Material();
92 
94  public: ~Material();
95 
98  public: explicit Material(const math::Color &_clr);
99 
102  public: std::string Name() const;
103 
107  public: void SetTextureImage(const std::string &_tex);
108 
112  public: void SetTextureImage(const std::string &_tex,
113  const std::string &_resourcePath);
114 
118  public: std::string TextureImage() const;
119 
122  public: void SetAmbient(const math::Color &_clr);
123 
126  public: math::Color Ambient() const;
127 
130  public: void SetDiffuse(const math::Color &_clr);
131 
134  public: math::Color Diffuse() const;
135 
138  public: void SetSpecular(const math::Color &_clr);
139 
142  public: math::Color Specular() const;
143 
146  public: void SetEmissive(const math::Color &_clr);
147 
150  public: math::Color Emissive() const;
151 
154  public: void SetTransparency(double _t);
155 
158  public: double Transparency() const;
159 
162  public: void SetShininess(double _t);
163 
166  public: double Shininess() const;
167 
172  public: void SetBlendFactors(double _srcFactor, double _dstFactor);
173 
177  public: void BlendFactors(double &_srcFactor, double &_dstFactor) const;
178 
181  public: void SetBlend(BlendMode _b);
182 
185  public: BlendMode Blend() const;
186 
188  public: std::string BlendStr() const;
189 
191  public: std::string ShadeStr() const;
192 
195  public: void SetShade(ShadeMode _b);
196 
199  public: ShadeMode Shade() const;
200 
203  public: void SetPointSize(double _size);
204 
207  public: double PointSize() const;
208 
211  public: void SetDepthWrite(bool _value);
212 
215  public: bool DepthWrite() const;
216 
219  public: void SetLighting(bool _value);
220 
223  public: bool Lighting() const;
224 
228  public: friend std::ostream &operator<<(std::ostream &_out,
229  const ignition::common::Material &_m)
230  {
231  _out << "Material:\n";
232  _out << " Name: " << _m.Name() << "\n";
233  _out << " Texture: " << _m.TextureImage() << "\n";
234  _out << " Ambient: " << _m.Ambient() << "\n";
235  _out << " Diffuse: " << _m.Diffuse() << "\n";
236  _out << " Specular: " << _m.Specular() << "\n";
237  _out << " Emissive: " << _m.Emissive() << "\n";
238  _out << " Transparency: " << _m.Transparency() << "\n";
239  _out << " Shininess: " << _m.Shininess() << "\n";
240  _out << " BlendMode: " << _m.BlendStr() << "\n";
241  _out << " ShadeMode: " << _m.ShadeStr() << "\n";
242  _out << " DepthWrite: " << _m.DepthWrite() << "\n";
243  return _out;
244  }
245 
248  private: std::unique_ptr<MaterialPrivate> dataPtr;
250  };
251  }
252 }
253 #endif
friend std::ostream & operator<<(std::ostream &_out, const Material &_m)
Stream insertion operator param[in] _out the output stream to extract from param[out] _m the material...
Definition: Material.hh:228
BlendMode
Definition: Material.hh:68
std::string Name() const
Get the name of the material.
double Transparency() const
Get the transparency percentage (0..1)
#define IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
Definition: SuppressWarning.hh:67
STL class.
double Shininess() const
Get the shininess.
Encapsulates description of a material.
Definition: Material.hh:37
std::string ShadeStr() const
Get the shade mode string.
std::string BlendStr() const
Get the blend mode string.
std::string TextureImage() const
Get a texture image.
bool DepthWrite() const
Get depth write.
math::Color Ambient() const
Get the ambient color.
ShadeMode
Definition: Material.hh:41
Forward declarations for the common classes.
math::Color Specular() const
Get the specular color.
math::Color Diffuse() const
Get the diffuse color.
STL class.
math::Color Emissive() const
Get the emissive color.
#define IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
Microsoft Visual Studio does not automatically export the interface information for member variables ...
Definition: SuppressWarning.hh:64