Gazebo Rendering

API Reference

6.6.4
gz/rendering/ogre/OgreDepthCamera.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 GZ_RENDERING_OGRE_OGREDEPTHCAMERA_HH_
19 #define GZ_RENDERING_OGRE_OGREDEPTHCAMERA_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 
39 
40 #include "gz/common/Event.hh"
41 #include "gz/common/Console.hh"
42 
43 
44 namespace Ogre
45 {
46  class Material;
47  class RenderTarget;
48  class Texture;
49  class Viewport;
50 }
51 
52 namespace ignition
53 {
54  namespace rendering
55  {
56  inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
57  //
58  // forward declaration
59  class OgreDepthCameraPrivate;
60 
65  class IGNITION_RENDERING_OGRE_VISIBLE OgreDepthCamera :
66  public BaseDepthCamera<OgreSensor>
67  {
69  protected: OgreDepthCamera();
70 
72  public: virtual ~OgreDepthCamera();
73 
75  public: virtual void Init() override;
76 
78  public: virtual void CreateDepthTexture() override;
79 
82  protected: void DestroyDepthTexture();
83 
85  public: virtual void PostRender() override;
86 
89  public: virtual const float *DepthData() const override;
90 
94  public: virtual gz::common::ConnectionPtr ConnectNewDepthFrame(
95  std::function<void(const float *, unsigned int, unsigned int,
96  unsigned int, const std::string &)> _subscriber) override;
97 
101  public: virtual gz::common::ConnectionPtr ConnectNewRgbPointCloud(
102  std::function<void(const float *, unsigned int, unsigned int,
103  unsigned int, const std::string &)> _subscriber) override;
104 
105  // Documentation inherited.
106  public: virtual void PreRender() override;
107 
109  public: virtual void Render() override;
110 
113  public: virtual void SetFarClipPlane(const double _far) override;
114 
117  public: virtual void SetNearClipPlane(const double _near) override;
118 
122  public: double NearClipPlane() const override;
123 
127  public: double FarClipPlane() const override;
128 
129  // Documentation inherited
130  public: virtual void Destroy() override;
131 
136  protected: void UpdateRenderTarget(OgreRenderTexturePtr _target,
137  Ogre::Material *_material,
138  const std::string &_matName);
139 
142  protected: virtual RenderTargetPtr RenderTarget() const override;
143 
148  protected: static double LimitFOV(const double _fov);
149 
151  protected: void CreateCamera();
152 
154  private: void CreatePointCloudTexture();
155 
158  protected: void DestroyPointCloudTexture();
159 
161  protected: bool newData = false;
162 
163  protected: bool captureData = false;
164 
167 
169  protected: Ogre::Viewport *depthViewport = nullptr;
170 
172  protected: Ogre::Camera *ogreCamera;
173 
177 
178  private: friend class OgreScene;
179  private: friend class OgreRayQuery;
180  };
181  }
182  }
183 }
184 #endif
Definition: gz/rendering/base/BaseDepthCamera.hh:37
Depth camera used to render depth data into an image buffer.
Definition: gz/rendering/ogre/OgreDepthCamera.hh:67
virtual const float * DepthData() const override
All things needed to get back z buffer for depth data.
void UpdateRenderTarget(OgreRenderTexturePtr _target, Ogre::Material *_material, const std::string &_matName)
Update a render target.
double FarClipPlane() const override
Get the far clip distance.
OgreRenderTexturePtr depthTexture
Pointer to the depth texture.
Definition: gz/rendering/ogre/OgreDepthCamera.hh:166
virtual RenderTargetPtr RenderTarget() const override
Get a pointer to the render target.
virtual void PreRender() override
Prepare this object and any of its children for rendering. This should be called for each object in a...
double NearClipPlane() const override
Get the near clip distance.
virtual void SetFarClipPlane(const double _far) override
Set the far clip distance.
virtual gz::common::ConnectionPtr ConnectNewDepthFrame(std::function< void(const float *, unsigned int, unsigned int, unsigned int, const std::string &)> _subscriber) override
Connect a to the new depth image signal.
virtual void PostRender() override
Render the camera.
Ogre::Camera * ogreCamera
Pointer to the ogre camera.
Definition: gz/rendering/ogre/OgreDepthCamera.hh:172
static double LimitFOV(const double _fov)
Limit field of view taking care of using a valid value for an OGRE camera.
virtual void Destroy() override
Destroy any resources associated with this object. Invoking any other functions after destroying an o...
void DestroyDepthTexture()
Destroy render texture created by CreateDepthTexture() Note: It's not virtual.
virtual gz::common::ConnectionPtr ConnectNewRgbPointCloud(std::function< void(const float *, unsigned int, unsigned int, unsigned int, const std::string &)> _subscriber) override
Connect a to the new rgb point cloud signal.
void CreateCamera()
Create the camera.
void DestroyPointCloudTexture()
Destroy render texture created by CreatePointCloudTexture() Note: It's not virtual.
virtual void CreateDepthTexture() override
Create a texture which will hold the depth data.
virtual void Init() override
Initialize the camera.
virtual void SetNearClipPlane(const double _near) override
Set the near clip distance.
virtual void Render() override
Implementation of the render call.
virtual ~OgreDepthCamera()
Destructor.
A Ray Query class used for computing ray object intersections.
Definition: gz/rendering/ogre/OgreRayQuery.hh:41
Definition: gz/rendering/ogre/OgreScene.hh:41
Definition: gz/rendering/ogre/OgreCamera.hh:28