Ignition Rendering

API Reference

4.1.0
BaseCamera.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 IGNITION_RENDERING_BASE_BASECAMERA_HH_
18 #define IGNITION_RENDERING_BASE_BASECAMERA_HH_
19 
20 #include <string>
21 
22 #include <ignition/math/Matrix3.hh>
23 #include <ignition/math/Pose3.hh>
24 
25 #include <ignition/common/Event.hh>
27 
33 
34 namespace ignition
35 {
36  namespace rendering
37  {
38  inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
39  template <class T>
41 
42  template <class T>
43  class BaseCamera :
44  public virtual Camera,
45  public virtual T
46  {
47  protected: BaseCamera();
48 
49  public: virtual ~BaseCamera();
50 
51  public: virtual unsigned int ImageWidth() const override;
52 
53  public: virtual void SetImageWidth(const unsigned int _width) override;
54 
55  public: virtual unsigned int ImageHeight() const override;
56 
57  public: virtual void SetImageHeight(const unsigned int _height) override;
58 
59  public: virtual PixelFormat ImageFormat() const override;
60 
61  public: virtual unsigned int ImageMemorySize() const override;
62 
63  public: virtual void SetImageFormat(PixelFormat _format) override;
64 
65  public: virtual math::Angle HFOV() const override;
66 
67  public: virtual void SetHFOV(const math::Angle &_hfov) override;
68 
69  public: virtual double AspectRatio() const override;
70 
71  public: virtual void SetAspectRatio(const double _ratio) override;
72 
73  public: virtual unsigned int AntiAliasing() const override;
74 
75  public: virtual void SetAntiAliasing(const unsigned int _aa) override;
76 
77  public: virtual double FarClipPlane() const override;
78 
79  public: virtual void SetFarClipPlane(const double _far) override;
80 
81  public: virtual double NearClipPlane() const override;
82 
83  public: virtual void SetNearClipPlane(const double _near) override;
84 
85  // Documentation inherited.
86  public: virtual void PreRender() override;
87 
88  // Documentation inherited.
89  public: virtual void PostRender() override;
90 
91  public: virtual void Update() override;
92 
93  public: virtual Image CreateImage() const override;
94 
95  public: virtual void Capture(Image &_image) override;
96 
97  public: virtual void Copy(Image &_image) const override;
98 
99  public: virtual bool SaveFrame(const std::string &_name) override;
100 
101  public: virtual common::ConnectionPtr ConnectNewImageFrame(
102  Camera::NewFrameListener _listener) override;
103 
104  public: virtual RenderWindowPtr CreateRenderWindow() override;
105 
106  // Documentation inherited.
107  public: virtual VisualPtr VisualAt(const ignition::math::Vector2i
108  &_mousePos) override;
109 
110  // Documentation inherited.
111  public: virtual math::Matrix4d ProjectionMatrix() const override;
112 
113  // Documentation inherited.
114  public: virtual math::Matrix4d ViewMatrix() const override;
115 
116  // Documentation inherited.
117  // \sa Camera::SetMaterial(const MaterialPtr &) override;
118  public: virtual void SetMaterial(const MaterialPtr &_material)
119  override;
120 
121  // Documentation inherited.
122  public: virtual void SetTrackTarget(const NodePtr &_target,
123  const math::Vector3d &_offset,
124  const bool _worldFrame) override;
125 
126  // Documentation inherited.
127  public: virtual NodePtr TrackTarget() const override;
128 
129  // Documentation inherited.
130  public: virtual void SetTrackOffset(const math::Vector3d &_offset)
131  override;
132 
133  // Documentation inherited.
134  public: virtual math::Vector3d TrackOffset() const override;
135 
136  // Documentation inherited.
137  public: virtual void SetTrackPGain(const double _pGain) override;
138 
139  // Documentation inherited.
140  public: virtual double TrackPGain() const override;
141 
142  // Documentation inherited.
143  public: virtual void SetFollowTarget(const NodePtr &_target,
144  const math::Vector3d &_Offset, const bool _worldFrame)
145  override;
146 
147  // Documentation inherited.
148  public: virtual NodePtr FollowTarget() const override;
149 
150  // Documentation inherited.
151  public: virtual void SetFollowOffset(const math::Vector3d &_offset)
152  override;
153 
154  // Documentation inherited.
155  public: virtual math::Vector3d FollowOffset() const override;
156 
157  // Documentation inherited.
158  public: virtual void SetFollowPGain(const double _pGain) override;
159 
160  // Documentation inherited.
161  public: virtual double FollowPGain() const override;
162 
163  // Documentation inherited.
164  public: virtual unsigned int RenderTextureGLId() const override;
165 
166  // Documentation inherited.
167  public: virtual void AddRenderPass(const RenderPassPtr &_pass) override;
168 
169  // Documentation inherited.
170  public: virtual void RemoveRenderPass(const RenderPassPtr &_pass)
171  override;
172 
173  // Documentation inherited.
174  public: virtual unsigned int RenderPassCount() const override;
175 
176  // Documentation inherited.
177  public: virtual RenderPassPtr RenderPassByIndex(unsigned int _index)
178  const override;
179 
180  protected: virtual void *CreateImageBuffer() const;
181 
182  protected: virtual void Load() override;
183 
184  protected: virtual void Reset();
185 
186  protected: virtual RenderTargetPtr RenderTarget() const = 0;
187 
188  protected: common::EventT<void(const void *, unsigned int, unsigned int,
189  unsigned int, const std::string &)> newFrameEvent;
190 
191  protected: ImagePtr imageBuffer;
192 
194  protected: double nearClip = 0.01;
195 
197  protected: double farClip = 1000.0;
198 
200  protected: double aspect = 1.3333333;
201 
203  protected: math::Angle hfov;
204 
206  protected: unsigned int antiAliasing = 0u;
207 
209  protected: NodePtr trackNode;
210 
212  protected: bool trackWorldFrame = false;
213 
217 
220  protected: double trackPGain = 1.0;
221 
223  protected: NodePtr followNode;
224 
226  protected: bool followWorldFrame = false;
227 
230  protected: double followPGain = 1.0;
231 
234 
235  friend class BaseDepthCamera<T>;
236  };
237 
239  template <class T>
241  {
242  }
243 
245  template <class T>
247  {
248  }
249 
251  template <class T>
252  unsigned int BaseCamera<T>::ImageWidth() const
253  {
254  return this->RenderTarget()->Width();
255  }
256 
258  template <class T>
259  void BaseCamera<T>::SetImageWidth(const unsigned int _width)
260  {
261  this->RenderTarget()->SetWidth(_width);
262  }
263 
265  template <class T>
266  unsigned int BaseCamera<T>::ImageHeight() const
267  {
268  return this->RenderTarget()->Height();
269  }
270 
272  template <class T>
273  void BaseCamera<T>::SetImageHeight(const unsigned int _height)
274  {
275  this->RenderTarget()->SetHeight(_height);
276  }
277 
279  template <class T>
280  unsigned int BaseCamera<T>::ImageMemorySize() const
281  {
282  PixelFormat format = this->ImageFormat();
283  unsigned int width = this->ImageWidth();
284  unsigned int height = this->ImageHeight();
285  return PixelUtil::MemorySize(format, width, height);
286  }
287 
289  template <class T>
291  {
292  return this->RenderTarget()->Format();
293  }
294 
296  template <class T>
298  {
299  this->RenderTarget()->SetFormat(_format);
300  }
301 
303  template <class T>
305  {
306  T::PreRender();
307 
308  this->RenderTarget()->PreRender();
309 
310  // camera following
311  if (this->followNode)
312  {
313  // tether camera fixed in world frame
314  if (this->followWorldFrame)
315  {
316  math::Vector3d targetCamPos =
317  this->followNode->WorldPosition() + this->followOffset;
318  math::Vector3d pos = this->WorldPosition() +
319  (targetCamPos - this->WorldPosition()) * this->followPGain;
320  this->SetWorldPosition(pos);
321  }
322  // tether camera fixed in target's local frame
323  else
324  {
325  math::Pose3d targetCamPose = math::Pose3d(this->followOffset,
326  this->WorldRotation());
327  targetCamPose += this->followNode->WorldPose();
328 
329  math::Vector3d pos = this->WorldPosition() +
330  (targetCamPose.Pos() - this->WorldPosition()) * this->followPGain;
331  this->SetWorldPosition(pos);
332  }
333  }
334 
335  // camera tracking
336  if (this->trackNode)
337  {
338  math::Vector3d eye = this->WorldPosition();
339  math::Pose3d targetPose = math::Pose3d(this->trackOffset,
341  if (this->trackWorldFrame)
342  {
343  targetPose.Pos() += this->trackNode->WorldPosition();
344  }
345  else
346  {
347  targetPose += this->trackNode->WorldPose();
348  }
349 
350  math::Pose3d p =
351  math::Matrix4d::LookAt(eye, targetPose.Pos()).Pose();
352 
353  math::Quaterniond q = p.Rot();
354  // skip slerp if we don't need it
355  if (!math::equal(this->trackPGain, 1.0))
356  {
358  this->trackPGain, this->WorldRotation(), p.Rot(), true);
359  }
360  this->SetWorldRotation(q);
361  }
362  }
363 
365  template <class T>
367  {
368  this->RenderTarget()->PostRender();
369  }
370 
372  template <class T>
374  {
375  PixelFormat format = this->ImageFormat();
376  unsigned int width = this->ImageWidth();
377  unsigned int height = this->ImageHeight();
378  return Image(width, height, format);
379  }
380 
382  template <class T>
384  {
385  this->Scene()->PreRender();
386  this->Render();
387  this->PostRender();
388  }
389 
391  template <class T>
393  {
394  this->Update();
395  this->Copy(_image);
396  }
397 
399  template <class T>
400  void BaseCamera<T>::Copy(Image &_image) const
401  {
402  this->RenderTarget()->Copy(_image);
403  }
404 
406  template <class T>
407  bool BaseCamera<T>::SaveFrame(const std::string &/*_name*/)
408  {
409  return false;
410  }
411 
413  template <class T>
415  Camera::NewFrameListener _listener)
416  {
417  return newFrameEvent.Connect(_listener);
418  }
419 
421  template <class T>
423  {
424  // TODO(anyone): determine proper type
425  unsigned int size = this->ImageMemorySize();
426  return new unsigned char *[size];
427  }
428 
430  template <class T>
432  {
433  T::Load();
434  }
435 
437  template <class T>
439  {
440  math::Angle fov;
441  fov.Degree(60);
442  this->SetImageWidth(1);
443  this->SetImageHeight(1);
444  this->SetImageFormat(PF_R8G8B8);
445  this->SetAspectRatio(1.33333);
446  this->SetAntiAliasing(0u);
447  this->SetHFOV(fov);
448  this->SetNearClipPlane(0.01);
449  this->SetFarClipPlane(1000);
450  }
451 
453  template <class T>
455  {
456  // Does nothing by default
457  ignerr << "Render window not supported for render engine: " <<
458  this->Scene()->Engine()->Name() << std::endl;
459  return RenderWindowPtr();
460  }
461 
463  template <class T>
465  {
466  // perspective projection
467  double ratio = this->AspectRatio();
468  double fov = this->HFOV().Radian();
469  double vfov = 2.0 * std::atan(std::tan(fov / 2.0) / ratio);
470  double f = 1.0;
471  double _near = this->NearClipPlane();
472  double _far = this->FarClipPlane();
473  double top = _near * std::tan(0.5*vfov) / f;
474  double height = 2 * top;
475  double width = ratio * height;
476  double left = -0.5 * width;
477  double right = left + width;
478  double bottom = top - height;
479 
480  double invw = 1.0 / (right - left);
481  double invh = 1.0 / (top - bottom);
482  double invd = 1.0 / (_far - _near);
483  double x = 2 * _near * invw;
484  double y = 2 * _near * invh;
485  double a = (right + left) * invw;
486  double b = (top + bottom) * invh;
487  double c = -(_far + _near) * invd;
488  double d = -2 * _far * _near * invd;
489  math::Matrix4d result;
490  result(0, 0) = x;
491  result(0, 2) = a;
492  result(1, 1) = y;
493  result(1, 2) = b;
494  result(2, 2) = c;
495  result(2, 3) = d;
496  result(3, 2) = -1;
497 
498  // TODO(anyone): compute projection matrix for orthographic camera
499 
500  return result;
501  }
502 
504  template <class T>
506  {
507  math::Matrix3d r(this->WorldPose().Rot());
508  // transform from y up to z up
509  math::Matrix3d tf(0, 0, -1,
510  -1, 0, 0,
511  0, 1, 0);
512  r = r * tf;
513  r.Transpose();
514  math::Vector3d t = r * this->WorldPose().Pos() * -1;
515  math::Matrix4d result;
516  result = r;
517  result.SetTranslation(t);
518  result(3, 3) = 1.0;
519  return result;
520  }
521 
523  template <class T>
525  {
526  return this->hfov;
527  }
528 
530  template <class T>
532  &/*_mousePos*/)
533  {
534  ignerr << "VisualAt not implemented for the render engine" << std::endl;
535  return VisualPtr();
536  }
537 
539  template <class T>
541  {
542  this->hfov = _hfov;
543  }
544 
546  template <class T>
548  {
549  return this->aspect;
550  }
551 
553  template <class T>
554  void BaseCamera<T>::SetAspectRatio(const double _aspect)
555  {
556  this->aspect = _aspect;
557  }
558 
560  template <class T>
561  unsigned int BaseCamera<T>::AntiAliasing() const
562  {
563  return this->antiAliasing;
564  }
565 
567  template <class T>
568  void BaseCamera<T>::SetAntiAliasing(const unsigned int _aa)
569  {
570  this->antiAliasing = _aa;
571  }
572 
574  template <class T>
576  {
577  return this->farClip;
578  }
579 
581  template <class T>
582  void BaseCamera<T>::SetFarClipPlane(const double _far)
583  {
584  this->farClip = _far;
585  }
586 
588  template <class T>
590  {
591  return this->nearClip;
592  }
593 
595  template <class T>
596  void BaseCamera<T>::SetNearClipPlane(const double _near)
597  {
598  this->nearClip = _near;
599  }
600 
602  template <class T>
604  const math::Vector3d &_offset, const bool _worldFrame)
605  {
606  this->trackNode = _target;
607  this->trackWorldFrame = _worldFrame;
608  this->trackOffset = _offset;
609  }
610 
612  template <class T>
614  {
615  return this->trackNode;
616  }
617 
619  template <class T>
621  {
622  return this->trackOffset;
623  }
624 
626  template <class T>
628  {
629  this->trackOffset = _offset;
630  }
631 
633  template <class T>
634  void BaseCamera<T>::SetTrackPGain(const double _pGain)
635  {
636  this->trackPGain = math::clamp(_pGain, 0.0, 1.0);
637  }
638 
640  template <class T>
642  {
643  return this->trackPGain;
644  }
645 
647  template <class T>
649  const math::Vector3d &_offset, const bool _worldFrame)
650  {
651  this->followNode = _target;
652  this->followWorldFrame = _worldFrame;
653  this->followOffset = _offset;
654  }
655 
657  template <class T>
659  {
660  return this->followNode;
661  }
662 
664  template <class T>
666  {
667  return this->followOffset;
668  }
669 
671  template <class T>
673  {
674  this->followOffset = _offset;
675  }
676 
678  template <class T>
679  void BaseCamera<T>::SetFollowPGain(const double _pGain)
680  {
681  this->followPGain = math::clamp(_pGain, 0.0, 1.0);
682  }
683 
685  template <class T>
687  {
688  return this->followPGain;
689  }
690 
692  template <class T>
693  void BaseCamera<T>::SetMaterial(const MaterialPtr &/*_material*/)
694  {
695  ignerr << "SetMaterial not implemented for current render"
696  << " engine" << std::endl;
697  }
698 
700  template <class T>
701  unsigned int BaseCamera<T>::RenderTextureGLId() const
702  {
703  ignerr << "RenderTextureGLId is not supported by current render"
704  << " engine" << std::endl;
705  return 0u;
706  }
707 
709  template <class T>
711  {
712  this->RenderTarget()->AddRenderPass(_pass);
713  }
714 
716  template <class T>
718  {
719  this->RenderTarget()->RemoveRenderPass(_pass);
720  }
721 
723  template <class T>
724  unsigned int BaseCamera<T>::RenderPassCount() const
725  {
726  return this->RenderTarget()->RenderPassCount();
727  }
728 
730  template <class T>
732  {
733  return this->RenderTarget()->RenderPassByIndex(_index);
734  }
735  }
736  }
737 }
738 #endif
static unsigned int MemorySize(PixelFormat _format, unsigned int _width, unsigned int _height)
Get total memory size in bytes for an image with the given format and dimensions. If an invalid forma...
T atan(T... args)
virtual void * CreateImageBuffer() const
Definition: BaseCamera.hh:422
virtual unsigned int RenderPassCount() const =0
Get the number of render passes applied to the render target.
virtual void SetTrackOffset(const math::Vector3d &_offset) override
Set track offset. Camera will track a point that&#39;s at an offset from the target node. The offset will be in the frame that is specified at the time the track target is set.
Definition: BaseCamera.hh:627
BaseCamera()
Definition: BaseCamera.hh:240
virtual void SetTrackPGain(const double _pGain) override
Set track P Gain. Determines how fast the camera rotates to look at the target node. Valid range: [0-1].
Definition: BaseCamera.hh:634
Definition: BaseCamera.hh:43
virtual common::ConnectionPtr ConnectNewImageFrame(Camera::NewFrameListener _listener) override
Subscribes a new listener to this camera&#39;s new frame event.
Definition: BaseCamera.hh:414
void Degree(double _degree)
virtual double FarClipPlane() const override
Get the camera&#39;s far clipping plane distance.
Definition: BaseCamera.hh:575
virtual unsigned int RenderTextureGLId() const override
Get the OpenGL texture id associated with the render texture used by this camera. A valid id is retur...
Definition: BaseCamera.hh:701
virtual RenderPassPtr RenderPassByIndex(unsigned int _index) const =0
Get a render pass by index.
virtual bool SaveFrame(const std::string &_name) override
Writes the previously rendered frame to a file. This function can be called multiple times after Post...
Definition: BaseCamera.hh:407
math::Vector3d trackOffset
Set camera to track a point offset in target node&#39;s local or world frame depending on trackWorldFrame...
Definition: BaseCamera.hh:216
virtual void SetAntiAliasing(const unsigned int _aa) override
Set the level of anti-aliasing used during rendering. If a value of 0 is given, no anti-aliasing will...
Definition: BaseCamera.hh:568
virtual void SetImageHeight(const unsigned int _height) override
Set the image height in pixels.
Definition: BaseCamera.hh:273
T endl(T... args)
virtual void PostRender()=0
Post process this object and any of its children after rendering.
common::EventT< void(const void *, unsigned int, unsigned int, unsigned int, const std::string &)> newFrameEvent
Definition: BaseCamera.hh:189
virtual void SetImageWidth(const unsigned int _width) override
Set the image width in pixels.
Definition: BaseCamera.hh:259
shared_ptr< RenderWindow > RenderWindowPtr
Definition: RenderTypes.hh:202
virtual RenderPassPtr RenderPassByIndex(unsigned int _index) const override
Get a render passes by index.
Definition: BaseCamera.hh:731
virtual void SetFollowTarget(const NodePtr &_target, const math::Vector3d &_Offset, const bool _worldFrame) override
Set a node for camera to follow. The camera will automatically update its position to keep itself at ...
Definition: BaseCamera.hh:648
virtual void SetFormat(PixelFormat _format)=0
Set the render target image format.
virtual math::Matrix4d ProjectionMatrix() const override
Get the projection matrix for this camera.
Definition: BaseCamera.hh:464
< RGB, 1-byte per channel
Definition: PixelFormat.hh:39
bool equal(const T &_a, const T &_b, const T &_epsilon=T(1e-6))
math::Vector3d followOffset
Offset distance between camera and target node being followed.
Definition: BaseCamera.hh:233
virtual unsigned int AntiAliasing() const override
Get the level of anti-aliasing used during rendering.
Definition: BaseCamera.hh:561
ImagePtr imageBuffer
Definition: BaseCamera.hh:191
virtual double FollowPGain() const override
Get the camera follow movement P gain.
Definition: BaseCamera.hh:686
virtual RenderWindowPtr CreateRenderWindow() override
Create a render window.
Definition: BaseCamera.hh:454
virtual void SetImageFormat(PixelFormat _format) override
Set the image pixel format.
Definition: BaseCamera.hh:297
STL class.
shared_ptr< Visual > VisualPtr
Definition: RenderTypes.hh:228
Represents a render-target to which cameras can render images.
Definition: RenderTarget.hh:37
virtual math::Vector3d TrackOffset() const override
Get the track offset vector in the frame specified at the time the track target is set...
Definition: BaseCamera.hh:620
virtual ~BaseCamera()
Definition: BaseCamera.hh:246
virtual void RemoveRenderPass(const RenderPassPtr &_pass)=0
Remove a render pass from the render target.
virtual NodePtr TrackTarget() const override
Get the target node being tracked.
Definition: BaseCamera.hh:613
virtual double NearClipPlane() const override
Get the camera&#39;s near clipping plane distance.
Definition: BaseCamera.hh:589
virtual void Copy(Image &_image) const override
Writes the last rendered image to the given image buffer. This function can be called multiple times ...
Definition: BaseCamera.hh:400
virtual void SetMaterial(const MaterialPtr &_material) override
Set a material that the camera should see on all objects.
Definition: BaseCamera.hh:693
Definition: BaseCamera.hh:40
virtual void Load() override
Definition: BaseCamera.hh:431
Encapsulates a raw image buffer and relevant properties.
Definition: Image.hh:36
Pose3< double > Pose3d
virtual void Capture(Image &_image) override
Renders a new frame and writes the results to the given image. This is a convenience function for sin...
Definition: BaseCamera.hh:392
virtual void RemoveRenderPass(const RenderPassPtr &_pass) override
Remove a render pass from the camera.
Definition: BaseCamera.hh:717
virtual void SetWidth(const unsigned int _width)=0
Set the render target width in pixels.
virtual math::Vector3d FollowOffset() const override
Get the follow offset vector in the frame specified at the time the follow target is set...
Definition: BaseCamera.hh:665
Manages a single scene-graph. This class updates scene-wide properties and holds the root scene node...
Definition: Scene.hh:48
static Quaternion< T > Slerp(T _fT, const Quaternion< T > &_rkP, const Quaternion< T > &_rkQ, bool _shortestPath=false)
virtual unsigned int ImageMemorySize() const override
Get the total image memory size in bytes.
Definition: BaseCamera.hh:280
PixelFormat
Image pixel format types.
Definition: PixelFormat.hh:32
static const Quaternion Identity
virtual math::Matrix4d ViewMatrix() const override
Get the view matrix for this camera.
Definition: BaseCamera.hh:505
virtual unsigned int RenderPassCount() const override
Get the number of render passes applied to the camera.
Definition: BaseCamera.hh:724
virtual void Reset()
Definition: BaseCamera.hh:438
virtual void PreRender() override
Prepare this object and any of its children for rendering. This should be called for each object in a...
Definition: BaseCamera.hh:304
virtual RenderEngine * Engine() const =0
Get the creating render-engine of the scene.
const Quaternion< T > & Rot() const
Posable camera used for rendering the scene graph.
Definition: Camera.hh:40
virtual void SetHFOV(const math::Angle &_hfov) override
Set the camera&#39;s horizontal field-of-view.
Definition: BaseCamera.hh:540
void SetTranslation(const Vector3< T > &_t)
virtual unsigned int ImageWidth() const override
Get the image width in pixels.
Definition: BaseCamera.hh:252
NodePtr trackNode
Target node to track if camera tracking is on.
Definition: BaseCamera.hh:209
virtual double TrackPGain() const override
Get the camera track rotation P gain.
Definition: BaseCamera.hh:641
virtual unsigned int ImageHeight() const override
Get the image height in pixels.
Definition: BaseCamera.hh:266
virtual void PostRender() override
Preforms any necessary final rendering work. Once rendering is complete the camera will alert any lis...
Definition: BaseCamera.hh:366
NodePtr followNode
Target node to follow.
Definition: BaseCamera.hh:223
virtual void AddRenderPass(const RenderPassPtr &_pass) override
Add a render pass to the camera.
Definition: BaseCamera.hh:710
virtual void SetHeight(const unsigned int _height)=0
Set the render target height in pixels.
virtual void SetFarClipPlane(const double _far) override
Set the camera&#39;s far clipping plane distance.
Definition: BaseCamera.hh:582
virtual std::string Name() const =0
Get name of the render-engine.
virtual void PreRender()=0
Prepare this object and any of its children for rendering. This should be called for each object in a...
virtual void SetTrackTarget(const NodePtr &_target, const math::Vector3d &_offset, const bool _worldFrame) override
Set a node for camera to track. The camera will automatically change its orientation to face the targ...
Definition: BaseCamera.hh:603
#define ignerr
const Vector3< T > & Pos() const
virtual void SetFollowPGain(const double _pGain) override
Set follow P Gain. Determines how fast the camera moves to follow the target node. Valid range: [0-1].
Definition: BaseCamera.hh:679
virtual Image CreateImage() const override
Created an empty image buffer for capturing images. The resulting image will have sufficient memory a...
Definition: BaseCamera.hh:373
T tan(T... args)
virtual void Copy(Image &_image) const =0
Write rendered image to given Image. The RenderTarget will convert the underlying image to the specif...
virtual void SetAspectRatio(const double _ratio) override
Set the camera&#39;s aspect ratio. This value determines the cameras vertical field-of-view. It is often the.
Definition: BaseCamera.hh:554
virtual double AspectRatio() const override
Get the camera&#39;s aspect ratio.
Definition: BaseCamera.hh:547
virtual void PreRender()=0
Prepare scene for rendering. The scene will flushing any scene changes by traversing scene-graph...
virtual void Update() override
Renders a new frame. This is a convenience function for single-camera scenes. It wraps the pre-render...
Definition: BaseCamera.hh:383
virtual VisualPtr VisualAt(const ignition::math::Vector2i &_mousePos) override
Get the visual for a given mouse position param[in] _mousePos mouse position.
Definition: BaseCamera.hh:531
virtual void AddRenderPass(const RenderPassPtr &_pass)=0
Add a render pass to the render target.
virtual void SetNearClipPlane(const double _near) override
Set the camera&#39;s near clipping plane distance.
Definition: BaseCamera.hh:596
virtual unsigned int Width() const =0
Get render target width in pixels.
virtual PixelFormat ImageFormat() const override
Get the image pixel format. If the image pixel format has not been set with a valid value...
Definition: BaseCamera.hh:290
static Matrix4< T > LookAt(const Vector3< T > &_eye, const Vector3< T > &_target, const Vector3< T > &_up=Vector3< T >::UnitZ)
virtual math::Angle HFOV() const override
Get the camera&#39;s horizontal field-of-view.
Definition: BaseCamera.hh:524
virtual NodePtr FollowTarget() const override
Get the target node being followed.
Definition: BaseCamera.hh:658
T clamp(T _v, T _min, T _max)
math::Angle hfov
Horizontal camera field of view.
Definition: BaseCamera.hh:203
virtual unsigned int Height() const =0
Get render target height in pixels.
virtual void SetFollowOffset(const math::Vector3d &_offset) override
Set offset of camera from target node being followed. The offset will be in the frame that is specifi...
Definition: BaseCamera.hh:672
virtual PixelFormat Format() const =0
Set the render target image format.