Ignition Rendering

API Reference

5.0.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 &_name) 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 &_name) 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(const std::string &_name) override;
135 
136  // Documentation inherited
137  public: virtual void ClearRoughnessMap() override;
138 
139  // Documentation inherited
140  public: virtual bool HasMetalnessMap() const override;
141 
142  // Documentation inherited
143  public: virtual std::string MetalnessMap() const override;
144 
145  // Documentation inherited
146  public: virtual void SetMetalnessMap(const std::string &_name) override;
147 
148  // Documentation inherited
149  public: virtual void ClearMetalnessMap() override;
150 
151  // Documentation inherited
152  public: virtual bool HasEnvironmentMap() const override;
153 
154  // Documentation inherited
155  public: virtual std::string EnvironmentMap() const override;
156 
157  // Documentation inherited
158  public: virtual void SetEnvironmentMap(const std::string &_name) override;
159 
160  // Documentation inherited
161  public: virtual void ClearEnvironmentMap() override;
162 
163  // Documentation inherited
164  public: virtual void SetRoughness(const float _roughness) override;
165 
166  // Documentation inherited
167  public: virtual bool HasEmissiveMap() const override;
168 
169  // Documentation inherited
170  public: virtual std::string EmissiveMap() const override;
171 
172  // Documentation inherited
173  public: virtual void SetEmissiveMap(const std::string &_name) override;
174 
175  // Documentation inherited
176  public: virtual void ClearEmissiveMap() override;
177 
178  // Documentation inherited
179  public: virtual bool HasLightMap() const override;
180 
181  // Documentation inherited
182  public: virtual std::string LightMap() const override;
183 
184  // Documentation inherited
185  public: virtual unsigned int LightMapTexCoordSet() const override;
186 
187  // Documentation inherited
188  public: virtual void SetLightMap(const std::string &_name,
189  unsigned int _uvSet = 0u) override;
190 
191  // Documentation inherited
192  public: virtual void ClearLightMap() override;
193 
194  // Documentation inherited
195  public: virtual float Roughness() const override;
196 
197  // Documentation inherited
198  public: virtual void SetMetalness(const float _roughness) override;
199 
200  // Documentation inherited
201  public: virtual float Metalness() const override;
202 
205  public: virtual Ogre::MaterialPtr Material();
206 
209  public: virtual Ogre::HlmsPbsDatablock *Datablock() const;
210 
213  public: virtual Ogre::HlmsUnlitDatablock *UnlitDatablock();
214 
218  public: virtual void FillUnlitDatablock(
219  Ogre::HlmsUnlitDatablock *_datablock) const;
220 
221  // Documentation inherited.
222  // \sa BaseMaterial::PreRender()
223  public: virtual void PreRender() override;
224 
225  // Documentation inherited.
226  public: virtual enum MaterialType Type() const override;
227 
228  // Documentation inherited
229  public: virtual bool DepthCheckEnabled() const override;
230 
231  // Documentation inherited
232  public: virtual void SetDepthCheckEnabled(bool _enabled) override;
233 
234  // Documentation inherited
235  public: virtual bool DepthWriteEnabled() const override;
236 
237  // Documentation inherited
238  public: virtual void SetDepthWriteEnabled(bool _enabled) override;
239 
244  protected: virtual void SetTextureMapImpl(const std::string &_texture,
245  Ogre::PbsTextureTypes _type);
246 
249  protected: virtual Ogre::TexturePtr Texture(const std::string &_name);
250 
253  protected: virtual void UpdateTransparency();
254 
255  // Documentation inherited.
256  protected: virtual void Init() override;
257 
259  protected: Ogre::MaterialPtr ogreMaterial;
260 
262  protected: Ogre::HlmsPbsDatablock *ogreDatablock = nullptr;
263 
265  protected: Ogre::HlmsUnlitDatablock *ogreUnlitDatablock = nullptr;
266 
268  protected: Ogre::HlmsPbs *ogreHlmsPbs = nullptr;
269 
272 
275 
278 
281 
284 
287 
290 
292  protected: unsigned int lightMapUvSet = 0u;
293 
296 
298  private: std::unique_ptr<Ogre2MaterialPrivate> dataPtr;
299 
301  private: friend class Ogre2Scene;
302  };
303  }
304  }
305 }
306 #endif
std::string roughnessMapName
Name of the roughness map.
Definition: Ogre2Material.hh:277
std::string lightMapName
Name of the light map.
Definition: Ogre2Material.hh:289
Ogre2.x implementation of the scene class.
Definition: Ogre2Scene.hh:56
STL class.
std::string normalMapName
Name of the normal map.
Definition: Ogre2Material.hh:274
Ogre::MaterialPtr ogreMaterial
Ogre material. Mainly used for render targets.
Definition: Ogre2Material.hh:259
Ogre 2.x implementation of the material class.
Definition: Ogre2Material.hh:51
std::string environmentMapName
Name of the environment map.
Definition: Ogre2Material.hh:283
std::string emissiveMapName
Name of the emissive map.
Definition: Ogre2Material.hh:286
Definition: OgreCamera.hh:27
std::string textureName
Name of the texture.
Definition: Ogre2Material.hh:271
Definition: BaseMaterial.hh:38
std::string ogreDatablockId
Unique id assigned to ogre hlms datablock.
Definition: Ogre2Material.hh:295
Represents a surface material of a Geometry.
Definition: Material.hh:47
std::string metalnessMapName
Name of the metalness map.
Definition: Ogre2Material.hh:280
MaterialType
An enum for the type of material.
Definition: Material.hh:36