Gazebo Rendering

API Reference

8.2.1
Ogre2BoundingBoxCamera.hh
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (C) 2021 Open Source Robotics Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17 */
18 
19 #ifndef GZ_RENDERING_OGRE2_OGRE2BOUNDINGBOXCAMERA_HH_
20 #define GZ_RENDERING_OGRE2_OGRE2BOUNDINGBOXCAMERA_HH_
21 
22 #ifdef _WIN32
23  // Ensure that Winsock2.h is included before Windows.h, which can get
24  // pulled in by anybody (e.g., Boost).
25  #include <Winsock2.h>
26 #endif
27 
28 #include <memory>
29 #include <vector>
30 
34 
35 namespace gz
36 {
37  namespace rendering
38  {
39  inline namespace GZ_RENDERING_VERSION_NAMESPACE {
40  //
41  // Forward declaration
42  class Ogre2BoundingBoxCameraPrivate;
43 
46  class GZ_RENDERING_OGRE2_VISIBLE Ogre2BoundingBoxCamera :
47  public BaseBoundingBoxCamera<Ogre2Sensor>
48  {
50  protected: Ogre2BoundingBoxCamera();
51 
53  public: virtual ~Ogre2BoundingBoxCamera();
54 
56  public: virtual void Init() override;
57 
59  public: virtual void Destroy() override;
60 
61  // Documentation inherited
62  public: virtual void PreRender() override;
63 
64  // Documentation inherited
65  public: virtual void Render() override;
66 
67  // Documentation inherited
68  public: virtual void PostRender() override;
69 
70  // Documentation inherited
71  public: virtual const std::vector<BoundingBox> &BoundingBoxData() const
72  override;
73 
74  // Documentation inherited
75  public: virtual common::ConnectionPtr
77  std::function<void(const std::vector<BoundingBox> &)>) override;
78 
79  // Documentation inherited
80  public: virtual void SetBoundingBoxType(BoundingBoxType _type) override;
81 
82  // Documentation inherited
83  public: virtual BoundingBoxType Type() const override;
84 
87  public: void CreateBoundingBoxTexture();
88 
91  public: void CreateRenderTexture();
92 
96  public: void FullBoundingBoxes();
97 
100  public: void VisibleBoundingBoxes();
101 
103  public: void BoundingBoxes3D();
104 
115  public: void MeshMinimalBox(
116  const Ogre::MeshPtr _mesh,
117  const Ogre::Matrix4 &_viewMatrix,
118  const Ogre::Matrix4 &_projMatrix,
119  Ogre::Vector3 &_minVertex,
120  Ogre::Vector3 &_maxVertex,
121  const Ogre::Vector3 &_position,
122  const Ogre::Quaternion &_orientation,
123  const Ogre::Vector3 &_scale
124  );
125 
126  // Documentation inherited
127  public: virtual void DrawBoundingBox(unsigned char *_data,
128  const math::Color &_color, const BoundingBox &_box) const override;
129 
136  public: void DrawLine(unsigned char *_data,
137  const math::Vector2i &_point1, const math::Vector2i &_point2,
138  const math::Color &_color) const;
139 
143  public: void ConvertToScreenCoord(Ogre::Vector3 &_minVertex,
144  Ogre::Vector3 &_maxVertex) const;
145 
148  public: void MarkVisibleBoxes();
149 
152  protected: virtual RenderTargetPtr RenderTarget() const override;
153 
155  private: void CreateCamera();
156 
158  private: void MergeMultiLinksModels2D();
159 
161  private: void MergeMultiLinksModels3D();
162 
166 
167  private: friend class Ogre2Scene;
168  };
169  }
170  }
171 }
172 #endif