File: Pbr.hh

package info (click to toggle)
sdformat 9.3.0%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 5,708 kB
  • sloc: cpp: 42,166; python: 1,618; javascript: 704; ruby: 368; sh: 81; ansic: 37; makefile: 16
file content (298 lines) | stat: -rw-r--r-- 11,124 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
/*
 * Copyright 2019 Open Source Robotics Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
#ifndef SDF_PBR_HH_
#define SDF_PBR_HH_

#include <string>
#include "sdf/Element.hh"
#include "sdf/Types.hh"
#include "sdf/sdf_config.h"
#include "sdf/system_util.hh"

namespace sdf
{
  // Inline bracke to help doxygen filtering.
  inline namespace SDF_VERSION_NAMESPACE {
  //
  // Forward declarations.
  class PbrPrivate;
  class PbrWorkflowPrivate;

  /// \brief Type of PBR workflow.
  enum class PbrWorkflowType : int
  {
    /// \brief No workflow
    NONE = 0,

    /// \brief Metal/Roughness workflow
    METAL = 1,

    /// \brief Specular/Glossiness workflow
    SPECULAR = 2,
  };

  /// \brief Space the normal map is defined in
  enum class NormalMapSpace: int
  {
    /// \brief Tangent space
    TANGENT = 0,

    /// \brief Object space
    OBJECT = 1,
  };

  /// \brief This class contains Physically-Based-Rendering (PBR) workflow
  /// properties.
  class SDFORMAT_VISIBLE PbrWorkflow
  {
    /// \brief Default constructor
    public: PbrWorkflow();

    /// \brief Copy constructor
    /// \param[in] _workflow Workflow to copy.
    public: PbrWorkflow(const PbrWorkflow &_workflow);

    /// \brief Move constructor
    /// \param[in] _workflow to move.
    public: PbrWorkflow(PbrWorkflow &&_workflow) noexcept;

    /// \brief Destructor
    public: ~PbrWorkflow();

    /// \brief Load the pbr workflow based on an element pointer. This is *not*
    /// the usual entry point. Typical usage of the SDF DOM is through the Root
    /// object.
    /// \param[in] _sdf The SDF Element pointer
    /// \return Errors, which is a vector of Error objects. Each Error includes
    /// an error code and message. An empty vector indicates no error.
    public: Errors Load(ElementPtr _sdf);

    /// \brief Assignment operator.
    /// \param[in] _workflow The workflow to set values from.
    /// \return *this
    public: PbrWorkflow &operator=(const PbrWorkflow &_workflow);

    /// \brief Move assignment operator.
    /// \param[in] _workflow The workflow to move from.
    /// \return *this
    public: PbrWorkflow &operator=(PbrWorkflow &&_workflow);

    /// \brief Return true if both PbrWorkflow objects contain the same values.
    /// \param[_in] _workflow PbrWorkflow value to compare.
    /// \returen True if 'this' == _workflow.
    public: bool operator==(const PbrWorkflow &_workflow) const;

    /// \brief Return true this PbrWorkflow object does not contain the same
    /// values as the passed in parameter.
    /// \param[_in] _workflow PbrWorkflow value to compare.
    /// \returen True if 'this' != _workflow.
    public: bool operator!=(const PbrWorkflow &_workflow) const;

    /// \brief Get the albedo map filename. This will be an empty string if
    /// an albedo map has not been set.
    /// \return Filename of the albedo map, or empty string if an albedo map
    /// has not been specified.
    public: std::string AlbedoMap() const;

    /// \brief Set the albedo map filename.
    /// \param[in] _map Filename of the albedo map.
    public: void SetAlbedoMap(const std::string &_map);

    /// \brief Get the normal map filename. This will be an empty string if
    /// a normal map has not been set.
    /// \return Filename of the normal map, or empty string if a normal map
    /// has not been specified.
    public: std::string NormalMap() const;

    /// \brief Set the normal map filename.
    /// \param[in] _map Filename of the normal map.
    /// \param[in] _space Space that the normal map is defined in.
    /// Defaults to tangent space.
    public: void SetNormalMap(const std::string &_map,
        NormalMapSpace _space = NormalMapSpace::TANGENT);

    /// \brief Get the normal map type, either tangent or object space
    /// \return Space that the normal map is defined in
    public: NormalMapSpace NormalMapType() const;

    /// \brief Get the environment map filename. This will be an empty string
    /// if an environment map has not been set.
    /// \return Filename of the environment map, or empty string if an
    /// environment map has not been specified.
    public: std::string EnvironmentMap() const;

    /// \brief Set the environment map filename.
    /// \param[in] _map Filename of the environment map.
    public: void SetEnvironmentMap(const std::string &_map);

    /// \brief Get the ambient occlusion map filename. This will be an empty
    /// string if an ambient occlusion map has not been set.
    /// \return Filename of the ambient occlusion map, or empty string if an
    /// ambient occlusion map has not been specified.
    public: std::string AmbientOcclusionMap() const;

    /// \brief Set the ambient occlusion map filename.
    /// \param[in] _map Filename of the ambient occlusion map.
    public: void SetAmbientOcclusionMap(const std::string &_map);

    /// \brief Get the roughness map filename for metal workflow. This will be
    /// an empty string if a roughness map has not been set.
    /// \return Filename of the roughness map, or empty string if a roughness
    /// map has not been specified.
    public: std::string RoughnessMap() const;

    /// \brief Set the roughness map filename for metal workflow.
    /// \param[in] _map Filename of the roughness map.
    public: void SetRoughnessMap(const std::string &_map);

    /// \brief Get the metalness map filename for metal workflow. This will be
    /// an empty string if a metalness map has not been set.
    /// \return Filename of the metalness map, or empty string if a metalness
    /// map has not been specified.
    public: std::string MetalnessMap() const;

    /// \brief Set the metalness map filename for metal workflow.
    /// \param[in] _map Filename of the metalness map.
    public: void SetMetalnessMap(const std::string &_map);

    /// \brief Get the emissive map filename. This will be an empty string
    /// if an emissive map has not been set.
    /// \return Filename of the emissive map, or empty string if an emissive
    /// map has not been specified.
    public: std::string EmissiveMap() const;

    /// \brief Set the emissive map filename.
    /// \param[in] _map Filename of the emissive map.
    public: void SetEmissiveMap(const std::string &_map);

    /// \brief Get the metalness value of the material for metal workflow
    /// \return metalness value of the material
    public: double Metalness() const;

    /// \brief Set the metalness value of the material for metal workflow.
    /// \param[in] _value Metalness value.
    public: void SetMetalness(const double _value);

    /// \brief Get the roughness value of the material for metal workflow
    /// \return roughness value of the material
    public: double Roughness() const;

    /// \brief Set the roughness value of the material for metal workflow.
    /// \param[in] _value Roughness value.
    public: void SetRoughness(const double _value);

    /// \brief Get the glossiness map filename for specular workflow. This will
    /// be an empty string if a glossiness map has not been set.
    /// \return Filename of the glossiness map, or empty string if a glossiness
    /// map has not been specified.
    public: std::string GlossinessMap() const;

    /// \brief Set the glossiness map filename for specular workflow.
    /// \param[in] _map Filename of the glossiness map.
    public: void SetGlossinessMap(const std::string &_map);

    /// \brief Get the glossiness value of the material for specular workflow
    /// \return Glossiness value of the material
    public: double Glossiness() const;

    /// \brief Set the glossiness value of the material for specular workflow.
    /// \param[in] _value Glossiness value.
    public: void SetGlossiness(const double _value);

    /// \brief Get the specular map filename for specular workflow. This will
    /// be an empty string if a specular map has not been set.
    /// \return Filename of the specular map, or empty string if a specular
    /// map has not been specified.
    public: std::string SpecularMap() const;

    /// \brief Set the specular map filename for specular workflow.
    /// \param[in] _map Filename of the specular map.
    public: void SetSpecularMap(const std::string &_map);

    /// \brief Get a pointer to the SDF element that was used during
    /// load.
    /// \return SDF element pointer. The value will be nullptr if Load has
    /// not been called.
    public: sdf::ElementPtr Element() const;

    /// \brief Get the workflow type.
    /// \return PBR workflow type.
    public: PbrWorkflowType Type() const;

    /// \brief Set the PBR workflow to use
    /// \param[in] _type Workflow type to use
    public: void SetType(PbrWorkflowType _type);

    /// \brief Private data pointer.
    private: PbrWorkflowPrivate *dataPtr = nullptr;
  };

  /// \brief This class provides access to Physically-Based-Rendering (PBR)
  ///  material workflows.
  class SDFORMAT_VISIBLE Pbr
  {
    /// \brief Default constructor
    public: Pbr();

    /// \brief Copy constructor
    /// \param[in] _pbr Pbr to copy.
    public: Pbr(const Pbr &_pbr);

    /// \brief Move constructor
    /// \param[in] _pbr Pbr to move.
    public: Pbr(Pbr &&_pbr) noexcept;

    /// \brief Destructor
    public: ~Pbr();

    /// \brief Assignment operator.
    /// \param[in] _pbr The pbr to set values from.
    /// \return *this
    public: Pbr &operator=(const Pbr &_pbr);

    /// \brief Move assignment operator.
    /// \param[in] _pbr The pbr to move values from.
    /// \return *this
    public: Pbr &operator=(Pbr &&_pbr);

    /// \brief Load the pbr based on an element pointer. This is *not* the
    /// usual entry point. Typical usage of the SDF DOM is through the Root
    /// object.
    /// \param[in] _sdf The SDF Element pointer
    /// \return Errors, which is a vector of Error objects. Each Error includes
    /// an error code and message. An empty vector indicates no error.
    public: Errors Load(ElementPtr _sdf);

    /// \brief Set a PBR workflow by type
    /// \param[in] _type Type of PBR workflow
    /// \param[in] _workflow Workflow of the specified type.
    /// \sa PbrWorkflowType
    public: void SetWorkflow(PbrWorkflowType _type,
        const PbrWorkflow &_workflow);

    /// \brief Get a PBR workflow by type
    /// \param[in] _type Type of PBR workflow
    /// \return Workflow of the specified type.
    /// \sa PbrWorkflowType
    public: PbrWorkflow *Workflow(PbrWorkflowType _type) const;

    /// \brief Private data pointer.
    private: PbrPrivate *dataPtr = nullptr;
  };
  }
}
#endif