Gazebo Rendering

API Reference

6.6.4
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 ignition
46 {
47  namespace rendering
48  {
49  inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
50  //
51  // forward declaration
52  class Ogre2RenderTargetPrivate;
53 
55  class IGNITION_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 
140  protected: void DestroyTargetImpl();
141 
143  protected: void BuildTargetImpl();
144 
148  public: virtual uint32_t VisibilityMask() const;
149 
153  public: virtual void SetVisibilityMask(uint32_t _mask);
154 
156  public: static void UpdateRenderPassChain(
157  Ogre::CompositorWorkspace *_workspace,
158  const std::string &_workspaceDefName,
159  const std::string &_baseNode, const std::string &_finalNode,
160  const std::vector<RenderPassPtr> &_renderPasses,
161  bool _recreateNodes,
162  Ogre::TextureGpu *(*_ogreTextures)[2],
163  bool _isRenderWindow);
164 
166  protected: virtual void UpdateBackgroundColor();
167 
169  protected: virtual void UpdateBackgroundMaterial();
170 
172  protected: virtual void UpdateRenderPassChain();
173 
175  protected: virtual void RebuildImpl() override;
176 
178  protected: virtual void RebuildTarget() = 0;
179 
181  protected: virtual void RebuildCompositor();
182 
184  protected: virtual void BuildCompositor();
185 
187  protected: virtual void DestroyCompositor();
188 
193  protected: void RebuildMaterial();
194 
196  protected: Ogre::Camera *ogreCamera = nullptr;
197 
200  protected: Ogre::CompositorWorkspace *ogreCompositorWorkspace = nullptr;
201 
204 
206  protected: Ogre::ColourValue ogreBackgroundColor;
207 
210 
212  protected: MaterialPtr material;
213 
216 
218  protected: bool colorDirty = true;
219 
222  protected: bool backgroundMaterialDirty = false;
223 
225  protected: unsigned int antiAliasing = 4;
226 
228  protected: uint32_t visibilityMask = IGN_VISIBILITY_ALL;
229 
232  };
233 
235  class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2RenderTexture :
236  public virtual BaseRenderTexture<Ogre2RenderTarget>
237  {
239  protected: Ogre2RenderTexture();
240 
242  public: virtual ~Ogre2RenderTexture();
243 
244  // Documentation inherited.
245  public: virtual void Destroy() override;
246 
247  // Documentation inherited
248  public: virtual void PreRender() override;
249 
250  // Documentation inherited
251  public: virtual void PostRender() override;
252 
253  // Documentation inherited
254  public: virtual unsigned int GLId() const override;
255 
256  // Documentation inherited
257  // TODO(anyone): this function should be removed.
258  // We didn't do it to preserve ABI.
259  public: virtual Ogre::TextureGpu *RenderTarget() const override;
260 
261  // Documentation inherited.
262  protected: virtual void RebuildTarget() override;
263 
265  protected: virtual void DestroyTarget();
266 
268  protected: virtual void BuildTarget();
269 
271  private: friend class Ogre2Scene;
272  };
273 
275  class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2RenderWindow :
276  public virtual BaseRenderWindow<Ogre2RenderTarget>
277  {
279  protected: Ogre2RenderWindow();
280 
282  public: virtual ~Ogre2RenderWindow();
283 
284  // Documentation inherited.
285  public: virtual void Destroy() override;
286 
287  // Documentation inherited.
288  public: virtual bool IsRenderWindow() const override;
289 
290  // Documentation inherited.
291  public: virtual Ogre::TextureGpu *RenderTarget() const override;
292 
293  // Documentation inherited.
294  protected: virtual void RebuildTarget() override;
295 
297  protected: virtual void BuildTarget();
298 
300  protected: Ogre::TextureGpu *ogreRenderWindow = nullptr;
301 
303  private: friend class Ogre2Scene;
304  };
305  }
306  }
307 }
308 #endif
Definition: gz/rendering/base/BaseRenderTarget.hh:38
Definition: gz/rendering/base/BaseRenderTarget.hh:101
Definition: gz/rendering/base/BaseRenderTarget.hh:114
Encapsulates a raw image buffer and relevant properties.
Definition: gz/rendering/Image.hh:37
Ogre2.x implementation of the render target class.
Definition: gz/rendering/ogre2/Ogre2RenderTarget.hh:57
virtual void SetVisibilityMask(uint32_t _mask)
Set visibility mask for the viewport associated with this render target.
virtual void Render()
Main render call.
virtual unsigned int AntiAliasing() const
Get the anti-aliasing level.
virtual void Copy(Image &_image) const override
Copy the render target buffer data to an image.
virtual void SetCamera(Ogre::Camera *_camera)
Set the ogre camera to use for this render target.
MaterialPtr backgroundMaterial
Background material of the render target.
Definition: gz/rendering/ogre2/Ogre2RenderTarget.hh:209
void RebuildMaterial()
Re-initializes render target material to apply a material to everything in the scene....
virtual void UpdateRenderPassChain()
Update the render pass chain.
virtual void SetBackgroundColor(math::Color _color)
Set the background color of the render target.
uint8_t TargetFSAA() const
Returns the FSAA to use based on supported specs by HW and value specified in Ogre2RenderTarget::Anti...
Ogre::ColourValue ogreBackgroundColor
Stores the background color of the render target.
Definition: gz/rendering/ogre2/Ogre2RenderTarget.hh:206
virtual Ogre::TextureGpu * RenderTarget() const =0
Get a pointer to the ogre render target containing the results of the render.
virtual void PreRender() override
Prepare this object and any of its children for rendering. This should be called for each object in a...
virtual void PostRender() override
Post process this object and any of its children after rendering.
virtual void SetBackgroundMaterial(MaterialPtr _material)
Set the background material of this camera.
virtual void RebuildCompositor()
Rebuild the compositor.
virtual bool IsRenderWindow() const
Returns true if this is a render window.
virtual ~Ogre2RenderTarget()
Destructor.
static void UpdateRenderPassChain(Ogre::CompositorWorkspace *_workspace, const std::string &_workspaceDefName, const std::string &_baseNode, const std::string &_finalNode, const std::vector< RenderPassPtr > &_renderPasses, bool _recreateNodes, Ogre::TextureGpu *(*_ogreTextures)[2], bool _isRenderWindow)
Update the render pass chain.
virtual void DestroyCompositor()
Destroy the compositor.
void BuildTargetImpl()
Build the render texture.
void SetMaterial(MaterialPtr _material)
Set a material to render on every object. This method is used for special cases like the render targe...
virtual void RebuildTarget()=0
Rebuild the render target.
Ogre::TextureGpu * RenderTargetImpl() const
Get a pointer to the ogre render target containing the results of the render (implemented separately ...
virtual void BuildCompositor()
Build the compositor.
virtual MaterialPtr BackgroundMaterial() const
Get the background material of this camera.
virtual uint32_t VisibilityMask() const
Get visibility mask for the viewport associated with this render target.
virtual void SetAntiAliasing(unsigned int _aa)
set the anti-aliasing level
void DestroyTargetImpl()
Destroy the render texture.
virtual void Destroy() override=0
Destroy the render target.
std::string ogreCompositorWorkspaceDefName
Ogre's compositor workspace definition name.
Definition: gz/rendering/ogre2/Ogre2RenderTarget.hh:203
virtual void UpdateBackgroundColor()
Update the background color.
Ogre2RenderTargetMaterialPtr materialApplicator
Helper class that applies the material to the render target.
Definition: gz/rendering/ogre2/Ogre2RenderTarget.hh:215
virtual void UpdateBackgroundMaterial()
Update the background material.
virtual math::Color BackgroundColor() const override
Get the background color of the render target. This should be the same as the scene background color.
virtual void RebuildImpl() override
Implementation of the Rebuild function.
virtual Ogre::Camera * Camera() const
Get a pointer to the internal ogre camera.
MaterialPtr material
a material used by for the render target
Definition: gz/rendering/ogre2/Ogre2RenderTarget.hh:212
Ogre2.x implementation of the render texture class.
Definition: gz/rendering/ogre2/Ogre2RenderTarget.hh:237
virtual void BuildTarget()
Build the render texture.
virtual void RebuildTarget() override
Rebuild the render target.
virtual void DestroyTarget()
Destroy the render texture.
virtual void PreRender() override
Prepare this object and any of its children for rendering. This should be called for each object in a...
virtual void PostRender() override
Post process this object and any of its children after rendering.
virtual ~Ogre2RenderTexture()
Destructor.
virtual void Destroy() override
Destroy the render target.
virtual unsigned int GLId() const override
Returns the OpenGL texture Id. A valid Id is returned only.
virtual Ogre::TextureGpu * RenderTarget() const override
Get a pointer to the ogre render target containing the results of the render.
Ogre2.x implementation of the render window class.
Definition: gz/rendering/ogre2/Ogre2RenderTarget.hh:277
virtual void BuildTarget()
Build the render window.
virtual void RebuildTarget() override
Rebuild the render target.
virtual bool IsRenderWindow() const override
Returns true if this is a render window.
virtual ~Ogre2RenderWindow()
Destructor.
virtual void Destroy() override
Destroy the render target.
virtual Ogre::TextureGpu * RenderTarget() const override
Get a pointer to the ogre render target containing the results of the render.
Ogre2.x implementation of the scene class.
Definition: gz/rendering/ogre2/Ogre2Scene.hh:59
#define IGN_VISIBILITY_ALL
Render everything visibility mask.
Definition: gz/rendering/RenderTypes.hh:26
Definition: gz/rendering/ogre/OgreCamera.hh:28