Gazebo Rendering

API Reference

8.3.0
Camera.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 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 #ifndef GZ_RENDERING_CAMERA_HH_
18 #define GZ_RENDERING_CAMERA_HH_
19 
20 #include <string>
21 
22 #include <gz/common/Event.hh>
23 #include <gz/math/Matrix4.hh>
24 
25 #include "gz/rendering/config.hh"
26 #include "gz/rendering/Image.hh"
29 #include "gz/rendering/Sensor.hh"
30 #include "gz/rendering/Scene.hh"
31 
32 // overloaded-virtuals warnings appeared on Ubuntu Noble
33 // GCC-13. it is not easy to fix them without breaking ABI
34 // ignore them to preserve current ABI.
35 #if defined(__GNUC__) || defined(__clang__)
36 # pragma GCC diagnostic push
37 # pragma GCC diagnostic ignored "-Woverloaded-virtual"
38 #endif
39 
40 namespace gz
41 {
42  namespace rendering
43  {
44  inline namespace GZ_RENDERING_VERSION_NAMESPACE {
45  //
47  enum GZ_RENDERING_VISIBLE CameraProjectionType
48  {
53  };
54 
57  class GZ_RENDERING_VISIBLE Camera :
58  public virtual Sensor
59  {
61  public: typedef std::function<void(const void*, unsigned int,
62  unsigned int, unsigned int, const std::string&)> NewFrameListener;
63 
65  public: virtual ~Camera();
66 
69  public: virtual unsigned int ImageWidth() const = 0;
70 
73  public: virtual void SetImageWidth(unsigned int _width) = 0;
74 
77  public: virtual unsigned int ImageHeight() const = 0;
78 
81  public: virtual void SetImageHeight(unsigned int _height) = 0;
82 
86  public: virtual PixelFormat ImageFormat() const = 0;
87 
91  public: virtual void SetImageFormat(PixelFormat _format,
92  bool _reinterpretable = false) = 0;
93 
96  public: virtual unsigned int ImageMemorySize() const = 0;
97 
100  public: virtual math::Angle HFOV() const = 0;
101 
104  public: virtual void SetHFOV(const math::Angle &_hfov) = 0;
105 
113  public: virtual double AspectRatio() const = 0;
114 
123  public: virtual void SetAspectRatio(const double _ratio) = 0;
124 
125  // TODO(anyone): add auto-aspect ratio
126 
129  public: virtual unsigned int AntiAliasing() const = 0;
130 
136  public: virtual void SetAntiAliasing(const unsigned int _aa) = 0;
137 
140  public: virtual double FarClipPlane() const = 0;
141 
144  public: virtual void SetFarClipPlane(const double _far) = 0;
145 
148  public: virtual double NearClipPlane() const = 0;
149 
152  public: virtual void SetNearClipPlane(const double _near) = 0;
153 
157  public: virtual void Render() = 0;
158 
163  public: virtual void PostRender() = 0;
164 
167  // \return visual for that position, null if no visual was found
168  public: virtual VisualPtr VisualAt(const gz::math::Vector2i
169  &_mousePos) = 0;
170 
176  public: virtual void Update() = 0;
177 
183  public: virtual Image CreateImage() const = 0;
184 
191  public: virtual void Capture(Image &_image) = 0;
192 
198  public: virtual void Copy(Image &_image) const = 0;
199 
210  public: bool CopyTo(const PixelBuffer &_buffer) const;
211 
217  public: virtual bool SaveFrame(const std::string &_name) = 0;
218 
222  NewFrameListener _listener) = 0;
223 
226  public: virtual RenderWindowPtr CreateRenderWindow() = 0;
227 
230  public: virtual math::Matrix4d ProjectionMatrix() const = 0;
231 
234  public: virtual math::Matrix4d ViewMatrix() const = 0;
235 
239  public: virtual void SetProjectionMatrix(const math::Matrix4d &_matrix)
240  = 0;
241 
244  public: virtual CameraProjectionType ProjectionType() const = 0;
245 
254  public: virtual void SetProjectionType(CameraProjectionType _type) = 0;
255 
259  public: virtual math::Vector2i Project(const math::Vector3d &_pt) const
260  = 0;
261 
274  public: virtual void SetTrackTarget(const NodePtr &_target,
275  const math::Vector3d &_offset = math::Vector3d::Zero,
276  const bool _worldFrame = false) = 0;
277 
280  public: virtual NodePtr TrackTarget() const = 0;
281 
286  public: virtual void SetTrackOffset(const math::Vector3d &_offset) = 0;
287 
291  public: virtual math::Vector3d TrackOffset() const = 0;
292 
296  public: virtual void SetTrackPGain(const double _pGain) = 0;
297 
300  public: virtual double TrackPGain() const = 0;
301 
313  public: virtual void SetFollowTarget(const NodePtr &_target,
314  const math::Vector3d &_offset = math::Vector3d::Zero,
315  const bool _worldFrame = false) = 0;
316 
319  public: virtual NodePtr FollowTarget() const = 0;
320 
325  public: virtual void SetFollowOffset(const math::Vector3d &_offset) = 0;
326 
330  public: virtual math::Vector3d FollowOffset() const = 0;
331 
335  public: virtual void SetFollowPGain(const double _pGain) = 0;
336 
339  public: virtual double FollowPGain() const = 0;
340 
343  public: virtual void SetMaterial(const MaterialPtr &_material) = 0;
344 
349  public: virtual unsigned int RenderTextureGLId() const = 0;
350 
357  public: virtual void RenderTextureMetalId(void *_textureIdPtr) const = 0;
358 
363  public: virtual void PrepareForExternalSampling() = 0;
364 
367  public: virtual void AddRenderPass(const RenderPassPtr &_pass) = 0;
368 
371  public: virtual void RemoveRenderPass(const RenderPassPtr &_pass) = 0;
372 
374  public: virtual void RemoveAllRenderPasses() = 0;
375 
378  public: virtual unsigned int RenderPassCount() const = 0;
379 
382  public: virtual RenderPassPtr RenderPassByIndex(unsigned int _index)
383  const = 0;
384 
387  public: virtual void SetShadowsDirty() = 0;
388  };
389  }
390  }
391 }
392 
393 #if defined(__GNUC__) || defined(__clang__)
394 # pragma GCC diagnostic pop
395 #endif
396 
397 #endif