VTK  9.3.1
vtkCamera.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
32 #ifndef vtkCamera_h
33 #define vtkCamera_h
34 
35 #include "vtkObject.h"
36 #include "vtkRect.h" // for ivar
37 #include "vtkRenderingCoreModule.h" // For export macro
38 
39 VTK_ABI_NAMESPACE_BEGIN
41 class vtkInformation;
42 class vtkMatrix4x4;
44 class vtkRenderer;
45 class vtkTransform;
46 class vtkCallbackCommand;
47 class vtkCameraCallbackCommand;
48 
49 class VTKRENDERINGCORE_EXPORT vtkCamera : public vtkObject
50 {
51 public:
52  vtkTypeMacro(vtkCamera, vtkObject);
53  void PrintSelf(ostream& os, vtkIndent indent) override;
54 
60  static vtkCamera* New();
61 
63 
67  void SetPosition(double x, double y, double z);
68  void SetPosition(const double a[3]) { this->SetPosition(a[0], a[1], a[2]); }
69  vtkGetVector3Macro(Position, double);
71 
73 
77  void SetFocalPoint(double x, double y, double z);
78  void SetFocalPoint(const double a[3]) { this->SetFocalPoint(a[0], a[1], a[2]); }
79  vtkGetVector3Macro(FocalPoint, double);
81 
83 
87  void SetViewUp(double vx, double vy, double vz);
88  void SetViewUp(const double a[3]) { this->SetViewUp(a[0], a[1], a[2]); }
89  vtkGetVector3Macro(ViewUp, double);
91 
98 
103  void SetDistance(double);
104 
106 
110  vtkGetMacro(Distance, double);
112 
114 
119  vtkGetVector3Macro(DirectionOfProjection, double);
121 
128  void Dolly(double value);
129 
131 
134  void SetRoll(double angle);
135  double GetRoll();
137 
142  void Roll(double angle);
143 
150  void Azimuth(double angle);
151 
159  void Yaw(double angle);
160 
167  void Elevation(double angle);
168 
174  void Pitch(double angle);
175 
177 
184  vtkGetMacro(ParallelProjection, vtkTypeBool);
185  vtkBooleanMacro(ParallelProjection, vtkTypeBool);
187 
189 
200  vtkGetMacro(UseHorizontalViewAngle, vtkTypeBool);
201  vtkBooleanMacro(UseHorizontalViewAngle, vtkTypeBool);
203 
205 
216  void SetViewAngle(double angle);
217  vtkGetMacro(ViewAngle, double);
219 
221 
230  void SetParallelScale(double scale);
231  vtkGetMacro(ParallelScale, double);
233 
241  void Zoom(double factor);
242 
244 
257  void SetClippingRange(double dNear, double dFar);
258  void SetClippingRange(const double a[2]) { this->SetClippingRange(a[0], a[1]); }
259  vtkGetVector2Macro(ClippingRange, double);
261 
263 
270  void SetThickness(double);
271  vtkGetMacro(Thickness, double);
273 
275 
284  void SetWindowCenter(double x, double y);
285  vtkGetVector2Macro(WindowCenter, double);
287 
301  void SetObliqueAngles(double alpha, double beta);
302 
309 
311 
316  vtkGetVector3Macro(ViewPlaneNormal, double);
318 
320 
328  void SetViewShear(double dxdz, double dydz, double center);
329  void SetViewShear(double d[3]);
330  vtkGetVector3Macro(ViewShear, double);
332 
334 
338  vtkSetMacro(EyeAngle, double);
339  vtkGetMacro(EyeAngle, double);
341 
343 
349  vtkSetMacro(FocalDisk, double);
350  vtkGetMacro(FocalDisk, double);
352 
354 
362  vtkSetMacro(FocalDistance, double);
363  vtkGetMacro(FocalDistance, double);
365 
367 
376  vtkSetMacro(UseOffAxisProjection, vtkTypeBool);
377  vtkGetMacro(UseOffAxisProjection, vtkTypeBool);
378  vtkBooleanMacro(UseOffAxisProjection, vtkTypeBool);
380 
382 
388 
390 
395  vtkSetVector3Macro(ScreenBottomLeft, double);
396  vtkGetVector3Macro(ScreenBottomLeft, double);
398 
400 
405  vtkSetVector3Macro(ScreenBottomRight, double);
406  vtkGetVector3Macro(ScreenBottomRight, double);
408 
410 
415  vtkSetVector3Macro(ScreenTopRight, double);
416  vtkGetVector3Macro(ScreenTopRight, double);
418 
420 
425  vtkSetMacro(EyeSeparation, double);
426  vtkGetMacro(EyeSeparation, double);
428 
430 
436  void SetEyePosition(double eyePosition[3]);
437  void GetEyePosition(double eyePosition[3]);
439 
441 
449  void GetStereoEyePosition(double eyePosition[3]);
451 
456  void GetEyePlaneNormal(double normal[3]);
457 
459 
466  vtkGetObjectMacro(EyeTransformMatrix, vtkMatrix4x4);
468 
475  void SetEyeTransformMatrix(const double elements[16]);
476 
478 
484  vtkGetObjectMacro(ModelTransformMatrix, vtkMatrix4x4);
486 
492  void SetModelTransformMatrix(const double elements[16]);
493 
498 
503 
512 
523 
531  vtkGetObjectMacro(ExplicitProjectionTransformMatrix, vtkMatrix4x4);
539  vtkSetMacro(UseExplicitProjectionTransformMatrix, bool);
540  vtkGetMacro(UseExplicitProjectionTransformMatrix, bool);
541  vtkBooleanMacro(UseExplicitProjectionTransformMatrix, bool);
549  vtkSetMacro(ExplicitAspectRatio, double);
550  vtkGetMacro(ExplicitAspectRatio, double);
559  vtkSetMacro(UseExplicitAspectRatio, bool);
560  vtkGetMacro(UseExplicitAspectRatio, bool);
561  vtkBooleanMacro(UseExplicitAspectRatio, bool);
574  virtual vtkMatrix4x4* GetProjectionTransformMatrix(double aspect, double nearz, double farz);
575 
587  double aspect, double nearz, double farz);
588 
601  double aspect, double nearz, double farz);
602 
611 
613 
619  vtkGetObjectMacro(UserViewTransform, vtkHomogeneousTransform);
621 
623 
629  vtkGetObjectMacro(UserTransform, vtkHomogeneousTransform);
631 
637  virtual void Render(vtkRenderer*) {}
638 
643 
649 
660  virtual void GetFrustumPlanes(double aspect, double planes[24]);
661 
663 
673  virtual void UpdateIdealShiftScale(double aspect);
674  vtkGetVector3Macro(FocalPointShift, double);
675  vtkGetMacro(FocalPointScale, double);
676  vtkGetVector3Macro(NearPlaneShift, double);
677  vtkGetMacro(NearPlaneScale, double);
678  vtkSetMacro(ShiftScaleThreshold, double);
679  vtkGetMacro(ShiftScaleThreshold, double);
681 
683 
687  double* GetOrientationWXYZ() VTK_SIZEHINT(4);
689 
694  void ComputeViewPlaneNormal();
695 
701  vtkMatrix4x4* GetCameraLightTransformMatrix();
702 
706  virtual void UpdateViewport(vtkRenderer* vtkNotUsed(ren)) {}
707 
709 
712  vtkGetMacro(Stereo, int);
714 
716 
719  vtkSetMacro(LeftEye, int);
720  vtkGetMacro(LeftEye, int);
722 
730 
738 
740 
745  vtkSetMacro(FreezeFocalPoint, bool);
746  vtkGetMacro(FreezeFocalPoint, bool);
748 
750 
753  vtkSetMacro(UseScissor, bool);
754  vtkGetMacro(UseScissor, bool);
756 
758 
761  void SetScissorRect(vtkRecti scissorRect);
762  void GetScissorRect(vtkRecti& scissorRect);
764 
766 
769  vtkGetObjectMacro(Information, vtkInformation);
772 
773 protected:
775  ~vtkCamera() override;
776 
778 
782  virtual void ComputeViewTransform();
784 
788  virtual void ComputeProjectionTransform(double aspect, double nearz, double farz);
789 
793  void ComputeCompositeProjectionTransform(double aspect, double nearz, double farz);
794 
796 
802 
807 
812 
820 
821  double WindowCenter[2];
822  double ObliqueAngles[2];
823  double FocalPoint[3];
824  double Position[3];
825  double ViewUp[3];
826  double ViewAngle;
827  double ClippingRange[2];
828  double EyeAngle;
831  int Stereo;
832  int LeftEye;
833  double Thickness;
834  double Distance;
835  double DirectionOfProjection[3];
836  double ViewPlaneNormal[3];
837  double ViewShear[3];
839 
841 
842  double ScreenBottomLeft[3];
843  double ScreenBottomRight[3];
844  double ScreenTopRight[3];
845  double ScreenCenter[3];
846 
849 
852 
854 
857 
860 
863 
868 
870 
871  double FocalDisk;
873 
874  double FocalPointShift[3];
876  double NearPlaneShift[3];
879 
880  vtkCameraCallbackCommand* UserViewTransformCallbackCommand;
881  friend class vtkCameraCallbackCommand;
882 
883  // ViewingRaysMtime keeps track of camera modifications which will
884  // change the calculation of viewing rays for the camera before it is
885  // transformed to the camera's location and orientation.
889 
891 
892  // Arbitrary extra information associated with this camera.
894 
895 private:
896  vtkCamera(const vtkCamera&) = delete;
897  void operator=(const vtkCamera&) = delete;
898 };
899 
900 VTK_ABI_NAMESPACE_END
901 #endif
supports function callbacks
a virtual camera for 3D rendering
Definition: vtkCamera.h:50
bool UseExplicitProjectionTransformMatrix
Definition: vtkCamera.h:859
void ComputeOffAxisProjectionFrustum()
Compute and use frustum using offaxis method.
vtkInformation * Information
Definition: vtkCamera.h:893
virtual void SetInformation(vtkInformation *)
Set/Get the information object associated with this camera.
vtkMatrix4x4 * EyeTransformMatrix
Definition: vtkCamera.h:850
void Roll(double angle)
Rotate the camera about the direction of projection.
vtkTypeBool ParallelProjection
Definition: vtkCamera.h:829
void ApplyTransform(vtkTransform *t)
Apply a transform to the camera.
void SetModelTransformMatrix(vtkMatrix4x4 *matrix)
Set/Get model transformation matrix.
double GetRoll()
Set the roll angle of the camera about the direction of projection.
vtkPerspectiveTransform * Transform
Definition: vtkCamera.h:866
void ComputeCameraLightTransform()
void SetViewUp(const double a[3])
Set/Get the view up direction for the camera.
Definition: vtkCamera.h:88
vtkTransform * ViewTransform
Definition: vtkCamera.h:864
double FocalDistance
Definition: vtkCamera.h:872
void SetUserTransform(vtkHomogeneousTransform *transform)
In addition to the instance variables such as position and orientation, you can add an additional tra...
virtual void ComputeViewTransform()
These methods should only be used within vtkCamera.cxx.
double FocalPointScale
Definition: vtkCamera.h:875
bool FreezeFocalPoint
Definition: vtkCamera.h:887
void GetStereoEyePosition(double eyePosition[3])
Using the LeftEye property to determine whether left or right eye is being requested,...
void SetEyePosition(double eyePosition[3])
Set/Get the eye position (center point between two eyes).
void SetPosition(const double a[3])
Set/Get the position of the camera in world coordinates.
Definition: vtkCamera.h:68
virtual vtkMatrix4x4 * GetViewTransformMatrix()
For backward compatibility.
void Yaw(double angle)
Rotate the focal point about the view up vector, using the camera's position as the center of rotatio...
void SetRoll(double angle)
Set the roll angle of the camera about the direction of projection.
void PartialCopy(vtkCamera *source)
Copy the ivars.
void Elevation(double angle)
Rotate the camera about the cross product of the negative of the direction of projection and the view...
double EyeAngle
Definition: vtkCamera.h:828
void Azimuth(double angle)
Rotate the camera about the view up vector centered at the focal point.
vtkHomogeneousTransform * UserTransform
Definition: vtkCamera.h:855
void DeepCopy(vtkCamera *source)
Copy the properties of ‘source’ into ‘this’.
virtual vtkMatrix4x4 * GetProjectionTransformMatrix(double aspect, double nearz, double farz)
Return the projection transform matrix, which converts from camera coordinates to viewport coordinate...
void Pitch(double angle)
Rotate the focal point about the cross product of the view up vector and the direction of projection,...
vtkTypeBool UseOffAxisProjection
Definition: vtkCamera.h:840
vtkMatrix4x4 * ExplicitProjectionTransformMatrix
Definition: vtkCamera.h:858
void SetObliqueAngles(double alpha, double beta)
Get/Set the oblique viewing angles.
double NearPlaneScale
Definition: vtkCamera.h:877
void SetParallelProjection(vtkTypeBool flag)
Set/Get the value of the ParallelProjection instance variable.
void ComputeModelViewMatrix()
Compute model view matrix for the camera.
int LeftEye
Definition: vtkCamera.h:832
double EyeSeparation
Definition: vtkCamera.h:848
virtual void GetFrustumPlanes(double aspect, double planes[24])
Get the plane equations that bound the view frustum.
void Zoom(double factor)
In perspective mode, decrease the view angle by the specified factor.
void SetPosition(double x, double y, double z)
Set/Get the position of the camera in world coordinates.
void SetViewUp(double vx, double vy, double vz)
Set/Get the view up direction for the camera.
vtkMatrix4x4 * ProjectionPlaneOrientationMatrix
Definition: vtkCamera.h:851
double * GetOrientation()
Get the orientation of the camera.
vtkMatrix4x4 * ModelTransformMatrix
Definition: vtkCamera.h:853
void ShallowCopy(vtkCamera *source)
Copy the properties of ‘source’ into ‘this’.
static vtkCamera * New()
Construct camera instance with its focal point at the origin, and position=(0,0,1).
double FocalDisk
Definition: vtkCamera.h:871
double Distance
Definition: vtkCamera.h:834
bool UseExplicitAspectRatio
Definition: vtkCamera.h:862
void SetModelTransformMatrix(const double elements[16])
Set model transformation matrix.
void SetClippingRange(double dNear, double dFar)
Set/Get the location of the near and far clipping planes along the direction of projection.
void SetThickness(double)
Set the distance between clipping planes.
void GetScissorRect(vtkRecti &scissorRect)
Set/Get the vtkRect value of the scissor.
virtual void Render(vtkRenderer *)
This method causes the camera to set up whatever is required for viewing the scene.
Definition: vtkCamera.h:637
void ViewingRaysModified()
Mark that something has changed which requires the view rays to be recomputed.
void SetFocalPoint(const double a[3])
Set/Get the focal of the camera in world coordinates.
Definition: vtkCamera.h:78
void SetEyeTransformMatrix(vtkMatrix4x4 *matrix)
Set/Get eye transformation matrix.
void GetEyePosition(double eyePosition[3])
Set/Get the eye position (center point between two eyes).
void SetDistance(double)
Move the focal point so that it is the specified distance from the camera position.
virtual vtkTransform * GetModelViewTransformObject()
Return the model view transform.
void SetWindowCenter(double x, double y)
Set/Get the center of the window in viewport coordinates.
void SetEyeTransformMatrix(const double elements[16])
Set the eye transform matrix.
double Thickness
Definition: vtkCamera.h:833
void SetScissorRect(vtkRecti scissorRect)
Set/Get the vtkRect value of the scissor.
virtual vtkMatrix4x4 * GetProjectionTransformMatrix(vtkRenderer *ren)
Return the projection transform matrix, which converts from camera coordinates to viewport coordinate...
void ComputeCompositeProjectionTransform(double aspect, double nearz, double farz)
These methods should only be used within vtkCamera.cxx.
vtkRecti ScissorRect
Definition: vtkCamera.h:890
virtual vtkMatrix4x4 * GetModelViewTransformMatrix()
Return the model view matrix of model view transform.
vtkTransform * CameraLightTransform
Definition: vtkCamera.h:867
bool UseScissor
Definition: vtkCamera.h:888
void SetViewAngle(double angle)
Set/Get the camera view angle, which is the angular height of the camera view measured in degrees.
void GetEyePlaneNormal(double normal[3])
Get normal vector from eye to screen rotated by EyeTransformMatrix.
vtkTypeBool UseHorizontalViewAngle
Definition: vtkCamera.h:838
void OrthogonalizeViewUp()
Recompute the ViewUp vector to force it to be perpendicular to camera->focalpoint vector.
void Dolly(double value)
Divide the camera's distance from the focal point by the given dolly value.
virtual void SetExplicitProjectionTransformMatrix(vtkMatrix4x4 *)
Set/get an explicit 4x4 projection matrix to use, rather than computing one from other state variable...
vtkMTimeType GetViewingRaysMTime()
Return the MTime that concerns recomputing the view rays of the camera.
void SetFocalPoint(double x, double y, double z)
Set/Get the focal of the camera in world coordinates.
void SetUseHorizontalViewAngle(vtkTypeBool flag)
Set/Get the value of the UseHorizontalViewAngle instance variable.
int Stereo
Definition: vtkCamera.h:831
virtual vtkMatrix4x4 * GetCompositeProjectionTransformMatrix(double aspect, double nearz, double farz)
Return the concatenation of the ViewTransform and the ProjectionTransform.
~vtkCamera() override
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetParallelScale(double scale)
Set/Get the scaling used for a parallel projection, i.e.
double ViewAngle
Definition: vtkCamera.h:826
void SetViewShear(double d[3])
Set/get the shear transform of the viewing frustum.
double ParallelScale
Definition: vtkCamera.h:830
void ComputeScreenOrientationMatrix()
Given screen screen top, bottom left and top right calculate screen orientation.
vtkHomogeneousTransform * UserViewTransform
Definition: vtkCamera.h:856
vtkPerspectiveTransform * ProjectionTransform
Definition: vtkCamera.h:865
vtkCameraCallbackCommand * UserViewTransformCallbackCommand
Definition: vtkCamera.h:880
double ShiftScaleThreshold
Definition: vtkCamera.h:878
virtual void ComputeProjectionTransform(double aspect, double nearz, double farz)
These methods should only be used within vtkCamera.cxx.
void SetUserViewTransform(vtkHomogeneousTransform *transform)
In addition to the instance variables such as position and orientation, you can add an additional tra...
void ComputeDistance()
These methods should only be used within vtkCamera.cxx.
double GetOffAxisClippingAdjustment()
Get adjustment to clipping thickness, computed by camera based on the physical size of the screen and...
virtual vtkTransform * GetViewTransformObject()
For backward compatibility.
void SetViewShear(double dxdz, double dydz, double center)
Set/get the shear transform of the viewing frustum.
virtual void UpdateIdealShiftScale(double aspect)
The following methods are used to support view dependent methods for normalizing data (typically poin...
virtual vtkPerspectiveTransform * GetProjectionTransformObject(double aspect, double nearz, double farz)
Return the projection transform matrix, which converts from camera coordinates to viewport coordinate...
vtkTransform * ModelViewTransform
Definition: vtkCamera.h:869
double OffAxisClippingAdjustment
Definition: vtkCamera.h:847
void SetClippingRange(const double a[2])
Set/Get the location of the near and far clipping planes along the direction of projection.
Definition: vtkCamera.h:258
vtkTimeStamp ViewingRaysMTime
Definition: vtkCamera.h:886
double ExplicitAspectRatio
Definition: vtkCamera.h:861
superclass for homogeneous transformations
a simple class to control print indentation
Definition: vtkIndent.h:38
Store vtkAlgorithm input/output information.
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:40
abstract base class for most VTK objects
Definition: vtkObject.h:61
describes a 4x4 matrix transformation
abstract specification for renderers
Definition: vtkRenderer.h:71
record modification and/or execution time
Definition: vtkTimeStamp.h:34
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:59
@ value
Definition: vtkX3D.h:220
@ scale
Definition: vtkX3D.h:229
@ center
Definition: vtkX3D.h:230
@ alpha
Definition: vtkX3D.h:250
int vtkTypeBool
Definition: vtkABI.h:64
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270
#define VTK_SIZEHINT(...)