Gazebo Rendering

API Reference

9.0.0
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 <memory>
21#include <string>
22
23#include <gz/utils/SuppressWarning.hh>
24
25#include <gz/common/Image.hh>
26
30
31namespace gz
32{
33 namespace rendering
34 {
35 inline namespace GZ_RENDERING_VERSION_NAMESPACE {
36 // TODO(anyone): use a better way to find shader configurations
38 "depth_vertex_shader.glsl";
40 "depth_fragment_shader.glsl";
41
42 class GZ_RENDERING_OGRE_VISIBLE OgreMaterial :
43 public BaseMaterial<OgreObject>
44 {
45 protected: OgreMaterial();
46
47 public: virtual ~OgreMaterial();
48
49 // Documentation inherited
50 public: virtual void Destroy() override;
51
52 public: virtual bool LightingEnabled() const override;
53
54 public: virtual void SetLightingEnabled(const bool _enabled) override;
55
56 // Documentation inherited
57 public: virtual bool DepthCheckEnabled() const override;
58
59 // Documentation inherited
60 public: virtual void SetDepthCheckEnabled(bool _enabled) override;
61
62 // Documentation inherited
63 public: virtual bool DepthWriteEnabled() const override;
64
65 // Documentation inherited
66 public: virtual void SetDepthWriteEnabled(bool _enabled) override;
67
68 public: virtual math::Color Ambient() const override;
69
70 public: virtual void SetAmbient(const math::Color &_color) override;
71
72 public: virtual math::Color Diffuse() const override;
73
74 public: virtual void SetDiffuse(const math::Color &_color) override;
75
76 public: virtual math::Color Specular() const override;
77
78 public: virtual void SetSpecular(const math::Color &_color) override;
79
80 public: virtual math::Color Emissive() const override;
81
82 public: virtual void SetEmissive(const math::Color &_color) override;
83
84 public: virtual double Shininess() const override;
85
86 public: virtual void SetShininess(const double _shininess) override;
87
88 public: virtual double Transparency() const override;
89
90 public: virtual void SetTransparency(const double _transparency)
91 override;
92
93 // Documentation inherited
94 public: virtual void SetAlphaFromTexture(bool _enabled,
95 double _alpha = 0.5, bool _twoSided = true) override;
96
97 public: virtual double Reflectivity() const override;
98
99 public: virtual void SetReflectivity(const double _reflectivity)
100 override;
101
102 public: virtual bool CastShadows() const override;
103
104 // Documentation inherited.
105 public: virtual void SetCastShadows(const bool _castShadows) override;
106
107 public: virtual bool ReceiveShadows() const override;
108
109 public: virtual void SetReceiveShadows(const bool _receiveShadows)
110 override;
111
112 // Documentation inherited
113 public: virtual float RenderOrder() const override;
114
115 // Documentation inherited
116 // Review the official documentation to get more details about this
117 // parameter, in particular Ogre::Pass::setDepthBias()
118 // https://www.ogre3d.org/docs/api/1.8/class_ogre_1_1_pass.html
119 public: virtual void SetRenderOrder(const float _renderOrder) override;
120
121 public: virtual bool ReflectionEnabled() const override;
122
123 public: virtual void SetReflectionEnabled(const bool _enabled) override;
124
125 public: virtual bool HasTexture() const override;
126
127 public: virtual std::string Texture() const override;
128
129 // Documentation inherited.
130 public: virtual void SetTexture(const std::string &_texture,
131 const std::shared_ptr<const common::Image> &_img = nullptr) override;
132
133 public: virtual void ClearTexture() override;
134
136 const override;
137
138 public: virtual bool HasNormalMap() const override;
139
140 public: virtual std::string NormalMap() const override;
141
143 const override;
144
145 // Documentation inherited.
146 public: virtual void SetNormalMap(const std::string &_normalMap,
147 const std::shared_ptr<const common::Image> &_img = nullptr) override;
148
149 public: virtual void ClearNormalMap() override;
150
151 public: virtual enum ShaderType ShaderType() const override;
152
153 // Documentation inherited.
154 public: virtual void SetShaderType(enum ShaderType _type) override;
155
156 public: virtual Ogre::MaterialPtr Material() const;
157
158 // Documentation inherited.
159 // \sa Material::Set3DMaterial()
160 public: virtual void SetDepthMaterial(const double far,
161 const double near) override;
162
163 // Documentation inherited.
164 // \sa Material::SetVertexShader(const std::string &)
165 public: virtual void SetVertexShader(const std::string &_path) override;
166
167 // Documentation inherited.
168 // \sa Material::VertexShader() const
169 public: virtual std::string VertexShader() const override;
170
171 // Documentation inherited.
172 // \sa Material::VertexShaderParams()
173 public: virtual ShaderParamsPtr VertexShaderParams() override;
174
175 // Documentation inherited.
176 // \sa Material::SetFragmentShader(const std::string &)
177 public: virtual void SetFragmentShader(const std::string &_path)
178 override;
179
180 // Documentation inherited.
181 // \sa Material::FragmentShader() const
182 public: virtual std::string FragmentShader() const override;
183
184 // Documentation inherited.
185 // \sa Material::FragmentShaderParams()
186 public: virtual ShaderParamsPtr FragmentShaderParams() override;
187
188 // Documentation inherited.
189 // \sa BaseMaterial::PreRender()
190 public: virtual void PreRender() override;
191
192 protected: virtual void LoadOneImage(const std::string &_name,
193 Ogre::Image &_image);
194
197 protected: virtual void SetTextureImpl(const std::string &_texture);
198
203 protected: void SetTextureDataImpl(const std::string &_texture,
205
206 protected: virtual Ogre::TexturePtr Texture(const std::string &_name);
207
208 protected: virtual Ogre::TexturePtr CreateTexture(
209 const std::string &_name);
210
211 protected: virtual void UpdateTransparency();
212
213 protected: virtual void UpdateColorOperation();
214
216 protected: void UpdateShaderParams();
217
222 Ogre::GpuProgramParametersSharedPtr _ogreParams);
223
224 protected: virtual void Init() override;
225
226 GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING
227 protected: Ogre::MaterialPtr ogreMaterial;
228
229 protected: Ogre::Technique *ogreTechnique = nullptr;
230
231 protected: Ogre::Pass *ogrePass = nullptr;
232
233 protected: Ogre::TextureUnitState *ogreTexState = nullptr;
234
235 protected: Ogre::String ogreGroup;
236
237#if OGRE_VERSION_MAJOR == 1 && OGRE_VERSION_MINOR <= 7
238 protected: math::Color emissiveColor;
239#endif
241
244
246
249
250 protected: enum ShaderType shaderType = ST_PIXEL;
251
254
257
260
263 GZ_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING
264
265 private: friend class OgreScene;
266 };
267 }
268 }
269}
270#endif