Gazebo Rendering

API Reference

7.4.2
gz/rendering/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"
28 #include "gz/rendering/Sensor.hh"
29 #include "gz/rendering/Scene.hh"
30 
31 
32 namespace gz
33 {
34  namespace rendering
35  {
36  inline namespace GZ_RENDERING_VERSION_NAMESPACE {
37  //
39  enum GZ_RENDERING_VISIBLE CameraProjectionType
40  {
45  };
46 
49  class GZ_RENDERING_VISIBLE Camera :
50  public virtual Sensor
51  {
53  public: typedef std::function<void(const void*, unsigned int,
54  unsigned int, unsigned int, const std::string&)> NewFrameListener;
55 
57  public: virtual ~Camera();
58 
61  public: virtual unsigned int ImageWidth() const = 0;
62 
65  public: virtual void SetImageWidth(unsigned int _width) = 0;
66 
69  public: virtual unsigned int ImageHeight() const = 0;
70 
73  public: virtual void SetImageHeight(unsigned int _height) = 0;
74 
78  public: virtual PixelFormat ImageFormat() const = 0;
79 
82  public: virtual void SetImageFormat(PixelFormat _format) = 0;
83 
86  public: virtual unsigned int ImageMemorySize() const = 0;
87 
90  public: virtual math::Angle HFOV() const = 0;
91 
94  public: virtual void SetHFOV(const math::Angle &_hfov) = 0;
95 
103  public: virtual double AspectRatio() const = 0;
104 
113  public: virtual void SetAspectRatio(const double _ratio) = 0;
114 
115  // TODO(anyone): add auto-aspect ratio
116 
119  public: virtual unsigned int AntiAliasing() const = 0;
120 
126  public: virtual void SetAntiAliasing(const unsigned int _aa) = 0;
127 
130  public: virtual double FarClipPlane() const = 0;
131 
134  public: virtual void SetFarClipPlane(const double _far) = 0;
135 
138  public: virtual double NearClipPlane() const = 0;
139 
142  public: virtual void SetNearClipPlane(const double _near) = 0;
143 
147  public: virtual void Render() = 0;
148 
153  public: virtual void PostRender() = 0;
154 
157  // \return visual for that position, null if no visual was found
158  public: virtual VisualPtr VisualAt(const gz::math::Vector2i
159  &_mousePos) = 0;
160 
166  public: virtual void Update() = 0;
167 
173  public: virtual Image CreateImage() const = 0;
174 
181  public: virtual void Capture(Image &_image) = 0;
182 
188  public: virtual void Copy(Image &_image) const = 0;
189 
195  public: virtual bool SaveFrame(const std::string &_name) = 0;
196 
199  public: virtual common::ConnectionPtr ConnectNewImageFrame(
200  NewFrameListener _listener) = 0;
201 
204  public: virtual RenderWindowPtr CreateRenderWindow() = 0;
205 
208  public: virtual math::Matrix4d ProjectionMatrix() const = 0;
209 
212  public: virtual math::Matrix4d ViewMatrix() const = 0;
213 
217  public: virtual void SetProjectionMatrix(const math::Matrix4d &_matrix)
218  = 0;
219 
222  public: virtual CameraProjectionType ProjectionType() const = 0;
223 
232  public: virtual void SetProjectionType(CameraProjectionType _type) = 0;
233 
237  public: virtual math::Vector2i Project(const math::Vector3d &_pt) const
238  = 0;
239 
252  public: virtual void SetTrackTarget(const NodePtr &_target,
253  const math::Vector3d &_offset = math::Vector3d::Zero,
254  const bool _worldFrame = false) = 0;
255 
258  public: virtual NodePtr TrackTarget() const = 0;
259 
264  public: virtual void SetTrackOffset(const math::Vector3d &_offset) = 0;
265 
269  public: virtual math::Vector3d TrackOffset() const = 0;
270 
274  public: virtual void SetTrackPGain(const double _pGain) = 0;
275 
278  public: virtual double TrackPGain() const = 0;
279 
291  public: virtual void SetFollowTarget(const NodePtr &_target,
292  const math::Vector3d &_offset = math::Vector3d::Zero,
293  const bool _worldFrame = false) = 0;
294 
297  public: virtual NodePtr FollowTarget() const = 0;
298 
303  public: virtual void SetFollowOffset(const math::Vector3d &_offset) = 0;
304 
308  public: virtual math::Vector3d FollowOffset() const = 0;
309 
313  public: virtual void SetFollowPGain(const double _pGain) = 0;
314 
317  public: virtual double FollowPGain() const = 0;
318 
321  public: virtual void SetMaterial(const MaterialPtr &_material) = 0;
322 
327  public: virtual unsigned int RenderTextureGLId() const = 0;
328 
335  public: virtual void RenderTextureMetalId(void *_textureIdPtr) const = 0;
336 
339  public: virtual void AddRenderPass(const RenderPassPtr &_pass) = 0;
340 
343  public: virtual void RemoveRenderPass(const RenderPassPtr &_pass) = 0;
344 
347  public: virtual unsigned int RenderPassCount() const = 0;
348 
351  public: virtual RenderPassPtr RenderPassByIndex(unsigned int _index)
352  const = 0;
353 
356  public: virtual void SetShadowsDirty() = 0;
357  };
358  }
359  }
360 }
361 #endif