Gazebo Rendering

API Reference

9.5.0
Ogre2GpuRays.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_OGRE2_OGRE2GPURAYS_HH_
19#define GZ_RENDERING_OGRE2_OGRE2GPURAYS_HH_
20
21#include <functional>
22#include <string>
23#include <memory>
24
27#include "gz/rendering/ogre2/Export.hh"
32
33#include "gz/common/Event.hh"
34#include "gz/common/Console.hh"
35
36namespace Ogre
37{
38 class Material;
39 class RenderTarget;
40 class Texture;
41 class Viewport;
42}
43
44namespace gz
45{
46 namespace rendering
47 {
48 inline namespace GZ_RENDERING_VERSION_NAMESPACE {
49 //
50 // Forward declaration
51 class Ogre2GpuRaysPrivate;
52
66 class GZ_RENDERING_OGRE2_VISIBLE Ogre2GpuRays :
67 public BaseGpuRays<Ogre2Sensor>
68 {
70 protected: Ogre2GpuRays();
71
73 public: virtual ~Ogre2GpuRays();
74
75 // Documentation inherited
76 public: virtual void Init() override;
77
78 // Documentation inherited
79 public: virtual void Destroy() override;
80
82 public: virtual void CreateRenderTexture();
83
84 // Documentation inherited
85 public: virtual void PreRender() override;
86
87 // Documentation inherited
88 public: virtual void PostRender() override;
89
90 // Documentation inherited
91 public: virtual const float *Data() const override;
92
93 // Documentation inherited.
94 public: virtual void Copy(float *_data) override;
95
96 // Documentation inherited.
98 std::function<void(const float *_frame, unsigned int _width,
99 unsigned int _height, unsigned int _channels,
100 const std::string &_format)> _subscriber) override;
101
102 // Documentation inherited.
103 public: virtual RenderTargetPtr RenderTarget() const override;
104
109 private: virtual void Set1stTextureSize(const unsigned int _w,
110 const unsigned int _h = 1);
111
116 private: virtual void SetRangeCount(const unsigned int _w,
117 const unsigned int _h = 1);
118
119 // Documentation inherited.
120 private: virtual void Render() override;
121
123 private: void ConfigureCamera();
124
126 private: void CreateCamera();
127
129 private: virtual void CreateGpuRaysTextures();
130
132 private: void UpdateRenderTarget1stPass();
133
135 private: void UpdateRenderTarget2ndPass();
136
139 private: void CreateSampleTexture();
140
142 private: void Setup1stPass();
143
145 private: void Setup2ndPass();
146
152 private: math::Vector2d SampleCubemap(const math::Vector3d &_v,
153 unsigned int &_faceIndex);
154
158
160 private: friend class Ogre2Scene;
161 };
162 }
163 }
164}
165#endif