Ignition Rendering

API Reference

4.1.0
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 IGNITION_RENDERING_OGRE_OGREGPURAYS_HH_
19 #define IGNITION_RENDERING_OGRE_OGREGPURAYS_HH_
20 
21 #include <string>
22 #include <vector>
23 #include <memory>
24 #include <sstream>
25 
35 
36 #ifdef _WIN32
37  // Ensure that Winsock2.h is included before Windows.h, which can get
38  // pulled in by anybody (e.g., Boost).
39  #include <Winsock2.h>
40 #endif
41 
42 namespace ignition
43 {
44  namespace rendering
45  {
46  inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
47  //
48  // Forward declaration
49  class OgreGpuRaysPrivate;
50 
54  class IGNITION_RENDERING_OGRE_VISIBLE OgreGpuRays :
56  public BaseGpuRays<OgreSensor>, public Ogre::RenderObjectListener
57  {
59  protected: OgreGpuRays();
60 
62  public: virtual ~OgreGpuRays();
63 
64  // Documentation inherited
65  public: virtual void Init() override;
66 
67  // Documentation inherited
68  public: virtual void Destroy() override;
69 
71  public: virtual void CreateRenderTexture();
72 
73  // Documentation inherited
74  public: virtual void PreRender() override;
75 
76  // Documentation inherited
77  public: virtual void PostRender() override;
78 
79  // Documentation inherited
80  public: virtual const float *Data() const override;
81 
82  // Documentation inherited.
83  public: virtual void Copy(float *_data) override;
84 
85  // Documentation inherited.
86  public: virtual common::ConnectionPtr ConnectNewGpuRaysFrame(
87  std::function<void(const float *_frame, unsigned int _width,
88  unsigned int _height, unsigned int _channels,
89  const std::string &_format)> _subscriber) override;
90 
91  // Documentation inherited.
92  public: virtual RenderTargetPtr RenderTarget() const override;
93 
96  public: virtual void notifyRenderSingleObject(Ogre::Renderable *_rend,
97  const Ogre::Pass *_p, const Ogre::AutoParamDataSource *_s,
98  const Ogre::LightList *_ll, bool _supp) override;
99 
104  private: virtual void Set1stTextureSize(const unsigned int _w,
105  const unsigned int _h = 1);
106 
111  private: virtual void SetRangeCount(const unsigned int _w,
112  const unsigned int _h = 1);
113 
114  // Documentation inherited.
115  private: virtual void Render() override;
116 
118  private: void ConfigureCameras();
119 
121  private: void CreateMesh();
122 
124  private: void CreateCanvas();
125 
127  private: void CreateOrthoCam();
128 
130  private: void CreateCamera();
131 
133  private: virtual void CreateGpuRaysTextures();
134 
143  private: Ogre::Matrix4 BuildScaledOrthoMatrix(const float _left,
144  const float _right, const float _bottom, const float _top,
145  const float _near, const float _far);
146 
147  private: void UpdateRenderTarget(Ogre::RenderTarget *_target,
148  Ogre::Material *_material,
149  Ogre::Camera *_cam,
150  const bool _updateTex);
151 
154  private: virtual double CosHorzFOV() const;
155 
158  private: virtual void SetCosHorzFOV(const double _chfov);
159 
162  private: virtual double CosVertFOV() const;
163 
166  private: virtual void SetCosVertFOV(const double _cvfov);
167 
170  private: virtual double HorzHalfAngle() const;
171 
174  private: virtual double VertHalfAngle() const;
175 
178  private: virtual void SetHorzHalfAngle(const double _angle);
179 
182  private: virtual void SetVertHalfAngle(const double _angle);
183 
186  private: std::unique_ptr<OgreGpuRaysPrivate> dataPtr;
187 
188  private: friend class OgreScene;
189  };
190  }
191  }
192 }
193 #endif
STL class.
shared_ptr< RenderTarget > RenderTargetPtr
Definition: RenderTypes.hh:194
std::shared_ptr< Connection > ConnectionPtr
Definition: OgreScene.hh:39