VTK  9.3.20240722
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#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
139
140VTK_ABI_NAMESPACE_BEGIN
142class vtkInformation;
143class vtkMatrix4x4;
145class vtkRenderer;
146class vtkTransform;
148class vtkCameraCallbackCommand;
149
150class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkCamera : public vtkObject
151{
152public:
153 vtkTypeMacro(vtkCamera, vtkObject);
154 void PrintSelf(ostream& os, vtkIndent indent) override;
155
161 static vtkCamera* New();
162
164
168 void SetPosition(double x, double y, double z);
169 void SetPosition(const double a[3]) { this->SetPosition(a[0], a[1], a[2]); }
170 vtkGetVector3Macro(Position, double);
172
174
178 void SetFocalPoint(double x, double y, double z);
179 void SetFocalPoint(const double a[3]) { this->SetFocalPoint(a[0], a[1], a[2]); }
180 vtkGetVector3Macro(FocalPoint, double);
182
184
188 void SetViewUp(double vx, double vy, double vz);
189 void SetViewUp(const double a[3]) { this->SetViewUp(a[0], a[1], a[2]); }
190 vtkGetVector3Macro(ViewUp, double);
192
199
204 void SetDistance(double);
205
207
211 vtkGetMacro(Distance, double);
213
215
220 vtkGetVector3Macro(DirectionOfProjection, double);
222
229 void Dolly(double value);
230
232
235 void SetRoll(double angle);
236 double GetRoll();
238
243 void Roll(double angle);
244
251 void Azimuth(double angle);
252
260 void Yaw(double angle);
261
268 void Elevation(double angle);
269
275 void Pitch(double angle);
276
278
285 vtkGetMacro(ParallelProjection, vtkTypeBool);
286 vtkBooleanMacro(ParallelProjection, vtkTypeBool);
288
290
301 vtkGetMacro(UseHorizontalViewAngle, vtkTypeBool);
302 vtkBooleanMacro(UseHorizontalViewAngle, vtkTypeBool);
304
306
317 void SetViewAngle(double angle);
318 vtkGetMacro(ViewAngle, double);
320
322
331 void SetParallelScale(double scale);
332 vtkGetMacro(ParallelScale, double);
334
342 void Zoom(double factor);
343
345
358 void SetClippingRange(double dNear, double dFar);
359 void SetClippingRange(const double a[2]) { this->SetClippingRange(a[0], a[1]); }
360 vtkGetVector2Macro(ClippingRange, double);
362
364
371 void SetThickness(double);
372 vtkGetMacro(Thickness, double);
374
376
385 void SetWindowCenter(double x, double y);
386 vtkGetVector2Macro(WindowCenter, double);
388
402 void SetObliqueAngles(double alpha, double beta);
403
410
412
417 vtkGetVector3Macro(ViewPlaneNormal, double);
419
421
429 void SetViewShear(double dxdz, double dydz, double center);
430 void SetViewShear(double d[3]);
431 vtkGetVector3Macro(ViewShear, double);
433
435
439 vtkSetMacro(EyeAngle, double);
440 vtkGetMacro(EyeAngle, double);
442
444
450 vtkSetMacro(FocalDisk, double);
451 vtkGetMacro(FocalDisk, double);
453
455
463 vtkSetMacro(FocalDistance, double);
464 vtkGetMacro(FocalDistance, double);
466
468
477 vtkSetMacro(UseOffAxisProjection, vtkTypeBool);
478 vtkGetMacro(UseOffAxisProjection, vtkTypeBool);
479 vtkBooleanMacro(UseOffAxisProjection, vtkTypeBool);
481
483
489
491
496 vtkSetVector3Macro(ScreenBottomLeft, double);
497 vtkGetVector3Macro(ScreenBottomLeft, double);
499
501
506 vtkSetVector3Macro(ScreenBottomRight, double);
507 vtkGetVector3Macro(ScreenBottomRight, double);
509
511
516 vtkSetVector3Macro(ScreenTopRight, double);
517 vtkGetVector3Macro(ScreenTopRight, double);
519
521
526 vtkSetMacro(EyeSeparation, double);
527 vtkGetMacro(EyeSeparation, double);
529
531
537 void SetEyePosition(double eyePosition[3]);
538 void GetEyePosition(double eyePosition[3]);
540
542
550 void GetStereoEyePosition(double eyePosition[3]);
552
557 void GetEyePlaneNormal(double normal[3]);
558
560
567 void SetEyeTransformMatrix(const double elements[16]);
568 vtkGetObjectMacro(EyeTransformMatrix, vtkMatrix4x4);
570
572
578 void SetModelTransformMatrix(const double elements[16]);
579 vtkGetObjectMacro(ModelTransformMatrix, vtkMatrix4x4);
581
586
591
600
611
619 vtkGetObjectMacro(ExplicitProjectionTransformMatrix, vtkMatrix4x4);
627 vtkSetMacro(UseExplicitProjectionTransformMatrix, bool);
628 vtkGetMacro(UseExplicitProjectionTransformMatrix, bool);
629 vtkBooleanMacro(UseExplicitProjectionTransformMatrix, bool);
637 vtkSetMacro(ExplicitAspectRatio, double);
638 vtkGetMacro(ExplicitAspectRatio, double);
647 vtkSetMacro(UseExplicitAspectRatio, bool);
648 vtkGetMacro(UseExplicitAspectRatio, bool);
649 vtkBooleanMacro(UseExplicitAspectRatio, bool);
662 virtual vtkMatrix4x4* GetProjectionTransformMatrix(double aspect, double nearz, double farz);
663
675 double aspect, double nearz, double farz);
676
689 double aspect, double nearz, double farz);
690
699
701
707 vtkGetObjectMacro(UserViewTransform, vtkHomogeneousTransform);
709
711
717 vtkGetObjectMacro(UserTransform, vtkHomogeneousTransform);
719
725 virtual void Render(vtkRenderer*) {}
726
731
737
748 virtual void GetFrustumPlanes(double aspect, double planes[24]);
749
751
761 virtual void UpdateIdealShiftScale(double aspect);
762 vtkGetVector3Macro(FocalPointShift, double);
763 vtkGetMacro(FocalPointScale, double);
764 vtkGetVector3Macro(NearPlaneShift, double);
765 vtkGetMacro(NearPlaneScale, double);
766 vtkSetMacro(ShiftScaleThreshold, double);
767 vtkGetMacro(ShiftScaleThreshold, double);
769
771
775 double* GetOrientationWXYZ() VTK_SIZEHINT(4);
777
782 void ComputeViewPlaneNormal();
783
789 vtkMatrix4x4* GetCameraLightTransformMatrix();
790
794 virtual void UpdateViewport(vtkRenderer* vtkNotUsed(ren)) {}
795
797
800 vtkGetMacro(Stereo, int);
802
804
807 vtkSetMacro(LeftEye, int);
808 vtkGetMacro(LeftEye, int);
810
818
826
828
833 vtkSetMacro(FreezeFocalPoint, bool);
834 vtkGetMacro(FreezeFocalPoint, bool);
836
838
841 vtkSetMacro(UseScissor, bool);
842 vtkGetMacro(UseScissor, bool);
844
846
849 void SetScissorRect(vtkRecti scissorRect);
850 void GetScissorRect(vtkRecti& scissorRect);
852
854
858 vtkGetObjectMacro(Information, vtkInformation);
860 virtual void SetInformation(vtkInformation*);
862
863protected:
865 ~vtkCamera() override;
866
868
871 void ComputeDistance();
872 virtual void ComputeViewTransform();
874
878 virtual void ComputeProjectionTransform(double aspect, double nearz, double farz);
879
883 void ComputeCompositeProjectionTransform(double aspect, double nearz, double farz);
884
885 void ComputeCameraLightTransform();
886
891 void ComputeScreenOrientationMatrix();
892
896 void ComputeOffAxisProjectionFrustum();
897
901 void ComputeModelViewMatrix();
902
909 void PartialCopy(vtkCamera* source);
910
911 double WindowCenter[2];
912 double ObliqueAngles[2];
913 double FocalPoint[3];
914 double Position[3];
915 double ViewUp[3];
916 double ViewAngle;
917 double ClippingRange[2];
918 double EyeAngle;
919 vtkTypeBool ParallelProjection;
920 double ParallelScale;
921 int Stereo;
922 int LeftEye;
923 double Thickness;
924 double Distance;
925 double DirectionOfProjection[3];
926 double ViewPlaneNormal[3];
927 double ViewShear[3];
928 vtkTypeBool UseHorizontalViewAngle;
929
930 vtkTypeBool UseOffAxisProjection;
931
932 double ScreenBottomLeft[3];
933 double ScreenBottomRight[3];
934 double ScreenTopRight[3];
935 double ScreenCenter[3];
936
937 double OffAxisClippingAdjustment;
938 double EyeSeparation;
939
940 vtkMatrix4x4* EyeTransformMatrix;
941 vtkMatrix4x4* ProjectionPlaneOrientationMatrix;
942
943 vtkMatrix4x4* ModelTransformMatrix;
944
946 vtkHomogeneousTransform* UserViewTransform;
947
948 vtkMatrix4x4* ExplicitProjectionTransformMatrix;
949 bool UseExplicitProjectionTransformMatrix;
950
951 double ExplicitAspectRatio;
952 bool UseExplicitAspectRatio;
953
954 vtkTransform* ViewTransform;
955 vtkPerspectiveTransform* ProjectionTransform;
957 vtkTransform* CameraLightTransform;
958
959 vtkTransform* ModelViewTransform;
960
961 double FocalDisk;
962 double FocalDistance;
963
964 double FocalPointShift[3];
965 double FocalPointScale;
966 double NearPlaneShift[3];
967 double NearPlaneScale;
968 double ShiftScaleThreshold;
969
970 vtkCameraCallbackCommand* UserViewTransformCallbackCommand;
971 friend class vtkCameraCallbackCommand;
972
973 // ViewingRaysMtime keeps track of camera modifications which will
974 // change the calculation of viewing rays for the camera before it is
975 // transformed to the camera's location and orientation.
976 vtkTimeStamp ViewingRaysMTime;
977 bool FreezeFocalPoint;
978 bool UseScissor;
979
980 vtkRecti ScissorRect;
981
982 // Arbitrary extra information associated with this camera.
983 vtkInformation* Information;
984
985private:
986 vtkCamera(const vtkCamera&) = delete;
987 void operator=(const vtkCamera&) = delete;
988};
989
990VTK_ABI_NAMESPACE_END
991#endif
supports function callbacks
a virtual camera for 3D rendering
Definition vtkCamera.h:151
void Roll(double angle)
Rotate the camera about the direction of projection.
virtual vtkMatrix4x4 * GetViewTransformMatrix()
For backward compatibility.
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.
double * GetOrientation()
Get the orientation of the camera.
void SetViewUp(const double a[3])
Set/Get the view up direction for the camera.
Definition vtkCamera.h:189
void SetUserTransform(vtkHomogeneousTransform *transform)
In addition to the instance variables such as position and orientation, you can add an additional tra...
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:169
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 Elevation(double angle)
Rotate the camera about the cross product of the negative of the direction of projection and the view...
void Azimuth(double angle)
Rotate the camera about the view up vector centered at the focal point.
void DeepCopy(vtkCamera *source)
Copy the properties of ‘source’ into ‘this’.
void Pitch(double angle)
Rotate the focal point about the cross product of the view up vector and the direction of projection,...
void SetObliqueAngles(double alpha, double beta)
Get/Set the oblique viewing angles.
virtual vtkMatrix4x4 * GetProjectionTransformMatrix(vtkRenderer *ren)
Return the projection transform matrix, which converts from camera coordinates to viewport coordinate...
void SetParallelProjection(vtkTypeBool flag)
Set/Get the value of the ParallelProjection instance variable.
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.
void ShallowCopy(vtkCamera *source)
Copy the properties of ‘source’ into ‘this’.
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.
virtual vtkMatrix4x4 * GetModelViewTransformMatrix()
Return the model view matrix of model view transform.
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:725
void ViewingRaysModified()
Mark that something has changed which requires the view rays to be recomputed.
static vtkCamera * New()
Construct camera instance with its focal point at the origin, and position=(0,0,1).
void SetFocalPoint(const double a[3])
Set/Get the focal of the camera in world coordinates.
Definition vtkCamera.h:179
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 vtkPerspectiveTransform * GetProjectionTransformObject(double aspect, double nearz, double farz)
Return the projection transform matrix, which converts from camera coordinates to viewport coordinate...
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.
void SetScissorRect(vtkRecti scissorRect)
Set/Get the vtkRect value of the scissor.
virtual vtkMatrix4x4 * GetCompositeProjectionTransformMatrix(double aspect, double nearz, double farz)
Return the concatenation of the ViewTransform and the ProjectionTransform.
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.
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.
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.
virtual vtkTransform * GetViewTransformObject()
For backward compatibility.
void SetViewShear(double d[3])
Set/get the shear transform of the viewing frustum.
virtual vtkTransform * GetModelViewTransformObject()
Return the model view transform.
virtual vtkMatrix4x4 * GetProjectionTransformMatrix(double aspect, double nearz, double farz)
Return the projection transform matrix, which converts from camera coordinates to viewport coordinate...
void SetUserViewTransform(vtkHomogeneousTransform *transform)
In addition to the instance variables such as position and orientation, you can add an additional tra...
double GetOffAxisClippingAdjustment()
Get adjustment to clipping thickness, computed by camera based on the physical size of the screen and...
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...
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:359
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
abstract base class for most VTK objects
Definition vtkObject.h:162
describes a 4x4 matrix transformation
abstract specification for renderers
record modification and/or execution time
describes linear transformations via a 4x4 matrix
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(...)
#define VTK_MARSHAL_EXCLUDE_REASON_NOT_SUPPORTED
#define VTK_MARSHALAUTO
#define VTK_MARSHALEXCLUDE(reason)