Ignition Rendering

API Reference

5.1.0
Ogre2Material.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 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 IGNITION_RENDERING_OGRE2_OGRE2MATERIAL_HH_
18 #define IGNITION_RENDERING_OGRE2_OGRE2MATERIAL_HH_
19 
20 #include <memory>
21 #include <string>
22 
25 
26 #ifdef _MSC_VER
27  #pragma warning(push, 0)
28 #endif
29 #include <Hlms/Pbs/OgreHlmsPbsPrerequisites.h>
30 #include <OgreMaterial.h>
31 #ifdef _MSC_VER
32  #pragma warning(pop)
33 #endif
34 
35 namespace Ogre
36 {
37  class HlmsPbsDatablock;
38  class HlmsUnlitDatablock;
39 } // namespace Ogre
40 
41 namespace ignition
42 {
43  namespace rendering
44  {
45  inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
46  //
47  // forward declaration
48  class Ogre2MaterialPrivate;
49 
51  class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Material :
52  public BaseMaterial<Ogre2Object>
53  {
55  protected: Ogre2Material();
56 
58  public: virtual ~Ogre2Material();
59 
60  // Documentation inherited
61  public: virtual void Destroy() override;
62 
63  // Documentation inherited
64  public: virtual math::Color Diffuse() const override;
65 
66  // Documentation inherited
67  public: virtual void SetDiffuse(const math::Color &_color) override;
68 
69  // Documentation inherited
70  public: virtual math::Color Specular() const override;
71 
72  // Documentation inherited
73  public: virtual void SetSpecular(const math::Color &_color) override;
74 
75  // Documentation inherited
76  public: virtual math::Color Emissive() const override;
77 
78  // Documentation inherited
79  public: virtual void SetEmissive(const math::Color &_color) override;
80 
81  // Documentation inherited
82  public: virtual void SetTransparency(const double _transparency) override;
83 
84  // Documentation inherited
85  public: virtual void SetAlphaFromTexture(bool _enabled,
86  double _alpha = 0.5, bool _twoSided = true) override;
87 
88  // Documentation inherited
89  public: virtual float RenderOrder() const override;
90 
91  // Documentation inherited
92  // Review the official documentation to get more details about this
93  // parameter, in particular mDepthBiasConstant
94  public: virtual void SetRenderOrder(const float _renderOrder) override;
95 
96  // Documentation inherited
97  public: virtual bool ReceiveShadows() const override;
98 
99  // Documentation inherited
100  public: virtual void SetReceiveShadows(const bool _receiveShadows)
101  override;
102 
103  // Documentation inherited
104  public: virtual bool HasTexture() const override;
105 
106  // Documentation inherited
107  public: virtual std::string Texture() const override;
108 
109  // Documentation inherited
110  public: virtual void SetTexture(const std::string &_texture) override;
111 
112  // Documentation inherited
113  public: virtual void ClearTexture() override;
114 
115  // Documentation inherited
116  public: virtual bool HasNormalMap() const override;
117 
118  // Documentation inherited
119  public: virtual std::string NormalMap() const override;
120 
121  // Documentation inherited
122  public: virtual void SetNormalMap(const std::string &_normalMap) override;
123 
124  // Documentation inherited
125  public: virtual void ClearNormalMap() override;
126 
127  // Documentation inherited
128  public: virtual bool HasRoughnessMap() const override;
129 
130  // Documentation inherited
131  public: virtual std::string RoughnessMap() const override;
132 
133  // Documentation inherited
134  public: virtual void SetRoughnessMap(
135  const std::string &_roughnessMap) override;
136 
137  // Documentation inherited
138  public: virtual void ClearRoughnessMap() override;
139 
140  // Documentation inherited
141  public: virtual bool HasMetalnessMap() const override;
142 
143  // Documentation inherited
144  public: virtual std::string MetalnessMap() const override;
145 
146  // Documentation inherited
147  public: virtual void SetMetalnessMap(
148  const std::string &_metalnessMap) override;
149 
150  // Documentation inherited
151  public: virtual void ClearMetalnessMap() override;
152 
153  // Documentation inherited
154  public: virtual bool HasEnvironmentMap() const override;
155 
156  // Documentation inherited
157  public: virtual std::string EnvironmentMap() const override;
158 
159  // Documentation inherited
160  public: virtual void SetEnvironmentMap(
161  const std::string &_metalnessMap) override;
162 
163  // Documentation inherited
164  public: virtual void ClearEnvironmentMap() override;
165 
166  // Documentation inherited
167  public: virtual void SetRoughness(const float _roughness) override;
168 
169  // Documentation inherited
170  public: virtual bool HasEmissiveMap() const override;
171 
172  // Documentation inherited
173  public: virtual std::string EmissiveMap() const override;
174 
175  // Documentation inherited
176  public: virtual void SetEmissiveMap(
177  const std::string &_emissiveMap) override;
178 
179  // Documentation inherited
180  public: virtual void ClearEmissiveMap() override;
181 
182  // Documentation inherited
183  public: virtual bool HasLightMap() const override;
184 
185  // Documentation inherited
186  public: virtual std::string LightMap() const override;
187 
188  // Documentation inherited
189  public: virtual unsigned int LightMapTexCoordSet() const override;
190 
191  // Documentation inherited
192  public: virtual void SetLightMap(const std::string &_lightMap,
193  unsigned int _uvSet = 0u) override;
194 
195  // Documentation inherited
196  public: virtual void ClearLightMap() override;
197 
198  // Documentation inherited
199  public: virtual float Roughness() const override;
200 
201  // Documentation inherited
202  public: virtual void SetMetalness(const float _roughness) override;
203 
204  // Documentation inherited
205  public: virtual float Metalness() const override;
206 
209  public: virtual Ogre::MaterialPtr Material();
210 
213  public: virtual Ogre::HlmsPbsDatablock *Datablock() const;
214 
217  public: virtual Ogre::HlmsUnlitDatablock *UnlitDatablock();
218 
222  public: virtual void FillUnlitDatablock(
223  Ogre::HlmsUnlitDatablock *_datablock) const;
224 
225  // Documentation inherited.
226  // \sa BaseMaterial::PreRender()
227  public: virtual void PreRender() override;
228 
229  // Documentation inherited.
230  public: virtual enum MaterialType Type() const override;
231 
232  // Documentation inherited
233  public: virtual bool DepthCheckEnabled() const override;
234 
235  // Documentation inherited
236  public: virtual void SetDepthCheckEnabled(bool _enabled) override;
237 
238  // Documentation inherited
239  public: virtual bool DepthWriteEnabled() const override;
240 
241  // Documentation inherited
242  public: virtual void SetDepthWriteEnabled(bool _enabled) override;
243 
248  protected: virtual void SetTextureMapImpl(const std::string &_texture,
249  Ogre::PbsTextureTypes _type);
250 
253  protected: virtual Ogre::TexturePtr Texture(const std::string &_name);
254 
257  protected: virtual void UpdateTransparency();
258 
259  // Documentation inherited.
260  protected: virtual void Init() override;
261 
263  protected: Ogre::MaterialPtr ogreMaterial;
264 
266  protected: Ogre::HlmsPbsDatablock *ogreDatablock = nullptr;
267 
269  protected: Ogre::HlmsUnlitDatablock *ogreUnlitDatablock = nullptr;
270 
272  protected: Ogre::HlmsPbs *ogreHlmsPbs = nullptr;
273 
276 
279 
282 
285 
288 
291 
294 
296  protected: unsigned int lightMapUvSet = 0u;
297 
300 
302  private: std::unique_ptr<Ogre2MaterialPrivate> dataPtr;
303 
305  private: friend class Ogre2Scene;
306  };
307  }
308  }
309 }
310 #endif
std::string roughnessMapName
Name of the roughness map.
Definition: Ogre2Material.hh:281
std::string lightMapName
Name of the light map.
Definition: Ogre2Material.hh:293
Ogre2.x implementation of the scene class.
Definition: Ogre2Scene.hh:56
STL class.
std::string normalMapName
Name of the normal map.
Definition: Ogre2Material.hh:278
Ogre::MaterialPtr ogreMaterial
Ogre material. Mainly used for render targets.
Definition: Ogre2Material.hh:263
Ogre 2.x implementation of the material class.
Definition: Ogre2Material.hh:51
std::string environmentMapName
Name of the environment map.
Definition: Ogre2Material.hh:287
std::string emissiveMapName
Name of the emissive map.
Definition: Ogre2Material.hh:290
Definition: OgreCamera.hh:27
std::string textureName
Name of the texture.
Definition: Ogre2Material.hh:275
Definition: BaseMaterial.hh:38
std::string ogreDatablockId
Unique id assigned to ogre hlms datablock.
Definition: Ogre2Material.hh:299
Represents a surface material of a Geometry.
Definition: Material.hh:47
std::string metalnessMapName
Name of the metalness map.
Definition: Ogre2Material.hh:284
MaterialType
An enum for the type of material.
Definition: Material.hh:36