Ignition Rendering

API Reference

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