Ignition Rendering

API Reference

5.1.0
Ogre2DepthCamera.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 
18 #ifndef IGNITION_RENDERING_OGRE2_OGRE2DEPTHCAMERA_HH_
19 #define IGNITION_RENDERING_OGRE2_OGRE2DEPTHCAMERA_HH_
20 
21 #ifdef _WIN32
22  // Ensure that Winsock2.h is included before Windows.h, which can get
23  // pulled in by anybody (e.g., Boost).
24  #include <Winsock2.h>
25 #endif
26 
27 #include <memory>
28 #include <string>
29 
32 
33 #include "ignition/common/Event.hh"
35 
36 namespace Ogre
37 {
38  class Material;
39  class RenderTarget;
40  class Texture;
41  class Viewport;
42 }
43 
44 namespace ignition
45 {
46  namespace rendering
47  {
48  inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
49  //
50  // Forward declaration
51  class Ogre2DepthCameraPrivate;
52 
54  class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2DepthCamera :
55  public BaseDepthCamera<Ogre2Sensor>
56  {
58  protected: Ogre2DepthCamera();
59 
61  public: virtual ~Ogre2DepthCamera();
62 
64  public: virtual void Init() override;
65 
66  // Documentation inherited
67  public: virtual void Destroy() override;
68 
70  public: virtual void CreateRenderTexture();
71 
74  public: virtual void CreateDepthTexture() override;
75 
78  private: void CreateWorkspaceInstance();
79 
80  // Documentation inherited
81  public: virtual void PreRender() override;
82 
84  public: virtual void PostRender() override;
85 
88  public: virtual const float *DepthData() const override;
89 
93  public: virtual ignition::common::ConnectionPtr ConnectNewDepthFrame(
94  std::function<void(const float *, unsigned int, unsigned int,
95  unsigned int, const std::string &)> _subscriber) override;
96 
100  public: virtual ignition::common::ConnectionPtr ConnectNewRgbPointCloud(
101  std::function<void(const float *, unsigned int, unsigned int,
102  unsigned int, const std::string &)> _subscriber) override;
103 
105  public: virtual void Render() override;
106 
109  public: virtual void SetFarClipPlane(const double _far) override;
110 
113  public: virtual void SetNearClipPlane(const double _near) override;
114 
118  public: double NearClipPlane() const override;
119 
123  public: double FarClipPlane() const override;
124 
125  // Documentation inherited.
126  // TODO(anyone): this function should be virtual, declared in 'Camera'
127  // and 'BaseCamera'. We didn't do it to preserve ABI.
128  // Looks in commit history for '#SetShadowsNodeDefDirtyABI' to
129  // see changes made and revert
130  public: void SetShadowsNodeDefDirty();
131 
132  // TODO(anyone): This fixes the pass quad material leaving dangling
133  // pointers when we remove the workspace, so we have to cleanup the
134  // material first.
135  // This bug was fixed in Ogre 2.2 thus the workaround should not be
136  // necessary there
137  //
138  // See https://github.com/ignitionrobotics/ign-rendering/
139  // pull/303#pullrequestreview-635228897
140  // Repro:
141  // 1.run the sensors_demo.sdf world: ign gazebo -v 4 -r sensors_demo.sdf
142  // 2.open Lights plugin, top right menu (3 dots) and select Lights
143  // 3.insert a spot light into the scene (needs to be spot light)
144  // 4.ign gazebo crashes
145  private: void RemoveWorkspaceCrashWorkaround();
146 
147  // Documentation inherited.
148  public: void AddRenderPass(const RenderPassPtr &_pass) override;
149 
152  protected: virtual RenderTargetPtr RenderTarget() const override;
153 
158  protected: static double LimitFOV(const double _fov);
159 
161  protected: void CreateCamera();
162 
164  protected: Ogre::Camera *ogreCamera;
165 
169 
170  private: friend class Ogre2Scene;
171  };
172  }
173  }
174 }
175 #endif
Depth camera used to render depth data into an image buffer.
Definition: Ogre2DepthCamera.hh:54
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: BaseCamera.hh:41
Definition: OgreCamera.hh:27
Ogre::Camera * ogreCamera
Pointer to the ogre camera.
Definition: Ogre2DepthCamera.hh:164