Gazebo Rendering

API Reference

7.4.2
gz/rendering/ogre/OgreGpuRays.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_OGREGPURAYS_HH_
19 #define GZ_RENDERING_OGRE_OGREGPURAYS_HH_
20 
21 #include <string>
22 #include <vector>
23 #include <memory>
24 #include <sstream>
25 
26 #include <gz/utils/SuppressWarning.hh>
27 
37 
38 #ifdef _WIN32
39  // Ensure that Winsock2.h is included before Windows.h, which can get
40  // pulled in by anybody (e.g., Boost).
41  #include <Winsock2.h>
42 #endif
43 
44 namespace gz
45 {
46  namespace rendering
47  {
48  inline namespace GZ_RENDERING_VERSION_NAMESPACE {
49  //
50  // Forward declaration
51  class OgreGpuRaysPrivate;
52 
56  class GZ_RENDERING_OGRE_VISIBLE OgreGpuRays :
58  public BaseGpuRays<OgreSensor>, public Ogre::RenderObjectListener
59  {
61  protected: OgreGpuRays();
62 
64  public: virtual ~OgreGpuRays();
65 
66  // Documentation inherited
67  public: virtual void Init() override;
68 
69  // Documentation inherited
70  public: virtual void Destroy() override;
71 
73  public: virtual void CreateRenderTexture();
74 
75  // Documentation inherited
76  public: virtual void PreRender() override;
77 
78  // Documentation inherited
79  public: virtual void PostRender() override;
80 
81  // Documentation inherited
82  public: virtual const float *Data() const override;
83 
84  // Documentation inherited.
85  public: virtual void Copy(float *_data) override;
86 
87  // Documentation inherited.
88  public: virtual common::ConnectionPtr ConnectNewGpuRaysFrame(
89  std::function<void(const float *_frame, unsigned int _width,
90  unsigned int _height, unsigned int _channels,
91  const std::string &_format)> _subscriber) override;
92 
93  // Documentation inherited.
94  public: virtual RenderTargetPtr RenderTarget() const override;
95 
98  public: virtual void notifyRenderSingleObject(Ogre::Renderable *_rend,
99  const Ogre::Pass *_p, const Ogre::AutoParamDataSource *_s,
100  const Ogre::LightList *_ll, bool _supp) override;
101 
106  private: virtual void Set1stTextureSize(const unsigned int _w,
107  const unsigned int _h = 1);
108 
113  private: virtual void SetRangeCount(const unsigned int _w,
114  const unsigned int _h = 1);
115 
116  // Documentation inherited.
117  private: virtual void Render() override;
118 
120  private: void ConfigureCameras();
121 
123  private: void CreateMesh();
124 
126  private: void CreateCanvas();
127 
129  private: void CreateOrthoCam();
130 
132  private: void CreateCamera();
133 
135  private: virtual void CreateGpuRaysTextures();
136 
145  private: Ogre::Matrix4 BuildScaledOrthoMatrix(const float _left,
146  const float _right, const float _bottom, const float _top,
147  const float _near, const float _far);
148 
149  private: void UpdateRenderTarget(Ogre::RenderTarget *_target,
150  Ogre::Material *_material,
151  Ogre::Camera *_cam,
152  const bool _updateTex);
153 
156  private: virtual double CosHorzFOV() const;
157 
160  private: virtual void SetCosHorzFOV(const double _chfov);
161 
164  private: virtual double CosVertFOV() const;
165 
168  private: virtual void SetCosVertFOV(const double _cvfov);
169 
172  private: virtual double HorzHalfAngle() const;
173 
176  private: virtual double VertHalfAngle() const;
177 
180  private: virtual void SetHorzHalfAngle(const double _angle);
181 
184  private: virtual void SetVertHalfAngle(const double _angle);
185 
188  GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING
189  private: std::unique_ptr<OgreGpuRaysPrivate> dataPtr;
190  GZ_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING
191 
192  private: friend class OgreScene;
193  };
194  }
195  }
196 }
197 #endif