VTK  9.3.0
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 
444  void GetEyePlaneNormal(double normal[3]);
445 
447 
454  vtkGetObjectMacro(EyeTransformMatrix, vtkMatrix4x4);
456 
463  void SetEyeTransformMatrix(const double elements[16]);
464 
466 
472  vtkGetObjectMacro(ModelTransformMatrix, vtkMatrix4x4);
474 
480  void SetModelTransformMatrix(const double elements[16]);
481 
486 
491 
500 
511 
519  vtkGetObjectMacro(ExplicitProjectionTransformMatrix, vtkMatrix4x4);
527  vtkSetMacro(UseExplicitProjectionTransformMatrix, bool);
528  vtkGetMacro(UseExplicitProjectionTransformMatrix, bool);
529  vtkBooleanMacro(UseExplicitProjectionTransformMatrix, bool);
537  vtkSetMacro(ExplicitAspectRatio, double);
538  vtkGetMacro(ExplicitAspectRatio, double);
547  vtkSetMacro(UseExplicitAspectRatio, bool);
548  vtkGetMacro(UseExplicitAspectRatio, bool);
549  vtkBooleanMacro(UseExplicitAspectRatio, bool);
562  virtual vtkMatrix4x4* GetProjectionTransformMatrix(double aspect, double nearz, double farz);
563 
575  double aspect, double nearz, double farz);
576 
589  double aspect, double nearz, double farz);
590 
599 
601 
607  vtkGetObjectMacro(UserViewTransform, vtkHomogeneousTransform);
609 
611 
617  vtkGetObjectMacro(UserTransform, vtkHomogeneousTransform);
619 
625  virtual void Render(vtkRenderer*) {}
626 
631 
637 
648  virtual void GetFrustumPlanes(double aspect, double planes[24]);
649 
651 
661  virtual void UpdateIdealShiftScale(double aspect);
662  vtkGetVector3Macro(FocalPointShift, double);
663  vtkGetMacro(FocalPointScale, double);
664  vtkGetVector3Macro(NearPlaneShift, double);
665  vtkGetMacro(NearPlaneScale, double);
666  vtkSetMacro(ShiftScaleThreshold, double);
667  vtkGetMacro(ShiftScaleThreshold, double);
669 
671 
675  double* GetOrientationWXYZ() VTK_SIZEHINT(4);
677 
682  void ComputeViewPlaneNormal();
683 
689  vtkMatrix4x4* GetCameraLightTransformMatrix();
690 
694  virtual void UpdateViewport(vtkRenderer* vtkNotUsed(ren)) {}
695 
697 
700  vtkGetMacro(Stereo, int);
702 
704 
707  vtkSetMacro(LeftEye, int);
708  vtkGetMacro(LeftEye, int);
710 
718 
726 
728 
733  vtkSetMacro(FreezeFocalPoint, bool);
734  vtkGetMacro(FreezeFocalPoint, bool);
736 
738 
741  vtkSetMacro(UseScissor, bool);
742  vtkGetMacro(UseScissor, bool);
744 
746 
749  void SetScissorRect(vtkRecti scissorRect);
750  void GetScissorRect(vtkRecti& scissorRect);
752 
754 
757  vtkGetObjectMacro(Information, vtkInformation);
760 
761 protected:
763  ~vtkCamera() override;
764 
766 
770  virtual void ComputeViewTransform();
772 
776  virtual void ComputeProjectionTransform(double aspect, double nearz, double farz);
777 
781  void ComputeCompositeProjectionTransform(double aspect, double nearz, double farz);
782 
784 
790 
795 
800 
808 
809  double WindowCenter[2];
810  double ObliqueAngles[2];
811  double FocalPoint[3];
812  double Position[3];
813  double ViewUp[3];
814  double ViewAngle;
815  double ClippingRange[2];
816  double EyeAngle;
819  int Stereo;
820  int LeftEye;
821  double Thickness;
822  double Distance;
823  double DirectionOfProjection[3];
824  double ViewPlaneNormal[3];
825  double ViewShear[3];
827 
829 
830  double ScreenBottomLeft[3];
831  double ScreenBottomRight[3];
832  double ScreenTopRight[3];
833  double ScreenCenter[3];
834 
837 
840 
842 
845 
848 
851 
856 
858 
859  double FocalDisk;
861 
862  double FocalPointShift[3];
864  double NearPlaneShift[3];
867 
868  vtkCameraCallbackCommand* UserViewTransformCallbackCommand;
869  friend class vtkCameraCallbackCommand;
870 
871  // ViewingRaysMtime keeps track of camera modifications which will
872  // change the calculation of viewing rays for the camera before it is
873  // transformed to the camera's location and orientation.
877 
879 
880  // Arbitrary extra information associated with this camera.
882 
883 private:
884  vtkCamera(const vtkCamera&) = delete;
885  void operator=(const vtkCamera&) = delete;
886 };
887 
888 VTK_ABI_NAMESPACE_END
889 #endif
supports function callbacks
a virtual camera for 3D rendering
Definition: vtkCamera.h:50
bool UseExplicitProjectionTransformMatrix
Definition: vtkCamera.h:847
void ComputeOffAxisProjectionFrustum()
Compute and use frustum using offaxis method.
vtkInformation * Information
Definition: vtkCamera.h:881
virtual void SetInformation(vtkInformation *)
Set/Get the information object associated with this camera.
vtkMatrix4x4 * EyeTransformMatrix
Definition: vtkCamera.h:838
void Roll(double angle)
Rotate the camera about the direction of projection.
vtkTypeBool ParallelProjection
Definition: vtkCamera.h:817
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:854
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:852
double FocalDistance
Definition: vtkCamera.h:860
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:863
bool FreezeFocalPoint
Definition: vtkCamera.h:875
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:816
void Azimuth(double angle)
Rotate the camera about the view up vector centered at the focal point.
vtkHomogeneousTransform * UserTransform
Definition: vtkCamera.h:843
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:828
vtkMatrix4x4 * ExplicitProjectionTransformMatrix
Definition: vtkCamera.h:846
void SetObliqueAngles(double alpha, double beta)
Get/Set the oblique viewing angles.
double NearPlaneScale
Definition: vtkCamera.h:865
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:820
double EyeSeparation
Definition: vtkCamera.h:836
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:839
double * GetOrientation()
Get the orientation of the camera.
vtkMatrix4x4 * ModelTransformMatrix
Definition: vtkCamera.h:841
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:859
double Distance
Definition: vtkCamera.h:822
bool UseExplicitAspectRatio
Definition: vtkCamera.h:850
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:625
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:821
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:878
virtual vtkMatrix4x4 * GetModelViewTransformMatrix()
Return the model view matrix of model view transform.
vtkTransform * CameraLightTransform
Definition: vtkCamera.h:855
bool UseScissor
Definition: vtkCamera.h:876
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:826
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:819
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:814
void SetViewShear(double d[3])
Set/get the shear transform of the viewing frustum.
double ParallelScale
Definition: vtkCamera.h:818
void ComputeScreenOrientationMatrix()
Given screen screen top, bottom left and top right calculate screen orientation.
vtkHomogeneousTransform * UserViewTransform
Definition: vtkCamera.h:844
vtkPerspectiveTransform * ProjectionTransform
Definition: vtkCamera.h:853
vtkCameraCallbackCommand * UserViewTransformCallbackCommand
Definition: vtkCamera.h:868
double ShiftScaleThreshold
Definition: vtkCamera.h:866
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:857
double OffAxisClippingAdjustment
Definition: vtkCamera.h:835
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:874
double ExplicitAspectRatio
Definition: vtkCamera.h:849
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(...)