Ignition Rendering

API Reference

4.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 
26 
27 namespace ignition
28 {
29  namespace rendering
30  {
31  inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
32  //
33  // forward declaration
34  class Ogre2MaterialPrivate;
35 
37  class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Material :
38  public BaseMaterial<Ogre2Object>
39  {
41  protected: Ogre2Material();
42 
44  public: virtual ~Ogre2Material();
45 
46  // Documentation inherited
47  public: virtual void Destroy() override;
48 
49  // Documentation inherited
50  public: virtual math::Color Diffuse() const override;
51 
52  // Documentation inherited
53  public: virtual void SetDiffuse(const math::Color &_color) override;
54 
55  // Documentation inherited
56  public: virtual math::Color Specular() const override;
57 
58  // Documentation inherited
59  public: virtual void SetSpecular(const math::Color &_color) override;
60 
61  // Documentation inherited
62  public: virtual math::Color Emissive() const override;
63 
64  // Documentation inherited
65  public: virtual void SetEmissive(const math::Color &_color) override;
66 
67  // Documentation inherited
68  public: virtual void SetTransparency(const double _transparency) override;
69 
70  // Documentation inherited
71  public: virtual void SetAlphaFromTexture(bool _enabled,
72  double _alpha = 0.5, bool _twoSided = true) override;
73 
74  // Documentation inherited
75  public: virtual bool ReceiveShadows() const override;
76 
77  // Documentation inherited
78  public: virtual void SetReceiveShadows(const bool _receiveShadows)
79  override;
80 
81  // Documentation inherited
82  public: virtual bool HasTexture() const override;
83 
84  // Documentation inherited
85  public: virtual std::string Texture() const override;
86 
87  // Documentation inherited
88  public: virtual void SetTexture(const std::string &_name) override;
89 
90  // Documentation inherited
91  public: virtual void ClearTexture() override;
92 
93  // Documentation inherited
94  public: virtual bool HasNormalMap() const override;
95 
96  // Documentation inherited
97  public: virtual std::string NormalMap() const override;
98 
99  // Documentation inherited
100  public: virtual void SetNormalMap(const std::string &_name) override;
101 
102  // Documentation inherited
103  public: virtual void ClearNormalMap() override;
104 
105  // Documentation inherited
106  public: virtual bool HasRoughnessMap() const override;
107 
108  // Documentation inherited
109  public: virtual std::string RoughnessMap() const override;
110 
111  // Documentation inherited
112  public: virtual void SetRoughnessMap(const std::string &_name) override;
113 
114  // Documentation inherited
115  public: virtual void ClearRoughnessMap() override;
116 
117  // Documentation inherited
118  public: virtual bool HasMetalnessMap() const override;
119 
120  // Documentation inherited
121  public: virtual std::string MetalnessMap() const override;
122 
123  // Documentation inherited
124  public: virtual void SetMetalnessMap(const std::string &_name) override;
125 
126  // Documentation inherited
127  public: virtual void ClearMetalnessMap() override;
128 
129  // Documentation inherited
130  public: virtual bool HasEnvironmentMap() const override;
131 
132  // Documentation inherited
133  public: virtual std::string EnvironmentMap() const override;
134 
135  // Documentation inherited
136  public: virtual void SetEnvironmentMap(const std::string &_name) override;
137 
138  // Documentation inherited
139  public: virtual void ClearEnvironmentMap() override;
140 
141  // Documentation inherited
142  public: virtual void SetRoughness(const float _roughness) override;
143 
144  // Documentation inherited
145  public: virtual bool HasEmissiveMap() const override;
146 
147  // Documentation inherited
148  public: virtual std::string EmissiveMap() const override;
149 
150  // Documentation inherited
151  public: virtual void SetEmissiveMap(const std::string &_name) override;
152 
153  // Documentation inherited
154  public: virtual void ClearEmissiveMap() override;
155 
156  // Documentation inherited
157  public: virtual float Roughness() const override;
158 
159  // Documentation inherited
160  public: virtual void SetMetalness(const float _roughness) override;
161 
162  // Documentation inherited
163  public: virtual float Metalness() const override;
164 
167  public: virtual Ogre::MaterialPtr Material();
168 
171  public: virtual Ogre::HlmsPbsDatablock *Datablock() const;
172 
175  public: virtual Ogre::HlmsUnlitDatablock *UnlitDatablock();
176 
180  public: virtual void FillUnlitDatablock(
181  Ogre::HlmsUnlitDatablock *_datablock) const;
182 
183  // Documentation inherited.
184  // \sa BaseMaterial::PreRender()
185  public: virtual void PreRender() override;
186 
187  // Documentation inherited.
188  public: virtual enum MaterialType Type() const override;
189 
190  // Documentation inherited
191  public: virtual bool DepthCheckEnabled() const override;
192 
193  // Documentation inherited
194  public: virtual void SetDepthCheckEnabled(bool _enabled) override;
195 
196  // Documentation inherited
197  public: virtual bool DepthWriteEnabled() const override;
198 
199  // Documentation inherited
200  public: virtual void SetDepthWriteEnabled(bool _enabled) override;
201 
206  protected: virtual void SetTextureMapImpl(const std::string &_texture,
207  Ogre::PbsTextureTypes _type);
208 
211  protected: virtual Ogre::TexturePtr Texture(const std::string &_name);
212 
215  protected: virtual void UpdateTransparency();
216 
217  // Documentation inherited.
218  protected: virtual void Init() override;
219 
221  protected: Ogre::MaterialPtr ogreMaterial;
222 
224  protected: Ogre::HlmsPbsDatablock *ogreDatablock = nullptr;
225 
227  protected: Ogre::HlmsUnlitDatablock *ogreUnlitDatablock = nullptr;
228 
230  protected: Ogre::HlmsPbs *ogreHlmsPbs = nullptr;
231 
234 
237 
240 
243 
246 
249 
252 
254  private: std::unique_ptr<Ogre2MaterialPrivate> dataPtr;
255 
257  private: friend class Ogre2Scene;
258  };
259  }
260  }
261 }
262 #endif
std::string roughnessMapName
Name of the roughness map.
Definition: Ogre2Material.hh:239
Ogre2.x implementation of the scene class.
Definition: Ogre2Scene.hh:45
STL class.
std::string normalMapName
Name of the normal map.
Definition: Ogre2Material.hh:236
Ogre::MaterialPtr ogreMaterial
Ogre material. Mainly used for render targets.
Definition: Ogre2Material.hh:221
Ogre 2.x implementation of the material class.
Definition: Ogre2Material.hh:37
std::string environmentMapName
Name of the environment map.
Definition: Ogre2Material.hh:245
std::string emissiveMapName
Name of the emissive map.
Definition: Ogre2Material.hh:248
std::string textureName
Name of the texture.
Definition: Ogre2Material.hh:233
Definition: BaseMaterial.hh:38
std::string ogreDatablockId
Unique id assigned to ogre hlms datablock.
Definition: Ogre2Material.hh:251
Represents a surface material of a Geometry.
Definition: Material.hh:47
std::string metalnessMapName
Name of the metalness map.
Definition: Ogre2Material.hh:242
MaterialType
An enum for the type of material.
Definition: Material.hh:36