Gazebo Rendering

API Reference

8.3.0
Ogre2WideAngleCamera.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2022 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_WIDEANGLECAMERA_HH_
18 #define GZ_RENDERING_OGRE2_WIDEANGLECAMERA_HH_
19 
20 #include <memory>
21 #include <string>
22 
23 #include <gz/utils/ImplPtr.hh>
24 
26 #include "gz/rendering/ogre2/Export.hh"
29 
30 namespace gz
31 {
32  namespace rendering
33  {
34  inline namespace GZ_RENDERING_VERSION_NAMESPACE {
35  //
37  class GZ_RENDERING_OGRE2_VISIBLE Ogre2WideAngleCamera :
38  public BaseWideAngleCamera<Ogre2Sensor>
39  {
41  protected: Ogre2WideAngleCamera();
42 
44  public: virtual ~Ogre2WideAngleCamera() override;
45 
46  // Documentation inherited
47  public: virtual void Init() override;
48 
50  public: virtual void CreateRenderTexture();
51 
54  protected: void DestroyRenderTexture();
55 
57  public: virtual void PostRender() override;
58 
59  // Documentation inherited
60  public: virtual void Destroy() override;
61 
64  public: void DestroyTextures();
65 
66  // Documentation inherited
67  public: void AddRenderPass(const RenderPassPtr &_pass) override;
68 
69  // Documentation inherited
70  public: void RemoveRenderPass(const RenderPassPtr &_pass) override;
71 
72  // Documentation inherited
73  public: void RemoveAllRenderPasses() override;
74 
77  public: uint32_t EnvTextureSize() const;
78 
81  public: void SetEnvTextureSize(uint32_t _size);
82 
87  public: math::Vector3d Project3d(const math::Vector3d &_pt) const
88  override;
89 
96  public: Ogre::Ray CameraToViewportRay(const math::Vector2d &_screenPos,
97  uint32_t _faceIdx);
98 
99  // Documentation inherited.
100  public: virtual void PreRender() override;
101 
103  public: virtual void Render() override;
104 
105  // Documentation inherited.
106  public: void Copy(Image &_image) const override;
107 
114  private: bool CopyToBuffer(const PixelBuffer &_dst) const;
115 
116  // Documentation inherited
118  std::function<void(const unsigned char *, unsigned int, unsigned int,
119  unsigned int, const std::string &)> _subscriber) override;
120 
123  public: void SetBackgroundMaterial(MaterialPtr _material);
124 
128 
133 
137 
139  protected: void CreateStitchWorkspace();
140 
142  protected: void DestroyStitchWorkspace();
143 
147  protected: bool HasTempStitchTexture() const;
148 
152  protected: bool NeedsTempStitchTexture() const;
153 
158  protected: uint32_t TempStitchTextureChannel() const;
159 
163  protected: std::string WorkspaceDefinitionName(uint32_t _faceIdx) const;
164 
167  protected: void CreateWorkspaceDefinition(bool _withMsaa);
168 
171  protected: void CreateFacesWorkspaces(bool _withMsaa);
172 
174  protected: void DestroyFacesWorkspaces();
175 
178  protected: void UpdateRenderPasses();
179 
181  protected: void CreateWideAngleTexture() override;
182 
184  protected: void CreateCamera();
185 
188  protected: virtual RenderTargetPtr RenderTarget() const override;
189 
194  protected: void SetupMSAA(Ogre::CompositorManager2 *_ogreCompMgr,
195  uint8_t _msaa);
196 
198  private: void UpdateBackgroundMaterial();
199 
206  private: void RetrieveCubePassSceneDefs(
207  Ogre::CompositorManager2 *_ogreCompMgr, bool _withMsaa);
208 
211  private: void PrepareForCubemapFacePass(Ogre::CompositorPass *_pass);
212 
215  private: void PrepareForFinalPass(Ogre::Pass *_pass);
216 
219  GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr)
221 
222  private: friend class Ogre2Scene;
223  private: friend class Ogre2WideAngleCameraWorkspaceListenerPrivate;
224  };
225  }
226  }
227 }
228 #endif