Gazebo Rendering

API Reference

9.0.0
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
35namespace 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 {
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 math::Matrix4d ProjectionMatrix() const override;
72
73 // Documentation inherited.
74 public: virtual void SetProjectionMatrix(
75 const math::Matrix4d &_matrix) override;
76
77 // Documentation inherited
78 public: virtual const std::vector<BoundingBox> &BoundingBoxData() const
79 override;
80
81 // Documentation inherited
82 public: virtual common::ConnectionPtr
84 std::function<void(const std::vector<BoundingBox> &)>) override;
85
86 // Documentation inherited
87 public: virtual void SetBoundingBoxType(BoundingBoxType _type) override;
88
89 // Documentation inherited
90 public: virtual BoundingBoxType Type() const override;
91
95
98 public: void CreateRenderTexture();
99
103 public: void FullBoundingBoxes();
104
107 public: void VisibleBoundingBoxes();
108
110 public: void BoundingBoxes3D();
111
122 public: void MeshMinimalBox(
123 const Ogre::MeshPtr _mesh,
124 const Ogre::Matrix4 &_viewMatrix,
125 const Ogre::Matrix4 &_projMatrix,
126 Ogre::Vector3 &_minVertex,
127 Ogre::Vector3 &_maxVertex,
128 const Ogre::Vector3 &_position,
129 const Ogre::Quaternion &_orientation,
130 const Ogre::Vector3 &_scale
131 );
132
133 // Documentation inherited
134 public: virtual void DrawBoundingBox(unsigned char *_data,
135 const math::Color &_color, const BoundingBox &_box) const override;
136
143 public: void DrawLine(unsigned char *_data,
144 const math::Vector2i &_point1, const math::Vector2i &_point2,
145 const math::Color &_color) const;
146
150 public: void ConvertToScreenCoord(Ogre::Vector3 &_minVertex,
151 Ogre::Vector3 &_maxVertex) const;
152
155 public: void MarkVisibleBoxes();
156
159 protected: virtual RenderTargetPtr RenderTarget() const override;
160
162 private: void CreateCamera();
163
165 private: void MergeMultiLinksModels2D();
166
168 private: void MergeMultiLinksModels3D();
169
173
174 private: friend class Ogre2Scene;
175 };
176 }
177 }
178}
179#endif