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 <gz/utils/ImplPtr.hh>
22#include "sdf/Element.hh"
23#include "sdf/Types.hh"
24#include "sdf/sdf_config.h"
25#include "sdf/system_util.hh"
26
27namespace sdf
28{
29 // Inline bracket to help doxygen filtering.
30 inline namespace SDF_VERSION_NAMESPACE {
31 //
32
33 // Forward declarations.
34 class ParserConfig;
35 class Pbr;
36
37 enum class ShaderType : int
38 {
39 PIXEL = 0,
40 VERTEX = 1,
43 };
44
47 {
49 public: Material();
50
57 public: Errors Load(ElementPtr _sdf);
58
66 public: Errors Load(sdf::ElementPtr _sdf, const ParserConfig &_config);
67
72 public: gz::math::Color Ambient() const;
73
78 public: void SetAmbient(const gz::math::Color &_color);
79
84 public: gz::math::Color Diffuse() const;
85
90 public: void SetDiffuse(const gz::math::Color &_color);
91
96 public: gz::math::Color Specular() const;
97
102 public: void SetSpecular(const gz::math::Color &_color);
103
106 public: double Shininess() const;
107
110 public: void SetShininess(const double _shininess);
111
116 public: gz::math::Color Emissive() const;
117
122 public: void SetEmissive(const gz::math::Color &_color);
123
128 public: float RenderOrder() const;
129
133 public: void SetRenderOrder(const float _renderOrder);
134
138 public: bool Lighting() const;
139
142 public: void SetLighting(const bool _lighting);
143
147 public: bool DoubleSided() const;
148
151 public: void SetDoubleSided(bool _doubleSided);
152
157 public: sdf::ElementPtr Element() const;
158
162 public: std::string ScriptUri() const;
163
166 public: void SetScriptUri(const std::string &_uri);
167
173 public: std::string ScriptName() const;
174
178 public: void SetScriptName(const std::string &_name);
179
182 public: ShaderType Shader() const;
183
186 public: void SetShader(const ShaderType &_type);
187
192 public: std::string NormalMap() const;
193
196 public: void SetNormalMap(const std::string &_map);
197
200 public: void SetPbrMaterial(const Pbr &_pbr);
201
204 public: const Pbr *PbrMaterial() const;
205
208 public: const std::string &FilePath() const;
209
212 public: void SetFilePath(const std::string &_filePath);
213
219 public: sdf::ElementPtr ToElement() const;
220
227 public: sdf::ElementPtr ToElement(sdf::Errors &_errors) const;
228
230 GZ_UTILS_IMPL_PTR(dataPtr)
231 };
232 }
233}
234#endif
This class contains visual material properties.
Definition Material.hh:47
double Shininess() const
Get the specular exponent.
gz::math::Color Emissive() const
Get the emissive color.
std::string ScriptUri() const
Get the URI of the material script, if one has been set.
gz::math::Color Diffuse() const
Get the diffuse color.
std::string ScriptName() const
Get the name of the material script, or empty if one has not been specified.
void SetRenderOrder(const float _renderOrder)
Set render order.
gz::math::Color Ambient() const
Get the ambient color.
Errors Load(sdf::ElementPtr _sdf, const ParserConfig &_config)
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.
const std::string & FilePath() const
The path to the file where this element was loaded from.
void SetNormalMap(const std::string &_map)
Set the normal map filename.
const Pbr * PbrMaterial() const
Get the Physically Based Rendering (PBR) material.
bool DoubleSided() const
Get whether double sided material is enabled.
void SetEmissive(const gz::math::Color &_color)
Set the emissive color.
void SetScriptName(const std::string &_name)
Set the name of the material script.
void SetAmbient(const gz::math::Color &_color)
Set the ambient color.
void SetScriptUri(const std::string &_uri)
Set the URI of the material script.
Errors Load(ElementPtr _sdf)
Load the material based on a element pointer.
sdf::ElementPtr ToElement() const
Create and return an SDF element filled with data from this material.
void SetPbrMaterial(const Pbr &_pbr)
Set the Physically Based Rendering (PBR) material.
void SetDiffuse(const gz::math::Color &_color)
Set the diffuse color.
sdf::ElementPtr Element() const
Get a pointer to the SDF element that was used during load.
gz::math::Color Specular() const
Get the specular color.
void SetDoubleSided(bool _doubleSided)
Set whether double sided material is enabled.
bool Lighting() const
Get whether dynamic lighting is enabled.
void SetSpecular(const gz::math::Color &_color)
Set the specular color.
std::string NormalMap() const
Get the normal map filename.
sdf::ElementPtr ToElement(sdf::Errors &_errors) const
Create and return an SDF element filled with data from this material.
void SetLighting(const bool _lighting)
Set whether dynamic lighting is enabled.
ShaderType Shader() const
Get the type of shader.
void SetShader(const ShaderType &_type)
Set the type of shader.
float RenderOrder() const
Get render order for coplanar polygons.
void SetShininess(const double _shininess)
Set the specular exponent.
This class contains configuration options for the libsdformat parser.
Definition ParserConfig.hh:106
This class provides access to Physically-Based-Rendering (PBR) material workflows.
Definition Pbr.hh:239
std::vector< Error > Errors
A vector of Error.
Definition Types.hh:81
std::shared_ptr< Element > ElementPtr
Definition Element.hh:55
ShaderType
Definition Material.hh:38
namespace for Simulation Description Format parser
Definition Actor.hh:35
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition system_util.hh:25