Ignition Rendering

API Reference

6.3.1
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>
28 
34 
35 namespace ignition
36 {
37  namespace rendering
38  {
39  inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
40  template <class T>
42 
43  template <class T>
44  class BaseCamera :
45  public virtual Camera,
46  public virtual T
47  {
48  protected: BaseCamera();
49 
50  public: virtual ~BaseCamera();
51 
52  public: virtual unsigned int ImageWidth() const override;
53 
54  public: virtual void SetImageWidth(const unsigned int _width) override;
55 
56  public: virtual unsigned int ImageHeight() const override;
57 
58  public: virtual void SetImageHeight(const unsigned int _height) override;
59 
60  public: virtual PixelFormat ImageFormat() const override;
61 
62  public: virtual unsigned int ImageMemorySize() const override;
63 
64  public: virtual void SetImageFormat(PixelFormat _format) override;
65 
66  public: virtual math::Angle HFOV() const override;
67 
68  public: virtual void SetHFOV(const math::Angle &_hfov) override;
69 
70  public: virtual double AspectRatio() const override;
71 
72  public: virtual void SetAspectRatio(const double _ratio) override;
73 
74  public: virtual unsigned int AntiAliasing() const override;
75 
76  public: virtual void SetAntiAliasing(const unsigned int _aa) override;
77 
78  public: virtual double FarClipPlane() const override;
79 
80  public: virtual void SetFarClipPlane(const double _far) override;
81 
82  public: virtual double NearClipPlane() const override;
83 
84  public: virtual void SetNearClipPlane(const double _near) override;
85 
86  // Documentation inherited.
87  public: virtual void PreRender() override;
88 
89  // Documentation inherited.
90  public: virtual void PostRender() override;
91 
92  public: virtual void Update() override;
93 
94  public: virtual Image CreateImage() const override;
95 
96  public: virtual void Capture(Image &_image) override;
97 
98  public: virtual void Copy(Image &_image) const override;
99 
100  public: virtual bool SaveFrame(const std::string &_name) override;
101 
102  public: virtual common::ConnectionPtr ConnectNewImageFrame(
103  Camera::NewFrameListener _listener) override;
104 
105  public: virtual RenderWindowPtr CreateRenderWindow() override;
106 
107  // Documentation inherited.
108  public: virtual VisualPtr VisualAt(const ignition::math::Vector2i
109  &_mousePos) override;
110 
111  // Documentation inherited.
112  public: virtual math::Matrix4d ProjectionMatrix() const override;
113 
114  // Documentation inherited.
115  public: virtual math::Matrix4d ViewMatrix() const override;
116 
117  // Documentation inherited.
118  public: virtual void SetProjectionMatrix(const math::Matrix4d &_matrix)
119  override;
120 
121  // Documentation inherited.
122  public: virtual CameraProjectionType ProjectionType() const override;
123 
124  // Documentation inherited.
125  public: virtual void SetProjectionType(
126  CameraProjectionType _type) override;
127 
128  // Documentation inherited.
129  public: virtual math::Vector2i Project(const math::Vector3d &_pt) const
130  override;
131 
132  // Documentation inherited.
133  // \sa Camera::SetMaterial(const MaterialPtr &) override;
134  public: virtual void SetMaterial(const MaterialPtr &_material)
135  override;
136 
137  // Documentation inherited.
138  public: virtual void SetTrackTarget(const NodePtr &_target,
139  const math::Vector3d &_offset,
140  const bool _worldFrame) override;
141 
142  // Documentation inherited.
143  public: virtual NodePtr TrackTarget() const override;
144 
145  // Documentation inherited.
146  public: virtual void SetTrackOffset(const math::Vector3d &_offset)
147  override;
148 
149  // Documentation inherited.
150  public: virtual math::Vector3d TrackOffset() const override;
151 
152  // Documentation inherited.
153  public: virtual void SetTrackPGain(const double _pGain) override;
154 
155  // Documentation inherited.
156  public: virtual double TrackPGain() const override;
157 
158  // Documentation inherited.
159  public: virtual void SetFollowTarget(const NodePtr &_target,
160  const math::Vector3d &_Offset, const bool _worldFrame)
161  override;
162 
163  // Documentation inherited.
164  public: virtual NodePtr FollowTarget() const override;
165 
166  // Documentation inherited.
167  public: virtual void SetFollowOffset(const math::Vector3d &_offset)
168  override;
169 
170  // Documentation inherited.
171  public: virtual math::Vector3d FollowOffset() const override;
172 
173  // Documentation inherited.
174  public: virtual void SetFollowPGain(const double _pGain) override;
175 
176  // Documentation inherited.
177  public: virtual double FollowPGain() const override;
178 
179  // Documentation inherited.
180  public: virtual unsigned int RenderTextureGLId() const override;
181 
182  // Documentation inherited.
183  public: virtual void AddRenderPass(const RenderPassPtr &_pass) override;
184 
185  // Documentation inherited.
186  public: virtual void RemoveRenderPass(const RenderPassPtr &_pass)
187  override;
188 
189  // Documentation inherited.
190  public: virtual unsigned int RenderPassCount() const override;
191 
192  // Documentation inherited.
193  public: virtual RenderPassPtr RenderPassByIndex(unsigned int _index)
194  const override;
195 
196  // Documentation inherited.
197  public: virtual void SetShadowsDirty() override;
198 
199  protected: virtual void *CreateImageBuffer() const;
200 
201  protected: virtual void Load() override;
202 
203  protected: virtual void Reset();
204 
205  protected: virtual RenderTargetPtr RenderTarget() const = 0;
206 
208  protected: common::EventT<void(const void *, unsigned int, unsigned int,
209  unsigned int, const std::string &)> newFrameEvent;
210 
211  protected: ImagePtr imageBuffer;
212 
214  protected: double nearClip = 0.01;
215 
217  protected: double farClip = 1000.0;
218 
220  protected: double aspect = 1.3333333;
221 
223  protected: math::Angle hfov;
224 
226  protected: unsigned int antiAliasing = 0u;
227 
229  protected: NodePtr trackNode;
230 
232  protected: bool trackWorldFrame = false;
233 
237 
240  protected: double trackPGain = 1.0;
241 
243  protected: NodePtr followNode;
245 
247  protected: bool followWorldFrame = false;
248 
251  protected: double followPGain = 1.0;
252 
255 
258 
260  protected: CameraProjectionType projectionType = CPT_PERSPECTIVE;
261 
262  friend class BaseDepthCamera<T>;
263  };
264 
266  template <class T>
268  {
269  }
270 
272  template <class T>
274  {
275  }
276 
278  template <class T>
279  unsigned int BaseCamera<T>::ImageWidth() const
280  {
281  return this->RenderTarget()->Width();
282  }
283 
285  template <class T>
286  void BaseCamera<T>::SetImageWidth(const unsigned int _width)
287  {
288  this->RenderTarget()->SetWidth(_width);
289  }
290 
292  template <class T>
293  unsigned int BaseCamera<T>::ImageHeight() const
294  {
295  return this->RenderTarget()->Height();
296  }
297 
299  template <class T>
300  void BaseCamera<T>::SetImageHeight(const unsigned int _height)
301  {
302  this->RenderTarget()->SetHeight(_height);
303  }
304 
306  template <class T>
307  unsigned int BaseCamera<T>::ImageMemorySize() const
308  {
309  PixelFormat format = this->ImageFormat();
310  unsigned int width = this->ImageWidth();
311  unsigned int height = this->ImageHeight();
312  return PixelUtil::MemorySize(format, width, height);
313  }
314 
316  template <class T>
318  {
319  return this->RenderTarget()->Format();
320  }
321 
323  template <class T>
325  {
326  this->RenderTarget()->SetFormat(_format);
327  }
328 
330  template <class T>
332  {
333  T::PreRender();
334 
335  this->RenderTarget()->PreRender();
336 
337  // camera following
338  if (this->followNode)
339  {
340  // tether camera fixed in world frame
341  if (this->followWorldFrame)
342  {
343  math::Vector3d targetCamPos =
344  this->followNode->WorldPosition() + this->followOffset;
345  math::Vector3d pos = this->WorldPosition() +
346  (targetCamPos - this->WorldPosition()) * this->followPGain;
347  this->SetWorldPosition(pos);
348  }
349  // tether camera fixed in target's local frame
350  else
351  {
352  math::Pose3d targetCamPose = math::Pose3d(this->followOffset,
353  this->WorldRotation());
354  targetCamPose = this->followNode->WorldPose() * targetCamPose;
355 
356  math::Vector3d pos = this->WorldPosition() +
357  (targetCamPose.Pos() - this->WorldPosition()) * this->followPGain;
358  this->SetWorldPosition(pos);
359  }
360  }
361 
362  // camera tracking
363  if (this->trackNode)
364  {
365  math::Vector3d eye = this->WorldPosition();
366  math::Pose3d targetPose = math::Pose3d(this->trackOffset,
368  if (this->trackWorldFrame)
369  {
370  targetPose.Pos() += this->trackNode->WorldPosition();
371  }
372  else
373  {
374  targetPose = this->trackNode->WorldPose() * targetPose;
375  }
376 
377  math::Pose3d p =
378  math::Matrix4d::LookAt(eye, targetPose.Pos()).Pose();
379 
380  math::Quaterniond q = p.Rot();
381  // skip slerp if we don't need it
382  if (!math::equal(this->trackPGain, 1.0))
383  {
385  this->trackPGain, this->WorldRotation(), p.Rot(), true);
386  }
387  this->SetWorldRotation(q);
388  }
389  }
390 
392  template <class T>
394  {
395  this->RenderTarget()->PostRender();
396  }
397 
399  template <class T>
401  {
402  PixelFormat format = this->ImageFormat();
403  unsigned int width = this->ImageWidth();
404  unsigned int height = this->ImageHeight();
405  return Image(width, height, format);
406  }
407 
409  template <class T>
411  {
412  this->Scene()->PreRender();
413  this->Render();
414  this->PostRender();
415  if (!this->Scene()->LegacyAutoGpuFlush())
416  {
417  this->Scene()->PostRender();
418  }
419  }
420 
422  template <class T>
424  {
425  this->Update();
426  this->Copy(_image);
427  }
428 
430  template <class T>
431  void BaseCamera<T>::Copy(Image &_image) const
432  {
433  this->RenderTarget()->Copy(_image);
434  }
435 
437  template <class T>
438  bool BaseCamera<T>::SaveFrame(const std::string &/*_name*/)
439  {
440  return false;
441  }
442 
444  template <class T>
446  Camera::NewFrameListener _listener)
447  {
448  return newFrameEvent.Connect(_listener);
449  }
450 
452  template <class T>
454  {
455  // TODO(anyone): determine proper type
456  unsigned int size = this->ImageMemorySize();
457  return new unsigned char *[size];
458  }
459 
461  template <class T>
463  {
464  T::Load();
465  }
466 
468  template <class T>
470  {
471  math::Angle fov;
472  fov.Degree(60);
473  this->SetImageWidth(1);
474  this->SetImageHeight(1);
475  this->SetImageFormat(PF_R8G8B8);
476  this->SetAspectRatio(1.33333);
477  this->SetAntiAliasing(0u);
478  this->SetHFOV(fov);
479  this->SetNearClipPlane(0.01);
480  this->SetFarClipPlane(1000);
481  }
482 
484  template <class T>
486  {
487  // Does nothing by default
488  ignerr << "Render window not supported for render engine: " <<
489  this->Scene()->Engine()->Name() << std::endl;
490  return RenderWindowPtr();
491  }
492 
494  template <class T>
496  {
497  math::Matrix4d result = this->projectionMatrix;
498  if (this->projectionType == CPT_PERSPECTIVE)
499  {
500  double ratio = this->AspectRatio();
501  double fov = this->HFOV().Radian();
502  double vfov = 2.0 * std::atan(std::tan(fov / 2.0) / ratio);
503  double f = 1.0;
504  double _near = this->NearClipPlane();
505  double _far = this->FarClipPlane();
506  double top = _near * std::tan(0.5*vfov) / f;
507  double height = 2 * top;
508  double width = ratio * height;
509  double left = -0.5 * width;
510  double right = left + width;
511  double bottom = top - height;
512 
513  double invw = 1.0 / (right - left);
514  double invh = 1.0 / (top - bottom);
515  double invd = 1.0 / (_far - _near);
516  double x = 2 * _near * invw;
517  double y = 2 * _near * invh;
518  double a = (right + left) * invw;
519  double b = (top + bottom) * invh;
520  double c = -(_far + _near) * invd;
521  double d = -2 * _far * _near * invd;
522  result(0, 0) = x;
523  result(0, 2) = a;
524  result(1, 1) = y;
525  result(1, 2) = b;
526  result(2, 2) = c;
527  result(2, 3) = d;
528  result(3, 2) = -1;
529  }
530  else if (this->projectionType == CPT_ORTHOGRAPHIC)
531  {
532  double width = this->ImageWidth();
533  double height = this->ImageHeight();
534  double left = -width * 0.5;
535  double right = -left;
536  double top = height * 0.5;
537  double bottom = -top;
538  double _near = this->NearClipPlane();
539  double _far = this->FarClipPlane();
540 
541  double invw = 1.0 / (right - left);
542  double invh = 1.0 / (top - bottom);
543  double invd = 1.0 / (_far - _near);
544 
545  result(0, 0) = 2.0 * invw;
546  result(0, 3) = -(right + left) * invw;
547  result(1, 1) = 2.0 * invh;
548  result(1, 3) = -(top + bottom) * invh;
549  result(2, 2) = -2.0 * invd;
550  result(2, 3) = -(_far + _near) * invd;
551  result(3, 3) = 1.0;
552  }
553  else
554  {
555  ignerr << "Unknown camera projection type: " << this->projectionType
556  << std::endl;
557  }
558 
559  return result;
560  }
561 
563  template <class T>
565  {
566  this->projectionMatrix = _matrix;
567  }
568 
570  template <class T>
572  {
573  math::Matrix3d r(this->WorldPose().Rot());
574  // transform from y up to z up
575  math::Matrix3d tf(0, 0, -1,
576  -1, 0, 0,
577  0, 1, 0);
578  r = r * tf;
579  r.Transpose();
580  math::Vector3d t = r * this->WorldPose().Pos() * -1;
581  math::Matrix4d result;
582  result = r;
583  result.SetTranslation(t);
584  result(3, 3) = 1.0;
585  return result;
586  }
587 
589  template <class T>
591  {
592  this->projectionType = _type;
593  }
594 
596  template <class T>
598  {
599  return this->projectionType;
600  }
601 
603  template <class T>
605  {
606  math::Vector2i screenPos;
607  math::Matrix4d m = this->ProjectionMatrix() * this->ViewMatrix();
608  math::Vector3d pos = m * _pt;
609  double w = m(3, 0) * _pt.X() + m(3, 1) * _pt.Y() + m(3, 2) * _pt.Z()
610  + m(3, 3);
611  pos.X() = pos.X() / w;
612  pos.Y() = pos.Y() / w;
613 
614  screenPos.X() = static_cast<int>(
615  ((pos.X() / 2.0) + 0.5) * this->ImageWidth());
616  screenPos.Y() = static_cast<int>(
617  (1 - ((pos.Y() / 2.0) + 0.5)) * this->ImageHeight());
618  return screenPos;
619  }
620 
622  template <class T>
624  {
625  return this->hfov;
626  }
627 
629  template <class T>
631  &/*_mousePos*/)
632  {
633  ignerr << "VisualAt not implemented for the render engine" << std::endl;
634  return VisualPtr();
635  }
636 
638  template <class T>
640  {
641  this->hfov = _hfov;
642  }
643 
645  template <class T>
647  {
648  return this->aspect;
649  }
650 
652  template <class T>
653  void BaseCamera<T>::SetAspectRatio(const double _aspect)
654  {
655  this->aspect = _aspect;
656  }
657 
659  template <class T>
660  unsigned int BaseCamera<T>::AntiAliasing() const
661  {
662  return this->antiAliasing;
663  }
664 
666  template <class T>
667  void BaseCamera<T>::SetAntiAliasing(const unsigned int _aa)
668  {
669  this->antiAliasing = _aa;
670  }
671 
673  template <class T>
675  {
676  return this->farClip;
677  }
678 
680  template <class T>
681  void BaseCamera<T>::SetFarClipPlane(const double _far)
682  {
683  this->farClip = _far;
684  }
685 
687  template <class T>
689  {
690  return this->nearClip;
691  }
692 
694  template <class T>
695  void BaseCamera<T>::SetNearClipPlane(const double _near)
696  {
697  this->nearClip = _near;
698  }
699 
701  template <class T>
703  const math::Vector3d &_offset, const bool _worldFrame)
704  {
705  this->trackNode = _target;
706  this->trackWorldFrame = _worldFrame;
707  this->trackOffset = _offset;
708  }
709 
711  template <class T>
713  {
714  return this->trackNode;
715  }
716 
718  template <class T>
720  {
721  return this->trackOffset;
722  }
723 
725  template <class T>
727  {
728  this->trackOffset = _offset;
729  }
730 
732  template <class T>
733  void BaseCamera<T>::SetTrackPGain(const double _pGain)
734  {
735  this->trackPGain = math::clamp(_pGain, 0.0, 1.0);
736  }
737 
739  template <class T>
741  {
742  return this->trackPGain;
743  }
744 
746  template <class T>
748  const math::Vector3d &_offset, const bool _worldFrame)
749  {
750  this->followNode = _target;
751  this->followWorldFrame = _worldFrame;
752  this->followOffset = _offset;
753  }
754 
756  template <class T>
758  {
759  return this->followNode;
760  }
761 
763  template <class T>
765  {
766  return this->followOffset;
767  }
768 
770  template <class T>
772  {
773  this->followOffset = _offset;
774  }
775 
777  template <class T>
778  void BaseCamera<T>::SetFollowPGain(const double _pGain)
779  {
780  this->followPGain = math::clamp(_pGain, 0.0, 1.0);
781  }
782 
784  template <class T>
786  {
787  return this->followPGain;
788  }
789 
791  template <class T>
792  void BaseCamera<T>::SetMaterial(const MaterialPtr &/*_material*/)
793  {
794  ignerr << "SetMaterial not implemented for current render"
795  << " engine" << std::endl;
796  }
797 
799  template <class T>
800  unsigned int BaseCamera<T>::RenderTextureGLId() const
801  {
802  ignerr << "RenderTextureGLId is not supported by current render"
803  << " engine" << std::endl;
804  return 0u;
805  }
806 
808  template <class T>
810  {
811  this->RenderTarget()->AddRenderPass(_pass);
812  }
813 
815  template <class T>
817  {
818  this->RenderTarget()->RemoveRenderPass(_pass);
819  }
820 
822  template <class T>
823  unsigned int BaseCamera<T>::RenderPassCount() const
824  {
825  return this->RenderTarget()->RenderPassCount();
826  }
827 
829  template <class T>
831  {
832  return this->RenderTarget()->RenderPassByIndex(_index);
833  }
834 
836  template <class T>
838  {
839  // no op
840  }
841  }
842  }
843 }
844 #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:453
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:726
BaseCamera()
Definition: BaseCamera.hh:267
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:733
Definition: BaseCamera.hh:44
virtual common::ConnectionPtr ConnectNewImageFrame(Camera::NewFrameListener _listener) override
Subscribes a new listener to this camera&#39;s new frame event.
Definition: BaseCamera.hh:445
void Degree(double _degree)
virtual double FarClipPlane() const override
Get the camera&#39;s far clipping plane distance.
Definition: BaseCamera.hh:674
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:800
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:438
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:236
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:667
virtual void SetImageHeight(const unsigned int _height) override
Set the image height in pixels.
Definition: BaseCamera.hh:300
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:209
virtual void SetImageWidth(const unsigned int _width) override
Set the image width in pixels.
Definition: BaseCamera.hh:286
virtual RenderPassPtr RenderPassByIndex(unsigned int _index) const override
Get a render passes by index.
Definition: BaseCamera.hh:830
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:747
virtual void SetFormat(PixelFormat _format)=0
Set the render target image format.
CameraProjectionType
Enum for projection types.
Definition: Camera.hh:39
virtual math::Matrix4d ProjectionMatrix() const override
Get the projection matrix for this camera.
Definition: BaseCamera.hh:495
< 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:254
virtual unsigned int AntiAliasing() const override
Get the level of anti-aliasing used during rendering.
Definition: BaseCamera.hh:660
#define IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
ImagePtr imageBuffer
Definition: BaseCamera.hh:211
virtual double FollowPGain() const override
Get the camera follow movement P gain.
Definition: BaseCamera.hh:785
Perspective projection.
Definition: Camera.hh:42
virtual RenderWindowPtr CreateRenderWindow() override
Create a render window.
Definition: BaseCamera.hh:485
virtual void SetImageFormat(PixelFormat _format) override
Set the image pixel format.
Definition: BaseCamera.hh:324
STL class.
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:719
virtual ~BaseCamera()
Definition: BaseCamera.hh:273
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:712
virtual double NearClipPlane() const override
Get the camera&#39;s near clipping plane distance.
Definition: BaseCamera.hh:688
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:431
virtual void SetMaterial(const MaterialPtr &_material) override
Set a material that the camera should see on all objects.
Definition: BaseCamera.hh:792
shared_ptr< RenderWindow > RenderWindowPtr
Shared pointer to RenderWindow.
Definition: RenderTypes.hh:243
Definition: BaseCamera.hh:41
virtual void Load() override
Definition: BaseCamera.hh:462
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:423
virtual void RemoveRenderPass(const RenderPassPtr &_pass) override
Remove a render pass from the camera.
Definition: BaseCamera.hh:816
virtual void SetWidth(const unsigned int _width)=0
Set the render target width in pixels.
Orthographic projection.
Definition: Camera.hh:44
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:764
Manages a single scene-graph. This class updates scene-wide properties and holds the root scene node...
Definition: Scene.hh:49
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:307
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:571
virtual unsigned int RenderPassCount() const override
Get the number of render passes applied to the camera.
Definition: BaseCamera.hh:823
virtual void Reset()
Definition: BaseCamera.hh:469
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:331
virtual RenderEngine * Engine() const =0
Get the creating render-engine of the scene.
const Quaternion< T > & Rot() const
virtual void SetProjectionMatrix(const math::Matrix4d &_matrix) override
Set the projection matrix for this camera. This overrides the standard projection matrix computed bas...
Definition: BaseCamera.hh:564
Posable camera used for rendering the scene graph.
Definition: Camera.hh:49
virtual void SetHFOV(const math::Angle &_hfov) override
Set the camera&#39;s horizontal field-of-view.
Definition: BaseCamera.hh:639
void SetTranslation(const Vector3< T > &_t)
virtual unsigned int ImageWidth() const override
Get the image width in pixels.
Definition: BaseCamera.hh:279
NodePtr trackNode
Target node to track if camera tracking is on.
Definition: BaseCamera.hh:229
virtual double TrackPGain() const override
Get the camera track rotation P gain.
Definition: BaseCamera.hh:740
virtual unsigned int ImageHeight() const override
Get the image height in pixels.
Definition: BaseCamera.hh:293
virtual void PostRender() override
Preforms any necessary final rendering work. Once rendering is complete the camera will alert any lis...
Definition: BaseCamera.hh:393
NodePtr followNode
Target node to follow.
Definition: BaseCamera.hh:243
virtual void AddRenderPass(const RenderPassPtr &_pass) override
Add a render pass to the camera.
Definition: BaseCamera.hh:809
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:681
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:702
#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:778
virtual Image CreateImage() const override
Created an empty image buffer for capturing images. The resulting image will have sufficient memory a...
Definition: BaseCamera.hh:400
T tan(T... args)
virtual void SetProjectionType(CameraProjectionType _type) override
Set the projection type for this camera This changes the projection matrix of the camera based on the...
Definition: BaseCamera.hh:590
virtual void Copy(Image &_image) const =0
Write rendered image to given Image. The RenderTarget will convert the underlying image to the specif...
math::Matrix4d projectionMatrix
Custom projection matrix.
Definition: BaseCamera.hh:257
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:653
virtual double AspectRatio() const override
Get the camera&#39;s aspect ratio.
Definition: BaseCamera.hh:646
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:410
virtual void PostRender()=0
Call this function after you&#39;re done updating ALL cameras.
virtual CameraProjectionType ProjectionType() const override
Get the projection type for this camera.
Definition: BaseCamera.hh:597
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:630
shared_ptr< Visual > VisualPtr
Shared pointer to Visual.
Definition: RenderTypes.hh:269
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:695
virtual void SetShadowsDirty() override
Definition: BaseCamera.hh:837
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:317
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:623
virtual math::Vector2i Project(const math::Vector3d &_pt) const override
Project point in 3d world space to 2d screen space.
Definition: BaseCamera.hh:604
virtual NodePtr FollowTarget() const override
Get the target node being followed.
Definition: BaseCamera.hh:757
T clamp(T _v, T _min, T _max)
math::Angle hfov
Horizontal camera field of view.
Definition: BaseCamera.hh:223
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:771
#define IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
virtual PixelFormat Format() const =0
Set the render target image format.