Material.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2018 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 SDF_MATERIAL_HH_
18 #define SDF_MATERIAL_HH_
19 
20 #include <string>
21 #include "sdf/Element.hh"
22 #include "sdf/Types.hh"
23 #include "sdf/sdf_config.h"
24 #include "sdf/system_util.hh"
25 
26 namespace sdf
27 {
28  // Inline bracket to help doxygen filtering.
29  inline namespace SDF_VERSION_NAMESPACE {
30  //
31 
32  // Forward declarations.
33  class MaterialPrivate;
34  class Pbr;
35 
36  enum class ShaderType : int
37  {
38  PIXEL = 0,
39  VERTEX = 1,
40  NORMAL_MAP_OBJECTSPACE = 2,
42  };
43 
46  {
48  public: Material();
49 
52  public: Material(const Material &_material);
53 
56  public: Material(Material &&_material) noexcept;
57 
59  public: ~Material();
60 
64  public: Material &operator=(const Material &_material);
65 
69  public: Material &operator=(Material &&_material);
70 
77  public: Errors Load(ElementPtr _sdf);
78 
83  public: ignition::math::Color Ambient() const;
84 
89  public: void SetAmbient(const ignition::math::Color &_color) const;
90 
95  public: ignition::math::Color Diffuse() const;
96 
101  public: void SetDiffuse(const ignition::math::Color &_color) const;
102 
107  public: ignition::math::Color Specular() const;
108 
113  public: void SetSpecular(const ignition::math::Color &_color) const;
114 
119  public: ignition::math::Color Emissive() const;
120 
125  public: void SetEmissive(const ignition::math::Color &_color) const;
126 
130  public: bool Lighting() const;
131 
134  public: void SetLighting(const bool _lighting);
135 
140  public: sdf::ElementPtr Element() const;
141 
145  public: std::string ScriptUri() const;
146 
149  public: void SetScriptUri(const std::string &_uri);
150 
156  public: std::string ScriptName() const;
157 
161  public: void SetScriptName(const std::string &_name);
162 
165  public: ShaderType Shader() const;
166 
169  public: void SetShader(const ShaderType &_type);
170 
175  public: std::string NormalMap() const;
176 
179  public: void SetNormalMap(const std::string &_map);
180 
183  public: void SetPbrMaterial(const Pbr &_pbr);
184 
187  public: Pbr *PbrMaterial() const;
188 
191  public: const std::string &FilePath() const;
192 
195  public: void SetFilePath(const std::string &_filePath);
196 
198  private: MaterialPrivate *dataPtr = nullptr;
199  };
200  }
201 }
202 #endif
sdf::v9::Material::ScriptUri
std::string ScriptUri() const
Get the URI of the material script, if one has been set.
sdf::v9::Material::SetScriptName
void SetScriptName(const std::string &_name)
Set the name of the material script.
sdf::v9::Material::SetLighting
void SetLighting(const bool _lighting)
Set whether dynamic lighting is enabled.
sdf::v9::Material::Emissive
ignition::math::Color Emissive() const
Get the emissive color.
sdf
namespace for Simulation Description Format parser
Definition: Actor.hh:33
sdf::v9::Material::~Material
~Material()
Destructor.
sdf::v9::Material::SetAmbient
void SetAmbient(const ignition::math::Color &_color) const
Set the ambient color.
sdf::v9::Material::Material
Material(Material &&_material) noexcept
Move constructor.
sdf::v9::Material::SetShader
void SetShader(const ShaderType &_type)
Set the type of shader.
sdf::v9::ShaderType::PIXEL
@ PIXEL
sdf::v9::Material
This class contains visual material properties.
Definition: Material.hh:46
sdf::v9::Material::PbrMaterial
Pbr * PbrMaterial() const
Get the Physically Based Rendering (PBR) material.
sdf::v9::Material::SetPbrMaterial
void SetPbrMaterial(const Pbr &_pbr)
Set the Physically Based Rendering (PBR) material.
sdf::v9::Material::Material
Material()
Default constructor.
Types.hh
sdf::v9::Errors
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:89
sdf::v9::Material::SetSpecular
void SetSpecular(const ignition::math::Color &_color) const
Set the specular color.
SDFORMAT_VISIBLE
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system_util.hh:48
sdf::v9::Material::Material
Material(const Material &_material)
Copy constructor.
sdf::v9::Material::Ambient
ignition::math::Color Ambient() const
Get the ambient color.
sdf::v9::Material::ScriptName
std::string ScriptName() const
Get the name of the material script, or empty if one has not been specified.
sdf::v9::Material::SetEmissive
void SetEmissive(const ignition::math::Color &_color) const
Set the emissive color.
sdf::v9::Material::SetFilePath
void SetFilePath(const std::string &_filePath)
Set the path to the file where this element was loaded from.
sdf::v9::ShaderType
ShaderType
Definition: Material.hh:37
sdf::v9::Material::operator=
Material & operator=(Material &&_material)
Move assignment operator.
sdf::v9::Pbr
This class provides access to Physically-Based-Rendering (PBR) material workflows.
Definition: Pbr.hh:247
sdf::v9::Material::Load
Errors Load(ElementPtr _sdf)
Load the material based on a element pointer.
sdf::v9::Material::SetScriptUri
void SetScriptUri(const std::string &_uri)
Set the URI of the material script.
sdf::v9::Material::Lighting
bool Lighting() const
Get whether dynamic lighting is enabled.
sdf::v9::Material::Diffuse
ignition::math::Color Diffuse() const
Get the diffuse color.
sdf::v9::ElementPtr
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:53
sdf::v9::Material::Element
sdf::ElementPtr Element() const
Get a pointer to the SDF element that was used during load.
sdf::v9::Material::SetDiffuse
void SetDiffuse(const ignition::math::Color &_color) const
Set the diffuse color.
sdf::v9::Material::Specular
ignition::math::Color Specular() const
Get the specular color.
system_util.hh
sdf::v9::Material::NormalMap
std::string NormalMap() const
Get the normal map filename.
sdf::v9::Material::FilePath
const std::string & FilePath() const
The path to the file where this element was loaded from.
sdf::v9::Material::Shader
ShaderType Shader() const
Get the type of shader.
sdf::v9::Material::SetNormalMap
void SetNormalMap(const std::string &_map)
Set the normal map filename.
Element.hh
sdf::v9::Material::operator=
Material & operator=(const Material &_material)
Assignment operator.