VTK  9.3.20240328
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
132 #ifndef vtkCamera_h
133 #define vtkCamera_h
134 
135 #include "vtkObject.h"
136 #include "vtkRect.h" // for ivar
137 #include "vtkRenderingCoreModule.h" // For export macro
138 
139 VTK_ABI_NAMESPACE_BEGIN
141 class vtkInformation;
142 class vtkMatrix4x4;
144 class vtkRenderer;
145 class vtkTransform;
146 class vtkCallbackCommand;
147 class vtkCameraCallbackCommand;
148 
149 class VTKRENDERINGCORE_EXPORT vtkCamera : public vtkObject
150 {
151 public:
152  vtkTypeMacro(vtkCamera, vtkObject);
153  void PrintSelf(ostream& os, vtkIndent indent) override;
154 
160  static vtkCamera* New();
161 
163 
167  void SetPosition(double x, double y, double z);
168  void SetPosition(const double a[3]) { this->SetPosition(a[0], a[1], a[2]); }
169  vtkGetVector3Macro(Position, double);
171 
173 
177  void SetFocalPoint(double x, double y, double z);
178  void SetFocalPoint(const double a[3]) { this->SetFocalPoint(a[0], a[1], a[2]); }
179  vtkGetVector3Macro(FocalPoint, double);
181 
183 
187  void SetViewUp(double vx, double vy, double vz);
188  void SetViewUp(const double a[3]) { this->SetViewUp(a[0], a[1], a[2]); }
189  vtkGetVector3Macro(ViewUp, double);
191 
198 
203  void SetDistance(double);
204 
206 
210  vtkGetMacro(Distance, double);
212 
214 
219  vtkGetVector3Macro(DirectionOfProjection, double);
221 
228  void Dolly(double value);
229 
231 
234  void SetRoll(double angle);
235  double GetRoll();
237 
242  void Roll(double angle);
243 
250  void Azimuth(double angle);
251 
259  void Yaw(double angle);
260 
267  void Elevation(double angle);
268 
274  void Pitch(double angle);
275 
277 
284  vtkGetMacro(ParallelProjection, vtkTypeBool);
285  vtkBooleanMacro(ParallelProjection, vtkTypeBool);
287 
289 
300  vtkGetMacro(UseHorizontalViewAngle, vtkTypeBool);
301  vtkBooleanMacro(UseHorizontalViewAngle, vtkTypeBool);
303 
305 
316  void SetViewAngle(double angle);
317  vtkGetMacro(ViewAngle, double);
319 
321 
330  void SetParallelScale(double scale);
331  vtkGetMacro(ParallelScale, double);
333 
341  void Zoom(double factor);
342 
344 
357  void SetClippingRange(double dNear, double dFar);
358  void SetClippingRange(const double a[2]) { this->SetClippingRange(a[0], a[1]); }
359  vtkGetVector2Macro(ClippingRange, double);
361 
363 
370  void SetThickness(double);
371  vtkGetMacro(Thickness, double);
373 
375 
384  void SetWindowCenter(double x, double y);
385  vtkGetVector2Macro(WindowCenter, double);
387 
401  void SetObliqueAngles(double alpha, double beta);
402 
409 
411 
416  vtkGetVector3Macro(ViewPlaneNormal, double);
418 
420 
428  void SetViewShear(double dxdz, double dydz, double center);
429  void SetViewShear(double d[3]);
430  vtkGetVector3Macro(ViewShear, double);
432 
434 
438  vtkSetMacro(EyeAngle, double);
439  vtkGetMacro(EyeAngle, double);
441 
443 
449  vtkSetMacro(FocalDisk, double);
450  vtkGetMacro(FocalDisk, double);
452 
454 
462  vtkSetMacro(FocalDistance, double);
463  vtkGetMacro(FocalDistance, double);
465 
467 
476  vtkSetMacro(UseOffAxisProjection, vtkTypeBool);
477  vtkGetMacro(UseOffAxisProjection, vtkTypeBool);
478  vtkBooleanMacro(UseOffAxisProjection, vtkTypeBool);
480 
482 
488 
490 
495  vtkSetVector3Macro(ScreenBottomLeft, double);
496  vtkGetVector3Macro(ScreenBottomLeft, double);
498 
500 
505  vtkSetVector3Macro(ScreenBottomRight, double);
506  vtkGetVector3Macro(ScreenBottomRight, double);
508 
510 
515  vtkSetVector3Macro(ScreenTopRight, double);
516  vtkGetVector3Macro(ScreenTopRight, double);
518 
520 
525  vtkSetMacro(EyeSeparation, double);
526  vtkGetMacro(EyeSeparation, double);
528 
530 
536  void SetEyePosition(double eyePosition[3]);
537  void GetEyePosition(double eyePosition[3]);
539 
541 
549  void GetStereoEyePosition(double eyePosition[3]);
551 
556  void GetEyePlaneNormal(double normal[3]);
557 
559 
566  void SetEyeTransformMatrix(const double elements[16]);
567  vtkGetObjectMacro(EyeTransformMatrix, vtkMatrix4x4);
569 
571 
577  void SetModelTransformMatrix(const double elements[16]);
578  vtkGetObjectMacro(ModelTransformMatrix, vtkMatrix4x4);
580 
585 
590 
599 
610 
618  vtkGetObjectMacro(ExplicitProjectionTransformMatrix, vtkMatrix4x4);
626  vtkSetMacro(UseExplicitProjectionTransformMatrix, bool);
627  vtkGetMacro(UseExplicitProjectionTransformMatrix, bool);
628  vtkBooleanMacro(UseExplicitProjectionTransformMatrix, bool);
636  vtkSetMacro(ExplicitAspectRatio, double);
637  vtkGetMacro(ExplicitAspectRatio, double);
646  vtkSetMacro(UseExplicitAspectRatio, bool);
647  vtkGetMacro(UseExplicitAspectRatio, bool);
648  vtkBooleanMacro(UseExplicitAspectRatio, bool);
661  virtual vtkMatrix4x4* GetProjectionTransformMatrix(double aspect, double nearz, double farz);
662 
674  double aspect, double nearz, double farz);
675 
688  double aspect, double nearz, double farz);
689 
698 
700 
706  vtkGetObjectMacro(UserViewTransform, vtkHomogeneousTransform);
708 
710 
716  vtkGetObjectMacro(UserTransform, vtkHomogeneousTransform);
718 
724  virtual void Render(vtkRenderer*) {}
725 
730 
736 
747  virtual void GetFrustumPlanes(double aspect, double planes[24]);
748 
750 
760  virtual void UpdateIdealShiftScale(double aspect);
761  vtkGetVector3Macro(FocalPointShift, double);
762  vtkGetMacro(FocalPointScale, double);
763  vtkGetVector3Macro(NearPlaneShift, double);
764  vtkGetMacro(NearPlaneScale, double);
765  vtkSetMacro(ShiftScaleThreshold, double);
766  vtkGetMacro(ShiftScaleThreshold, double);
768 
770 
774  double* GetOrientationWXYZ() VTK_SIZEHINT(4);
776 
781  void ComputeViewPlaneNormal();
782 
788  vtkMatrix4x4* GetCameraLightTransformMatrix();
789 
793  virtual void UpdateViewport(vtkRenderer* vtkNotUsed(ren)) {}
794 
796 
799  vtkGetMacro(Stereo, int);
801 
803 
806  vtkSetMacro(LeftEye, int);
807  vtkGetMacro(LeftEye, int);
809 
817 
825 
827 
832  vtkSetMacro(FreezeFocalPoint, bool);
833  vtkGetMacro(FreezeFocalPoint, bool);
835 
837 
840  vtkSetMacro(UseScissor, bool);
841  vtkGetMacro(UseScissor, bool);
843 
845 
848  void SetScissorRect(vtkRecti scissorRect);
849  void GetScissorRect(vtkRecti& scissorRect);
851 
853 
856  vtkGetObjectMacro(Information, vtkInformation);
859 
860 protected:
862  ~vtkCamera() override;
863 
865 
869  virtual void ComputeViewTransform();
871 
875  virtual void ComputeProjectionTransform(double aspect, double nearz, double farz);
876 
880  void ComputeCompositeProjectionTransform(double aspect, double nearz, double farz);
881 
883 
889 
894 
899 
907 
908  double WindowCenter[2];
909  double ObliqueAngles[2];
910  double FocalPoint[3];
911  double Position[3];
912  double ViewUp[3];
913  double ViewAngle;
914  double ClippingRange[2];
915  double EyeAngle;
918  int Stereo;
919  int LeftEye;
920  double Thickness;
921  double Distance;
922  double DirectionOfProjection[3];
923  double ViewPlaneNormal[3];
924  double ViewShear[3];
926 
928 
929  double ScreenBottomLeft[3];
930  double ScreenBottomRight[3];
931  double ScreenTopRight[3];
932  double ScreenCenter[3];
933 
936 
939 
941 
944 
947 
950 
955 
957 
958  double FocalDisk;
960 
961  double FocalPointShift[3];
963  double NearPlaneShift[3];
966 
967  vtkCameraCallbackCommand* UserViewTransformCallbackCommand;
968  friend class vtkCameraCallbackCommand;
969 
970  // ViewingRaysMtime keeps track of camera modifications which will
971  // change the calculation of viewing rays for the camera before it is
972  // transformed to the camera's location and orientation.
976 
978 
979  // Arbitrary extra information associated with this camera.
981 
982 private:
983  vtkCamera(const vtkCamera&) = delete;
984  void operator=(const vtkCamera&) = delete;
985 };
986 
987 VTK_ABI_NAMESPACE_END
988 #endif
supports function callbacks
a virtual camera for 3D rendering
Definition: vtkCamera.h:150
bool UseExplicitProjectionTransformMatrix
Definition: vtkCamera.h:946
void ComputeOffAxisProjectionFrustum()
Compute and use frustum using offaxis method.
vtkInformation * Information
Definition: vtkCamera.h:980
virtual void SetInformation(vtkInformation *)
Set/Get the information object associated with this camera.
vtkMatrix4x4 * EyeTransformMatrix
Definition: vtkCamera.h:937
void Roll(double angle)
Rotate the camera about the direction of projection.
vtkTypeBool ParallelProjection
Definition: vtkCamera.h:916
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:953
void ComputeCameraLightTransform()
void SetViewUp(const double a[3])
Set/Get the view up direction for the camera.
Definition: vtkCamera.h:188
vtkTransform * ViewTransform
Definition: vtkCamera.h:951
double FocalDistance
Definition: vtkCamera.h:959
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:962
bool FreezeFocalPoint
Definition: vtkCamera.h:974
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:168
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:915
void Azimuth(double angle)
Rotate the camera about the view up vector centered at the focal point.
vtkHomogeneousTransform * UserTransform
Definition: vtkCamera.h:942
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:927
vtkMatrix4x4 * ExplicitProjectionTransformMatrix
Definition: vtkCamera.h:945
void SetObliqueAngles(double alpha, double beta)
Get/Set the oblique viewing angles.
double NearPlaneScale
Definition: vtkCamera.h:964
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:919
double EyeSeparation
Definition: vtkCamera.h:935
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:938
double * GetOrientation()
Get the orientation of the camera.
vtkMatrix4x4 * ModelTransformMatrix
Definition: vtkCamera.h:940
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:958
double Distance
Definition: vtkCamera.h:921
bool UseExplicitAspectRatio
Definition: vtkCamera.h:949
void SetModelTransformMatrix(const double elements[16])
Set/Get 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:724
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:178
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/Get eye transformation matrix.
double Thickness
Definition: vtkCamera.h:920
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:977
virtual vtkMatrix4x4 * GetModelViewTransformMatrix()
Return the model view matrix of model view transform.
vtkTransform * CameraLightTransform
Definition: vtkCamera.h:954
bool UseScissor
Definition: vtkCamera.h:975
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:925
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:918
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:913
void SetViewShear(double d[3])
Set/get the shear transform of the viewing frustum.
double ParallelScale
Definition: vtkCamera.h:917
void ComputeScreenOrientationMatrix()
Given screen screen top, bottom left and top right calculate screen orientation.
vtkHomogeneousTransform * UserViewTransform
Definition: vtkCamera.h:943
vtkPerspectiveTransform * ProjectionTransform
Definition: vtkCamera.h:952
vtkCameraCallbackCommand * UserViewTransformCallbackCommand
Definition: vtkCamera.h:967
double ShiftScaleThreshold
Definition: vtkCamera.h:965
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:956
double OffAxisClippingAdjustment
Definition: vtkCamera.h:934
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:358
vtkTimeStamp ViewingRaysMTime
Definition: vtkCamera.h:973
double ExplicitAspectRatio
Definition: vtkCamera.h:948
superclass for homogeneous transformations
a simple class to control print indentation
Definition: vtkIndent.h:108
Store vtkAlgorithm input/output information.
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:140
abstract base class for most VTK objects
Definition: vtkObject.h:161
describes a 4x4 matrix transformation
abstract specification for renderers
Definition: vtkRenderer.h:171
record modification and/or execution time
Definition: vtkTimeStamp.h:44
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:159
@ 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(...)