Gazebo Rendering

API Reference

7.4.2
gz/rendering/ogre2/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 
126  protected: Ogre::TextureGpu *RenderTargetImpl() const;
127 
130  public: virtual Ogre::TextureGpu *RenderTarget() const = 0;
131 
134  public: virtual bool IsRenderWindow() const;
135 
136  // Documentation inherited
137  public: unsigned int GLIdImpl() const;
138 
139  // Documentation inherited
140  public: void MetalIdImpl(void *_textureIdPtr) const;
141 
143  protected: void DestroyTargetImpl();
144 
146  protected: void BuildTargetImpl();
147 
151  public: virtual uint32_t VisibilityMask() const;
152 
156  public: virtual void SetVisibilityMask(uint32_t _mask);
157 
159  public: static void UpdateRenderPassChain(
160  Ogre::CompositorWorkspace *_workspace,
161  const std::string &_workspaceDefName,
162  const std::string &_baseNode, const std::string &_finalNode,
163  const std::vector<RenderPassPtr> &_renderPasses,
164  bool _recreateNodes,
165  Ogre::TextureGpu *(*_ogreTextures)[2],
166  bool _isRenderWindow);
167 
169  protected: virtual void UpdateBackgroundColor();
170 
172  protected: virtual void UpdateBackgroundMaterial();
173 
175  protected: virtual void UpdateRenderPassChain();
176 
178  protected: virtual void RebuildImpl() override;
179 
181  protected: virtual void RebuildTarget() = 0;
182 
184  protected: virtual void RebuildCompositor();
185 
187  protected: virtual void BuildCompositor();
188 
190  protected: virtual void DestroyCompositor();
191 
196  protected: void RebuildMaterial();
197 
199  protected: Ogre::Camera *ogreCamera = nullptr;
200 
203  protected: Ogre::CompositorWorkspace *ogreCompositorWorkspace = nullptr;
204 
207 
209  protected: Ogre::ColourValue ogreBackgroundColor;
210 
213 
215  protected: MaterialPtr material;
216 
219 
221  protected: bool colorDirty = true;
222 
225  protected: bool backgroundMaterialDirty = false;
226 
228  protected: unsigned int antiAliasing = 4;
229 
231  protected: uint32_t visibilityMask = GZ_VISIBILITY_ALL;
232 
235  };
236 
238  class GZ_RENDERING_OGRE2_VISIBLE Ogre2RenderTexture :
239  public virtual BaseRenderTexture<Ogre2RenderTarget>
240  {
242  protected: Ogre2RenderTexture();
243 
245  public: virtual ~Ogre2RenderTexture();
246 
247  // Documentation inherited.
248  public: virtual void Destroy() override;
249 
250  // Documentation inherited
251  public: virtual void PreRender() override;
252 
253  // Documentation inherited
254  public: virtual void PostRender() override;
255 
256  // Documentation inherited
257  public: virtual unsigned int GLId() const override;
258 
259  // Documentation inherited
260  public: virtual void MetalId(void *_textureIdPtr) const override;
261 
262  // Documentation inherited
263  // TODO(anyone): this function should be removed.
264  // We didn't do it to preserve ABI.
265  public: virtual Ogre::TextureGpu *RenderTarget() const override;
266 
267  // Documentation inherited.
268  protected: virtual void RebuildTarget() override;
269 
271  protected: virtual void DestroyTarget();
272 
274  protected: virtual void BuildTarget();
275 
277  private: friend class Ogre2Scene;
278  };
279 
281  class GZ_RENDERING_OGRE2_VISIBLE Ogre2RenderWindow :
282  public virtual BaseRenderWindow<Ogre2RenderTarget>
283  {
285  protected: Ogre2RenderWindow();
286 
288  public: virtual ~Ogre2RenderWindow();
289 
290  // Documentation inherited.
291  public: virtual void Destroy() override;
292 
293  // Documentation inherited.
294  public: virtual bool IsRenderWindow() const override;
295 
296  // Documentation inherited.
297  public: virtual Ogre::TextureGpu *RenderTarget() const override;
298 
299  // Documentation inherited.
300  protected: virtual void RebuildTarget() override;
301 
303  protected: virtual void BuildTarget();
304 
306  protected: Ogre::TextureGpu *ogreRenderWindow = nullptr;
307 
309  private: friend class Ogre2Scene;
310  };
311  }
312  }
313 }
314 #endif