Gazebo Rendering

API Reference

6.6.3
gz/rendering/ogre/OgreMaterial.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 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 GZ_RENDERING_OGRE_OGREMATERIAL_HH_
18 #define GZ_RENDERING_OGRE_OGREMATERIAL_HH_
19 
20 #include <string>
21 
22 #include <gz/common/SuppressWarning.hh>
23 
27 
28 namespace ignition
29 {
30  namespace rendering
31  {
32  inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
33  // TODO(anyone): use a better way to find shader configurations
35  "depth_vertex_shader.glsl";
37  "depth_fragment_shader.glsl";
38 
39  class IGNITION_RENDERING_OGRE_VISIBLE OgreMaterial :
40  public BaseMaterial<OgreObject>
41  {
42  protected: OgreMaterial();
43 
44  public: virtual ~OgreMaterial();
45 
46  // Documentation inherited
47  public: virtual void Destroy() override;
48 
49  public: virtual bool LightingEnabled() const override;
50 
51  public: virtual void SetLightingEnabled(const bool _enabled) override;
52 
53  // Documentation inherited
54  public: virtual bool DepthCheckEnabled() const override;
55 
56  // Documentation inherited
57  public: virtual void SetDepthCheckEnabled(bool _enabled) override;
58 
59  // Documentation inherited
60  public: virtual bool DepthWriteEnabled() const override;
61 
62  // Documentation inherited
63  public: virtual void SetDepthWriteEnabled(bool _enabled) override;
64 
65  public: virtual math::Color Ambient() const override;
66 
67  public: virtual void SetAmbient(const math::Color &_color) override;
68 
69  public: virtual math::Color Diffuse() const override;
70 
71  public: virtual void SetDiffuse(const math::Color &_color) override;
72 
73  public: virtual math::Color Specular() const override;
74 
75  public: virtual void SetSpecular(const math::Color &_color) override;
76 
77  public: virtual math::Color Emissive() const override;
78 
79  public: virtual void SetEmissive(const math::Color &_color) override;
80 
81  public: virtual double Shininess() const override;
82 
83  public: virtual void SetShininess(const double _shininess) override;
84 
85  public: virtual double Transparency() const override;
86 
87  public: virtual void SetTransparency(const double _transparency)
88  override;
89 
90  // Documentation inherited
91  public: virtual void SetAlphaFromTexture(bool _enabled,
92  double _alpha = 0.5, bool _twoSided = true) override;
93 
94  public: virtual double Reflectivity() const override;
95 
96  public: virtual void SetReflectivity(const double _reflectivity)
97  override;
98 
99  public: virtual bool CastShadows() const override;
100 
101  // Documentation inherited.
102  public: virtual void SetCastShadows(const bool _castShadows) override;
103 
104  public: virtual bool ReceiveShadows() const override;
105 
106  public: virtual void SetReceiveShadows(const bool _receiveShadows)
107  override;
108 
109  // Documentation inherited
110  public: virtual float RenderOrder() const override;
111 
112  // Documentation inherited
113  // Review the official documentation to get more details about this
114  // parameter, in particular Ogre::Pass::setDepthBias()
115  // https://www.ogre3d.org/docs/api/1.8/class_ogre_1_1_pass.html
116  public: virtual void SetRenderOrder(const float _renderOrder) override;
117 
118  public: virtual bool ReflectionEnabled() const override;
119 
120  public: virtual void SetReflectionEnabled(const bool _enabled) override;
121 
122  public: virtual bool HasTexture() const override;
123 
124  public: virtual std::string Texture() const override;
125 
126  // Documentation inherited.
127  public: virtual void SetTexture(const std::string &_texture) override;
128 
129  public: virtual void ClearTexture() override;
130 
131  public: virtual bool HasNormalMap() const override;
132 
133  public: virtual std::string NormalMap() const override;
134 
135  // Documentation inherited.
136  public: virtual void SetNormalMap(const std::string &_normalMap) override;
137 
138  public: virtual void ClearNormalMap() override;
139 
140  public: virtual enum ShaderType ShaderType() const override;
141 
142  // Documentation inherited.
143  public: virtual void SetShaderType(enum ShaderType _type) override;
144 
145  public: virtual Ogre::MaterialPtr Material() const;
146 
147  // Documentation inherited.
148  // \sa Material::Set3DMaterial()
149  public: virtual void SetDepthMaterial(const double far,
150  const double near) override;
151 
152  // Documentation inherited.
153  // \sa Material::SetVertexShader(const std::string &)
154  public: virtual void SetVertexShader(const std::string &_path) override;
155 
156  // Documentation inherited.
157  // \sa Material::VertexShader() const
158  public: virtual std::string VertexShader() const override;
159 
160  // Documentation inherited.
161  // \sa Material::VertexShaderParams()
162  public: virtual ShaderParamsPtr VertexShaderParams() override;
163 
164  // Documentation inherited.
165  // \sa Material::SetFragmentShader(const std::string &)
166  public: virtual void SetFragmentShader(const std::string &_path)
167  override;
168 
169  // Documentation inherited.
170  // \sa Material::FragmentShader() const
171  public: virtual std::string FragmentShader() const override;
172 
173  // Documentation inherited.
174  // \sa Material::FragmentShaderParams()
175  public: virtual ShaderParamsPtr FragmentShaderParams() override;
176 
177  // Documentation inherited.
178  // \sa BaseMaterial::PreRender()
179  public: virtual void PreRender() override;
180 
181  protected: virtual void LoadOneImage(const std::string &_name,
182  Ogre::Image &_image);
183 
186  protected: virtual void SetTextureImpl(const std::string &_texture);
187 
188  protected: virtual Ogre::TexturePtr Texture(const std::string &_name);
189 
190  protected: virtual Ogre::TexturePtr CreateTexture(
191  const std::string &_name);
192 
193  protected: virtual void UpdateTransparency();
194 
195  protected: virtual void UpdateColorOperation();
196 
198  protected: void UpdateShaderParams();
199 
203  protected: void UpdateShaderParams(ConstShaderParamsPtr _params,
204  Ogre::GpuProgramParametersSharedPtr _ogreParams);
205 
206  protected: virtual void Init() override;
207 
209  protected: Ogre::MaterialPtr ogreMaterial;
210 
211  protected: Ogre::Technique *ogreTechnique = nullptr;
212 
213  protected: Ogre::Pass *ogrePass = nullptr;
214 
215  protected: Ogre::TextureUnitState *ogreTexState = nullptr;
216 
217  protected: Ogre::String ogreGroup;
218 
219 #if OGRE_VERSION_MAJOR == 1 && OGRE_VERSION_MINOR <= 7
220  protected: math::Color emissiveColor;
221 #endif
223 
225 
226  protected: enum ShaderType shaderType = ST_PIXEL;
227 
230 
233 
236 
240 
241  private: friend class OgreScene;
242  };
243  }
244  }
245 }
246 #endif
std::string vertexShaderPath
Path to vertex shader program.
Definition: gz/rendering/ogre/OgreMaterial.hh:229
STL class.
STL class.
#define IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
Definition: gz/rendering/ogre/OgreScene.hh:39
std::string normalMapName
Definition: gz/rendering/ogre/OgreMaterial.hh:224
const std::string depth_fragment_shader_file
Definition: gz/rendering/ogre/OgreMaterial.hh:36
Definition: gz/rendering/ogre/OgreMaterial.hh:39
Definition: gz/rendering/base/BaseMaterial.hh:38
std::string textureName
Definition: gz/rendering/ogre/OgreMaterial.hh:222
ShaderParamsPtr vertexShaderParams
Parameters to be bound to the vertex shader.
Definition: gz/rendering/ogre/OgreMaterial.hh:235
std::string fragmentShaderPath
Path to fragment shader program.
Definition: gz/rendering/ogre/OgreMaterial.hh:232
Ogre::String ogreGroup
Definition: gz/rendering/ogre/OgreMaterial.hh:217
Ogre::MaterialPtr ogreMaterial
Definition: gz/rendering/ogre/OgreMaterial.hh:209
@ ST_PIXEL
Per pixel lighting shader.
Definition: gz/rendering/ShaderType.hh:40
ShaderParamsPtr fragmentShaderParams
Parameters to be bound to the fragment shader.
Definition: gz/rendering/ogre/OgreMaterial.hh:238
ShaderType
Available types of shaders. Note that not all rendering-engines will be able to use each type....
Definition: gz/rendering/ShaderType.hh:34
Represents a surface material of a Geometry.
Definition: gz/rendering/Material.hh:47
const std::string depth_vertex_shader_file
Definition: gz/rendering/ogre/OgreMaterial.hh:34
#define IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING