Loading...
Searching...
No Matches
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
26namespace 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,
41 NORMAL_MAP_TANGENTSPACE = 3,
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
139 public: bool DoubleSided() const;
140
143 public: void SetDoubleSided(bool _doubleSided);
144
149 public: sdf::ElementPtr Element() const;
150
154 public: std::string ScriptUri() const;
155
158 public: void SetScriptUri(const std::string &_uri);
159
165 public: std::string ScriptName() const;
166
170 public: void SetScriptName(const std::string &_name);
171
174 public: ShaderType Shader() const;
175
178 public: void SetShader(const ShaderType &_type);
179
184 public: std::string NormalMap() const;
185
188 public: void SetNormalMap(const std::string &_map);
189
192 public: void SetPbrMaterial(const Pbr &_pbr);
193
196 public: Pbr *PbrMaterial() const;
197
200 public: const std::string &FilePath() const;
201
204 public: void SetFilePath(const std::string &_filePath);
205
207 private: MaterialPrivate *dataPtr = nullptr;
208 };
209 }
210}
211#endif
This class contains visual material properties.
Definition Material.hh:46
void SetNormalMap(const std::string &_map)
Set the normal map filename.
bool Lighting() const
Get whether dynamic lighting is enabled.
ignition::math::Color Emissive() const
Get the emissive color.
Material()
Default constructor.
void SetDiffuse(const ignition::math::Color &_color) const
Set the diffuse color.
const std::string & FilePath() const
The path to the file where this element was loaded from.
std::string NormalMap() const
Get the normal map filename.
void SetDoubleSided(bool _doubleSided)
Set whether double sided material is enabled.
ignition::math::Color Diffuse() const
Get the diffuse color.
void SetPbrMaterial(const Pbr &_pbr)
Set the Physically Based Rendering (PBR) material.
Material & operator=(const Material &_material)
Assignment operator.
Material & operator=(Material &&_material)
Move assignment operator.
void SetScriptName(const std::string &_name)
Set the name of the material script.
ignition::math::Color Specular() const
Get the specular color.
Material(Material &&_material) noexcept
Move constructor.
Material(const Material &_material)
Copy constructor.
void SetShader(const ShaderType &_type)
Set the type of shader.
void SetAmbient(const ignition::math::Color &_color) const
Set the ambient color.
Errors Load(ElementPtr _sdf)
Load the material based on a element pointer.
void SetFilePath(const std::string &_filePath)
Set the path to the file where this element was loaded from.
std::string ScriptName() const
Get the name of the material script, or empty if one has not been specified.
sdf::ElementPtr Element() const
Get a pointer to the SDF element that was used during load.
Pbr * PbrMaterial() const
Get the Physically Based Rendering (PBR) material.
void SetLighting(const bool _lighting)
Set whether dynamic lighting is enabled.
void SetSpecular(const ignition::math::Color &_color) const
Set the specular color.
ShaderType Shader() const
Get the type of shader.
bool DoubleSided() const
Get whether double sided material is enabled.
std::string ScriptUri() const
Get the URI of the material script, if one has been set.
~Material()
Destructor.
void SetEmissive(const ignition::math::Color &_color) const
Set the emissive color.
void SetScriptUri(const std::string &_uri)
Set the URI of the material script.
ignition::math::Color Ambient() const
Get the ambient color.
This class provides access to Physically-Based-Rendering (PBR) material workflows.
Definition Pbr.hh:262
std::vector< Error > Errors
A vector of Error.
Definition Types.hh:89
ShaderType
Definition Material.hh:37
std::shared_ptr< Element > ElementPtr
Definition Element.hh:53
namespace for Simulation Description Format parser
Definition Actor.hh:33
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition system_util.hh:48