Gazebo Rendering

API Reference

6.6.3
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/ogre/OgreCamera.hh:27
STL class.
STL class.
STL class.
std::string ogreCompositorWorkspaceDefName
Ogre's compositor workspace definition name.
Definition: gz/rendering/ogre2/Ogre2RenderTarget.hh:203
Ogre2.x implementation of the render target class.
Definition: gz/rendering/ogre2/Ogre2RenderTarget.hh:55
Ogre2.x implementation of the render window class.
Definition: gz/rendering/ogre2/Ogre2RenderTarget.hh:275
Encapsulates a raw image buffer and relevant properties.
Definition: gz/rendering/Image.hh:36
Posable camera used for rendering the scene graph.
Definition: gz/rendering/Camera.hh:49
MaterialPtr material
a material used by for the render target
Definition: gz/rendering/ogre2/Ogre2RenderTarget.hh:212
Ogre2.x implementation of the scene class.
Definition: gz/rendering/ogre2/Ogre2Scene.hh:57
Represents a render-target to which cameras can render images.
Definition: gz/rendering/RenderTarget.hh:37
#define IGN_VISIBILITY_ALL
Render everything visibility mask.
Definition: gz/rendering/RenderTypes.hh:26
Definition: gz/rendering/base/BaseRenderTarget.hh:35
MaterialPtr backgroundMaterial
Background material of the render target.
Definition: gz/rendering/ogre2/Ogre2RenderTarget.hh:209
Ogre2.x implementation of the render texture class.
Definition: gz/rendering/ogre2/Ogre2RenderTarget.hh:235
Ogre::ColourValue ogreBackgroundColor
Stores the background color of the render target.
Definition: gz/rendering/ogre2/Ogre2RenderTarget.hh:206
Definition: gz/rendering/base/BaseRenderTarget.hh:111
Definition: gz/rendering/base/BaseRenderTarget.hh:98
Ogre2RenderTargetMaterialPtr materialApplicator
Helper class that applies the material to the render target.
Definition: gz/rendering/ogre2/Ogre2RenderTarget.hh:215