Ignition Rendering

API Reference

5.1.0
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 IGNITION_RENDERING_OGRE2_OGRE2RENDERTARGET_HH_
18 #define IGNITION_RENDERING_OGRE2_OGRE2RENDERTARGET_HH_
19 
20 #include <memory>
21 #include <string>
22 #include <vector>
23 #include <ignition/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: Ogre::RenderTarget *RenderTargetImpl() const;
122 
125  public: virtual Ogre::RenderTarget *RenderTarget() const = 0;
126 
132  public: bool IsRenderWindow() const;
133 
134  // Documentation inherited
135  public: unsigned int GLIdImpl() const;
136 
138  protected: void DestroyTargetImpl();
139 
141  protected: void BuildTargetImpl();
142 
146  public: virtual uint32_t VisibilityMask() const;
147 
151  public: virtual void SetVisibilityMask(uint32_t _mask);
152 
154  public: static IGN_DEPRECATED(5) void UpdateRenderPassChain(
155  Ogre::CompositorWorkspace *_workspace,
156  const std::string &_workspaceDefName,
157  const std::string &_baseNode, const std::string &_finalNode,
158  const std::vector<RenderPassPtr> &_renderPasses,
159  bool _recreateNodes);
160 
162  public: static void UpdateRenderPassChain(
163  Ogre::CompositorWorkspace *_workspace,
164  const std::string &_workspaceDefName,
165  const std::string &_baseNode, const std::string &_finalNode,
166  const std::vector<RenderPassPtr> &_renderPasses,
167  bool _recreateNodes,
168  Ogre::Texture *(*_ogreTextures)[2],
169  bool _isRenderWindow);
170 
172  protected: virtual void UpdateBackgroundColor();
173 
175  protected: virtual void UpdateBackgroundMaterial();
176 
178  protected: virtual void UpdateRenderPassChain();
179 
181  protected: void IGN_DEPRECATED(5) UpdateShadowNode();
182 
184  protected: virtual void RebuildImpl() override;
185 
187  protected: virtual void RebuildTarget() = 0;
188 
190  protected: virtual void RebuildCompositor();
191 
193  protected: virtual void BuildCompositor();
194 
196  protected: virtual void DestroyCompositor();
197 
202  protected: void RebuildMaterial();
203 
206  protected: void SyncOgreTextureVars();
207 
209  protected: Ogre::Camera *ogreCamera = nullptr;
210 
213  protected: Ogre::CompositorWorkspace *ogreCompositorWorkspace = nullptr;
214 
217 
219  protected: Ogre::ColourValue ogreBackgroundColor;
220 
223 
225  protected: MaterialPtr material;
226 
233 
235  protected: bool colorDirty = true;
236 
239  protected: bool backgroundMaterialDirty = false;
240 
242  protected: unsigned int antiAliasing = 4;
243 
245  protected: uint32_t visibilityMask = IGN_VISIBILITY_ALL;
246 
249  };
250 
252  class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2RenderTexture :
253  public virtual BaseRenderTexture<Ogre2RenderTarget>
254  {
256  protected: Ogre2RenderTexture();
257 
259  public: virtual ~Ogre2RenderTexture();
260 
261  // Documentation inherited.
262  public: virtual void Destroy() override;
263 
264  // Documentation inherited
265  public: virtual void PreRender() override;
266 
267  // Documentation inherited
268  public: virtual void PostRender() override;
269 
270  // Documentation inherited
271  public: virtual unsigned int GLId() const override;
272 
273  // Documentation inherited
274  // TODO(anyone): this function should be removed.
275  // We didn't do it to preserve ABI.
276  public: virtual Ogre::RenderTarget *RenderTarget() const override;
277 
278  // Documentation inherited.
279  protected: virtual void RebuildTarget() override;
280 
282  protected: virtual void DestroyTarget();
283 
285  protected: virtual void BuildTarget();
286 
293  public: void SetOgreTexture(Ogre::Texture *_ogreTexture);
294 
300  protected: IGN_DEPRECATED(5) Ogre::Texture * ogreTexture = nullptr;
301 
303  private: friend class Ogre2Scene;
304  };
305 
307  class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2RenderWindow :
308  public virtual BaseRenderWindow<Ogre2RenderTarget>
309  {
311  protected: Ogre2RenderWindow();
312 
314  public: virtual ~Ogre2RenderWindow();
315 
316  // Documentation inherited.
317  public: virtual void Destroy() override;
318 
319  // TODO(anyone): this function should be virtual.
320  // We didn't do it to preserve ABI.
321  // Looks in commit history for '#Ogre2IsRenderWindowABI' to
322  // see changes made and revert
323  public: bool IsRenderWindow() const;
324 
325  // Documentation inherited.
326  public: virtual Ogre::RenderTarget *RenderTarget() const override;
327 
328  // Documentation inherited.
329  protected: virtual void RebuildTarget() override;
330 
332  protected: virtual void BuildTarget();
333 
335  protected: Ogre::RenderTarget *ogreRenderWindow = nullptr;
336 
338  private: friend class Ogre2Scene;
339  };
340  }
341  }
342 }
343 #endif
#define IGN_VISIBILITY_ALL
Render everything visibility mask.
Definition: RenderTypes.hh:26
Definition: BaseRenderTarget.hh:98
Ogre::ColourValue ogreBackgroundColor
Stores the background color of the render target.
Definition: Ogre2RenderTarget.hh:219
MaterialPtr material
a material used by for the render target
Definition: Ogre2RenderTarget.hh:225
Ogre2.x implementation of the render window class.
Definition: Ogre2RenderTarget.hh:307
Definition: BaseRenderTarget.hh:35
std::string ogreCompositorWorkspaceDefName
Ogre&#39;s compositor workspace definition name.
Definition: Ogre2RenderTarget.hh:216
Ogre2.x implementation of the scene class.
Definition: Ogre2Scene.hh:56
STL class.
Represents a render-target to which cameras can render images.
Definition: RenderTarget.hh:37
Definition: BaseRenderTarget.hh:111
Encapsulates a raw image buffer and relevant properties.
Definition: Image.hh:36
Ogre2RenderTargetMaterialPtr materialApplicator
Unused. Kept for ABI reasons.
Definition: Ogre2RenderTarget.hh:232
MaterialPtr backgroundMaterial
Background material of the render target.
Definition: Ogre2RenderTarget.hh:222
Posable camera used for rendering the scene graph.
Definition: Camera.hh:40
Ogre2.x implementation of the render texture class.
Definition: Ogre2RenderTarget.hh:252
STL class.
Definition: OgreCamera.hh:27
Ogre2.x implementation of the render target class.
Definition: Ogre2RenderTarget.hh:55