Gazebo Rendering

API Reference

8.2.1
Ogre2RenderTarget.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 GZ_RENDERING_OGRE2_OGRE2RENDERTARGET_HH_
18 #define GZ_RENDERING_OGRE2_OGRE2RENDERTARGET_HH_
19 
20 #include <memory>
21 #include <string>
22 #include <vector>
23 #include <gz/math/Color.hh>
24 
29 
30 #ifdef _MSC_VER
31  #pragma warning(push, 0)
32 #endif
33 #include <Compositor/OgreCompositorShadowNode.h>
34 #ifdef _MSC_VER
35  #pragma warning(pop)
36 #endif
37 
38 namespace Ogre
39 {
40  class Camera;
41  class RenderTarget;
42  class Texture;
43 }
44 
45 namespace gz
46 {
47  namespace rendering
48  {
49  inline namespace GZ_RENDERING_VERSION_NAMESPACE {
50  //
51  // forward declaration
52  class Ogre2RenderTargetPrivate;
53 
55  class GZ_RENDERING_OGRE2_VISIBLE Ogre2RenderTarget :
56  public virtual BaseRenderTarget<Ogre2Object>
57  {
59  protected: Ogre2RenderTarget();
60 
62  public: virtual ~Ogre2RenderTarget();
63 
65  public: virtual unsigned int AntiAliasing() const;
66 
69  public: virtual void SetAntiAliasing(unsigned int _aa);
70 
73  public: virtual void Copy(Image &_image) const override;
74 
77  public: virtual Ogre::Camera *Camera() const;
78 
81  public: virtual void SetCamera(Ogre::Camera *_camera);
82 
83  // Documentation inherited
84  public: virtual math::Color BackgroundColor() const override;
85 
88  public: virtual void SetBackgroundColor(math::Color _color);
89 
92  public: virtual void SetBackgroundMaterial(MaterialPtr _material);
93 
96  public: virtual MaterialPtr BackgroundMaterial() const;
97 
98  // Documentation inherited
99  public: virtual void PreRender() override;
100 
101  // Documentation inherited
102  public: virtual void PostRender() override;
103 
105  public: virtual void Render();
106 
108  public: virtual void Destroy() override = 0;
109 
113  public: void SetMaterial(MaterialPtr _material);
114 
116  public: void SetShadowsNodeDefDirty();
117 
121  protected: uint8_t TargetFSAA() const;
122 
127  public: static uint8_t TargetFSAA(uint8_t _fsaa);
128 
132  protected: Ogre::TextureGpu *RenderTargetImpl() const;
133 
136  public: virtual Ogre::TextureGpu *RenderTarget() const = 0;
137 
140  public: virtual bool IsRenderWindow() const;
141 
142  // Documentation inherited
143  public: unsigned int GLIdImpl() const;
144 
145  // Documentation inherited
146  public: void MetalIdImpl(void *_textureIdPtr) const;
147 
150 
152  protected: void DestroyTargetImpl();
153 
155  protected: void BuildTargetImpl();
156 
160  public: virtual uint32_t VisibilityMask() const;
161 
165  public: virtual void SetVisibilityMask(uint32_t _mask);
166 
168  public: static void UpdateRenderPassChain(
169  Ogre::CompositorWorkspace *_workspace,
170  const std::string &_workspaceDefName,
171  const std::string &_baseNode, const std::string &_finalNode,
172  const std::vector<RenderPassPtr> &_renderPasses,
173  bool _recreateNodes,
174  Ogre::TextureGpu *(*_ogreTextures)[2],
175  bool _isRenderWindow);
176 
178  protected: virtual void UpdateBackgroundColor();
179 
181  protected: virtual void UpdateBackgroundMaterial();
182 
184  protected: virtual void UpdateRenderPassChain();
185 
187  protected: virtual void RebuildImpl() override;
188 
190  protected: virtual void RebuildTarget() = 0;
191 
193  protected: virtual void RebuildCompositor();
194 
196  protected: virtual void BuildCompositor();
197 
199  protected: virtual void DestroyCompositor();
200 
205  protected: void RebuildMaterial();
206 
208  protected: Ogre::Camera *ogreCamera = nullptr;
209 
212  protected: Ogre::CompositorWorkspace *ogreCompositorWorkspace = nullptr;
213 
216 
218  protected: Ogre::ColourValue ogreBackgroundColor;
219 
222 
224  protected: MaterialPtr material;
225 
228 
230  protected: bool colorDirty = true;
231 
234  protected: bool backgroundMaterialDirty = false;
235 
237  protected: unsigned int antiAliasing = 4;
238 
240  protected: uint32_t visibilityMask = GZ_VISIBILITY_ALL;
241 
244  };
245 
247  class GZ_RENDERING_OGRE2_VISIBLE Ogre2RenderTexture :
248  public virtual BaseRenderTexture<Ogre2RenderTarget>
249  {
251  protected: Ogre2RenderTexture();
252 
254  public: virtual ~Ogre2RenderTexture();
255 
256  // Documentation inherited
257  public: void AddRenderPass(const RenderPassPtr &_pass) override;
258 
259  // Documentation inherited
260  public: void RemoveRenderPass(const RenderPassPtr &_pass) override;
261 
262  // Documentation inherited
263  public: void RemoveAllRenderPasses() override;
264 
265  // Documentation inherited.
266  public: virtual void Destroy() override;
267 
268  // Documentation inherited
269  public: virtual void PreRender() override;
270 
271  // Documentation inherited
272  public: virtual void PostRender() override;
273 
274  // Documentation inherited
275  public: virtual unsigned int GLId() const override;
276 
277  // Documentation inherited
278  public: virtual void MetalId(void *_textureIdPtr) const override;
279 
280  // Documentation inherited
281  // TODO(anyone): this function should be removed.
282  // We didn't do it to preserve ABI.
283  public: virtual Ogre::TextureGpu *RenderTarget() const override;
284 
285  // Documentation inherited.
286  protected: virtual void RebuildTarget() override;
287 
289  protected: virtual void DestroyTarget();
290 
292  protected: virtual void BuildTarget();
293 
295  private: friend class Ogre2Scene;
296  };
297 
299  class GZ_RENDERING_OGRE2_VISIBLE Ogre2RenderWindow :
300  public virtual BaseRenderWindow<Ogre2RenderTarget>
301  {
303  protected: Ogre2RenderWindow();
304 
306  public: virtual ~Ogre2RenderWindow();
307 
308  // Documentation inherited.
309  public: virtual void Destroy() override;
310 
311  // Documentation inherited.
312  public: virtual bool IsRenderWindow() const override;
313 
314  // Documentation inherited.
315  public: virtual Ogre::TextureGpu *RenderTarget() const override;
316 
317  // Documentation inherited.
318  protected: virtual void RebuildTarget() override;
319 
321  protected: virtual void BuildTarget();
322 
324  protected: Ogre::TextureGpu *ogreRenderWindow = nullptr;
325 
327  private: friend class Ogre2Scene;
328  };
329  }
330  }
331 }
332 #endif