VTK  9.2.20230205
vtkCamera.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkCamera.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
144 #ifndef vtkCamera_h
145 #define vtkCamera_h
146 
147 #include "vtkObject.h"
148 #include "vtkRect.h" // for ivar
149 #include "vtkRenderingCoreModule.h" // For export macro
150 
151 VTK_ABI_NAMESPACE_BEGIN
153 class vtkInformation;
154 class vtkMatrix4x4;
156 class vtkRenderer;
157 class vtkTransform;
158 class vtkCallbackCommand;
159 class vtkCameraCallbackCommand;
160 
161 class VTKRENDERINGCORE_EXPORT vtkCamera : public vtkObject
162 {
163 public:
164  vtkTypeMacro(vtkCamera, vtkObject);
165  void PrintSelf(ostream& os, vtkIndent indent) override;
166 
172  static vtkCamera* New();
173 
175 
179  void SetPosition(double x, double y, double z);
180  void SetPosition(const double a[3]) { this->SetPosition(a[0], a[1], a[2]); }
181  vtkGetVector3Macro(Position, double);
183 
185 
189  void SetFocalPoint(double x, double y, double z);
190  void SetFocalPoint(const double a[3]) { this->SetFocalPoint(a[0], a[1], a[2]); }
191  vtkGetVector3Macro(FocalPoint, double);
193 
195 
199  void SetViewUp(double vx, double vy, double vz);
200  void SetViewUp(const double a[3]) { this->SetViewUp(a[0], a[1], a[2]); }
201  vtkGetVector3Macro(ViewUp, double);
203 
210 
215  void SetDistance(double);
216 
218 
222  vtkGetMacro(Distance, double);
224 
226 
231  vtkGetVector3Macro(DirectionOfProjection, double);
233 
240  void Dolly(double value);
241 
243 
246  void SetRoll(double angle);
247  double GetRoll();
249 
254  void Roll(double angle);
255 
262  void Azimuth(double angle);
263 
271  void Yaw(double angle);
272 
279  void Elevation(double angle);
280 
286  void Pitch(double angle);
287 
289 
296  vtkGetMacro(ParallelProjection, vtkTypeBool);
297  vtkBooleanMacro(ParallelProjection, vtkTypeBool);
299 
301 
312  vtkGetMacro(UseHorizontalViewAngle, vtkTypeBool);
313  vtkBooleanMacro(UseHorizontalViewAngle, vtkTypeBool);
315 
317 
328  void SetViewAngle(double angle);
329  vtkGetMacro(ViewAngle, double);
331 
333 
342  void SetParallelScale(double scale);
343  vtkGetMacro(ParallelScale, double);
345 
353  void Zoom(double factor);
354 
356 
369  void SetClippingRange(double dNear, double dFar);
370  void SetClippingRange(const double a[2]) { this->SetClippingRange(a[0], a[1]); }
371  vtkGetVector2Macro(ClippingRange, double);
373 
375 
382  void SetThickness(double);
383  vtkGetMacro(Thickness, double);
385 
387 
396  void SetWindowCenter(double x, double y);
397  vtkGetVector2Macro(WindowCenter, double);
399 
413  void SetObliqueAngles(double alpha, double beta);
414 
421 
423 
428  vtkGetVector3Macro(ViewPlaneNormal, double);
430 
432 
440  void SetViewShear(double dxdz, double dydz, double center);
441  void SetViewShear(double d[3]);
442  vtkGetVector3Macro(ViewShear, double);
444 
446 
450  vtkSetMacro(EyeAngle, double);
451  vtkGetMacro(EyeAngle, double);
453 
455 
461  vtkSetMacro(FocalDisk, double);
462  vtkGetMacro(FocalDisk, double);
464 
466 
474  vtkSetMacro(FocalDistance, double);
475  vtkGetMacro(FocalDistance, double);
477 
479 
488  vtkSetMacro(UseOffAxisProjection, vtkTypeBool);
489  vtkGetMacro(UseOffAxisProjection, vtkTypeBool);
490  vtkBooleanMacro(UseOffAxisProjection, vtkTypeBool);
492 
494 
500 
502 
507  vtkSetVector3Macro(ScreenBottomLeft, double);
508  vtkGetVector3Macro(ScreenBottomLeft, double);
510 
512 
517  vtkSetVector3Macro(ScreenBottomRight, double);
518  vtkGetVector3Macro(ScreenBottomRight, double);
520 
522 
527  vtkSetVector3Macro(ScreenTopRight, double);
528  vtkGetVector3Macro(ScreenTopRight, double);
530 
532 
537  vtkSetMacro(EyeSeparation, double);
538  vtkGetMacro(EyeSeparation, double);
540 
542 
548  void SetEyePosition(double eyePosition[3]);
549  void GetEyePosition(double eyePosition[3]);
551 
556  void GetEyePlaneNormal(double normal[3]);
557 
559 
566  vtkGetObjectMacro(EyeTransformMatrix, vtkMatrix4x4);
568 
575  void SetEyeTransformMatrix(const double elements[16]);
576 
578 
584  vtkGetObjectMacro(ModelTransformMatrix, vtkMatrix4x4);
586 
592  void SetModelTransformMatrix(const double elements[16]);
593 
598 
603 
612 
623 
631  vtkGetObjectMacro(ExplicitProjectionTransformMatrix, vtkMatrix4x4);
639  vtkSetMacro(UseExplicitProjectionTransformMatrix, bool);
640  vtkGetMacro(UseExplicitProjectionTransformMatrix, bool);
641  vtkBooleanMacro(UseExplicitProjectionTransformMatrix, bool);
649  vtkSetMacro(ExplicitAspectRatio, double);
650  vtkGetMacro(ExplicitAspectRatio, double);
659  vtkSetMacro(UseExplicitAspectRatio, bool);
660  vtkGetMacro(UseExplicitAspectRatio, bool);
661  vtkBooleanMacro(UseExplicitAspectRatio, bool);
674  virtual vtkMatrix4x4* GetProjectionTransformMatrix(double aspect, double nearz, double farz);
675 
687  double aspect, double nearz, double farz);
688 
701  double aspect, double nearz, double farz);
702 
711 
713 
719  vtkGetObjectMacro(UserViewTransform, vtkHomogeneousTransform);
721 
723 
729  vtkGetObjectMacro(UserTransform, vtkHomogeneousTransform);
731 
737  virtual void Render(vtkRenderer*) {}
738 
743 
749 
760  virtual void GetFrustumPlanes(double aspect, double planes[24]);
761 
763 
773  virtual void UpdateIdealShiftScale(double aspect);
774  vtkGetVector3Macro(FocalPointShift, double);
775  vtkGetMacro(FocalPointScale, double);
776  vtkGetVector3Macro(NearPlaneShift, double);
777  vtkGetMacro(NearPlaneScale, double);
778  vtkSetMacro(ShiftScaleThreshold, double);
779  vtkGetMacro(ShiftScaleThreshold, double);
781 
783 
787  double* GetOrientationWXYZ() VTK_SIZEHINT(4);
789 
794  void ComputeViewPlaneNormal();
795 
801  vtkMatrix4x4* GetCameraLightTransformMatrix();
802 
806  virtual void UpdateViewport(vtkRenderer* vtkNotUsed(ren)) {}
807 
809 
812  vtkGetMacro(Stereo, int);
814 
816 
819  vtkSetMacro(LeftEye, int);
820  vtkGetMacro(LeftEye, int);
822 
830 
838 
840 
845  vtkSetMacro(FreezeFocalPoint, bool);
846  vtkGetMacro(FreezeFocalPoint, bool);
848 
850 
853  vtkSetMacro(UseScissor, bool);
854  vtkGetMacro(UseScissor, bool);
856 
858 
861  void SetScissorRect(vtkRecti scissorRect);
862  void GetScissorRect(vtkRecti& scissorRect);
864 
866 
869  vtkGetObjectMacro(Information, vtkInformation);
872 
873 protected:
875  ~vtkCamera() override;
876 
878 
882  virtual void ComputeViewTransform();
884 
888  virtual void ComputeProjectionTransform(double aspect, double nearz, double farz);
889 
893  void ComputeCompositeProjectionTransform(double aspect, double nearz, double farz);
894 
896 
902 
907 
912 
920 
921  double WindowCenter[2];
922  double ObliqueAngles[2];
923  double FocalPoint[3];
924  double Position[3];
925  double ViewUp[3];
926  double ViewAngle;
927  double ClippingRange[2];
928  double EyeAngle;
931  int Stereo;
932  int LeftEye;
933  double Thickness;
934  double Distance;
935  double DirectionOfProjection[3];
936  double ViewPlaneNormal[3];
937  double ViewShear[3];
939 
941 
942  double ScreenBottomLeft[3];
943  double ScreenBottomRight[3];
944  double ScreenTopRight[3];
945  double ScreenCenter[3];
946 
949 
952 
954 
957 
960 
963 
968 
970 
971  double FocalDisk;
973 
974  double FocalPointShift[3];
976  double NearPlaneShift[3];
979 
980  vtkCameraCallbackCommand* UserViewTransformCallbackCommand;
981  friend class vtkCameraCallbackCommand;
982 
983  // ViewingRaysMtime keeps track of camera modifications which will
984  // change the calculation of viewing rays for the camera before it is
985  // transformed to the camera's location and orientation.
989 
991 
992  // Arbitrary extra information associated with this camera.
994 
995 private:
996  vtkCamera(const vtkCamera&) = delete;
997  void operator=(const vtkCamera&) = delete;
998 };
999 
1000 VTK_ABI_NAMESPACE_END
1001 #endif
supports function callbacks
a virtual camera for 3D rendering
Definition: vtkCamera.h:162
bool UseExplicitProjectionTransformMatrix
Definition: vtkCamera.h:959
void ComputeOffAxisProjectionFrustum()
Compute and use frustum using offaxis method.
vtkInformation * Information
Definition: vtkCamera.h:993
virtual void SetInformation(vtkInformation *)
Set/Get the information object associated with this camera.
vtkMatrix4x4 * EyeTransformMatrix
Definition: vtkCamera.h:950
void Roll(double angle)
Rotate the camera about the direction of projection.
vtkTypeBool ParallelProjection
Definition: vtkCamera.h:929
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:966
void ComputeCameraLightTransform()
void SetViewUp(const double a[3])
Set/Get the view up direction for the camera.
Definition: vtkCamera.h:200
vtkTransform * ViewTransform
Definition: vtkCamera.h:964
double FocalDistance
Definition: vtkCamera.h:972
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:975
bool FreezeFocalPoint
Definition: vtkCamera.h:987
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:180
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:928
void Azimuth(double angle)
Rotate the camera about the view up vector centered at the focal point.
vtkHomogeneousTransform * UserTransform
Definition: vtkCamera.h:955
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:940
vtkMatrix4x4 * ExplicitProjectionTransformMatrix
Definition: vtkCamera.h:958
void SetObliqueAngles(double alpha, double beta)
Get/Set the oblique viewing angles.
double NearPlaneScale
Definition: vtkCamera.h:977
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:932
double EyeSeparation
Definition: vtkCamera.h:948
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:951
double * GetOrientation()
Get the orientation of the camera.
vtkMatrix4x4 * ModelTransformMatrix
Definition: vtkCamera.h:953
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:971
double Distance
Definition: vtkCamera.h:934
bool UseExplicitAspectRatio
Definition: vtkCamera.h:962
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:737
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:190
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:933
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:990
virtual vtkMatrix4x4 * GetModelViewTransformMatrix()
Return the model view matrix of model view transform.
vtkTransform * CameraLightTransform
Definition: vtkCamera.h:967
bool UseScissor
Definition: vtkCamera.h:988
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:938
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:931
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:926
void SetViewShear(double d[3])
Set/get the shear transform of the viewing frustum.
double ParallelScale
Definition: vtkCamera.h:930
void ComputeScreenOrientationMatrix()
Given screen screen top, bottom left and top right calculate screen orientation.
vtkHomogeneousTransform * UserViewTransform
Definition: vtkCamera.h:956
vtkPerspectiveTransform * ProjectionTransform
Definition: vtkCamera.h:965
vtkCameraCallbackCommand * UserViewTransformCallbackCommand
Definition: vtkCamera.h:980
double ShiftScaleThreshold
Definition: vtkCamera.h:978
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:969
double OffAxisClippingAdjustment
Definition: vtkCamera.h:947
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:370
vtkTimeStamp ViewingRaysMTime
Definition: vtkCamera.h:986
double ExplicitAspectRatio
Definition: vtkCamera.h:961
superclass for homogeneous transformations
a simple class to control print indentation
Definition: vtkIndent.h:120
Store vtkAlgorithm input/output information.
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:152
abstract base class for most VTK objects
Definition: vtkObject.h:83
describes a 4x4 matrix transformation
abstract specification for renderers
Definition: vtkRenderer.h:183
record modification and/or execution time
Definition: vtkTimeStamp.h:56
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:171
@ value
Definition: vtkX3D.h:232
@ scale
Definition: vtkX3D.h:241
@ center
Definition: vtkX3D.h:242
@ alpha
Definition: vtkX3D.h:262
int vtkTypeBool
Definition: vtkABI.h:71
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:282
#define VTK_SIZEHINT(...)