Ignition Rendering

API Reference

4.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 
30 
31 namespace Ogre
32 {
33  class Camera;
34  class RenderTarget;
35  class Texture;
36 }
37 
38 namespace ignition
39 {
40  namespace rendering
41  {
42  inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
43  //
44  // forward declaration
45  class Ogre2RenderTargetPrivate;
46 
48  class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2RenderTarget :
49  public virtual BaseRenderTarget<Ogre2Object>
50  {
52  protected: Ogre2RenderTarget();
53 
55  public: virtual ~Ogre2RenderTarget();
56 
58  public: virtual unsigned int AntiAliasing() const;
59 
62  public: virtual void SetAntiAliasing(unsigned int _aa);
63 
66  public: virtual void Copy(Image &_image) const override;
67 
70  public: virtual Ogre::Camera *Camera() const;
71 
74  public: virtual void SetCamera(Ogre::Camera *_camera);
75 
76  // Documentation inherited
77  public: virtual math::Color BackgroundColor() const override;
78 
81  public: virtual void SetBackgroundColor(math::Color _color);
82 
83  // Documentation inherited
84  public: virtual void PreRender() override;
85 
86  // Documentation inherited
87  public: virtual void PostRender() override;
88 
90  public: virtual void Render();
91 
93  public: virtual void Destroy() override = 0;
94 
98  public: void SetMaterial(MaterialPtr _material);
99 
101  public: virtual Ogre::RenderTarget *RenderTarget() const = 0;
102 
106  public: virtual uint32_t VisibilityMask() const;
107 
111  public: virtual void SetVisibilityMask(uint32_t _mask);
112 
114  public: static void UpdateRenderPassChain(
115  Ogre::CompositorWorkspace *_workspace,
116  const std::string &_workspaceDefName,
117  const std::string &_baseNode, const std::string &_finalNode,
118  const std::vector<RenderPassPtr> &_renderPasses, bool _recreateNodes);
119 
121  protected: virtual void UpdateBackgroundColor();
122 
124  protected: virtual void UpdateRenderPassChain();
125 
128  protected: void UpdateShadowNode();
129 
131  protected: virtual void RebuildImpl() override;
132 
134  protected: virtual void RebuildTarget() = 0;
135 
137  protected: virtual void RebuildCompositor();
138 
140  protected: virtual void BuildCompositor();
141 
143  protected: virtual void DestroyCompositor();
144 
149  protected: void RebuildMaterial();
150 
164  private: void CreateShadowNodeWithSettings(
165  Ogre::CompositorManager2 *_compositorManager,
166  const std::string &_shadowNodeName,
167  const Ogre::ShadowNodeHelper::ShadowParamVec &_shadowParams);
168 
170  protected: Ogre::Camera *ogreCamera = nullptr;
171 
174  protected: Ogre::CompositorWorkspace *ogreCompositorWorkspace = nullptr;
175 
178 
180  protected: Ogre::ColourValue ogreBackgroundColor;
181 
183  protected: MaterialPtr material;
184 
187 
189  protected: bool colorDirty = true;
190 
192  protected: unsigned int antiAliasing = 4;
193 
195  protected: uint32_t visibilityMask = IGN_VISIBILITY_ALL;
196 
199  };
200 
202  class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2RenderTexture :
203  public virtual BaseRenderTexture<Ogre2RenderTarget>
204  {
206  protected: Ogre2RenderTexture();
207 
209  public: virtual ~Ogre2RenderTexture();
210 
211  // Documentation inherited.
212  public: virtual void Destroy() override;
213 
214  // Documentation inherited
215  public: virtual void PreRender() override;
216 
217  // Documentation inherited
218  public: virtual void PostRender() override;
219 
220  // Documentation inherited
221  public: virtual unsigned int GLId() const override;
222 
223  // Documentation inherited.
224  public: virtual Ogre::RenderTarget *RenderTarget() const override;
225 
226  // Documentation inherited.
227  protected: virtual void RebuildTarget() override;
228 
230  protected: virtual void DestroyTarget();
231 
233  protected: virtual void BuildTarget();
234 
236  protected: Ogre::Texture *ogreTexture = nullptr;
237 
239  private: friend class Ogre2Scene;
240  };
241 
243  class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2RenderWindow :
244  public virtual BaseRenderWindow<Ogre2RenderTarget>
245  {
247  protected: Ogre2RenderWindow();
248 
250  public: virtual ~Ogre2RenderWindow();
251 
252  // Documentation inherited.
253  public: virtual void Destroy() override;
254 
255  // Documentation inherited.
256  public: virtual Ogre::RenderTarget *RenderTarget() const override;
257 
258  // Documentation inherited.
259  protected: virtual void RebuildTarget() override;
260 
262  protected: virtual void BuildTarget();
263 
265  protected: Ogre::RenderTarget *ogreRenderWindow = nullptr;
266 
268  private: friend class Ogre2Scene;
269  };
270  }
271  }
272 }
273 #endif
Definition: BaseRenderTarget.hh:98
Ogre::ColourValue ogreBackgroundColor
Stores the background color of the render target.
Definition: Ogre2RenderTarget.hh:180
#define IGN_VISIBILITY_ALL
Render everything visibility mask.
Definition: RenderTypes.hh:26
MaterialPtr material
a material used by for the render target
Definition: Ogre2RenderTarget.hh:183
Ogre2.x implementation of the render window class.
Definition: Ogre2RenderTarget.hh:243
Definition: BaseRenderTarget.hh:35
std::string ogreCompositorWorkspaceDefName
Ogre&#39;s compositor workspace definition name.
Definition: Ogre2RenderTarget.hh:177
Ogre2.x implementation of the scene class.
Definition: Ogre2Scene.hh:45
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
Helper class that applies the material to the render target.
Definition: Ogre2RenderTarget.hh:186
Posable camera used for rendering the scene graph.
Definition: Camera.hh:40
Ogre2.x implementation of the render texture class.
Definition: Ogre2RenderTarget.hh:202
STL class.
Definition: OgreCamera.hh:27
Ogre2.x implementation of the render target class.
Definition: Ogre2RenderTarget.hh:48