VTK  9.1.0
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=========================================================================*/
38#ifndef vtkCamera_h
39#define vtkCamera_h
40
41#include "vtkObject.h"
42#include "vtkRect.h" // for ivar
43#include "vtkRenderingCoreModule.h" // For export macro
44
46class vtkInformation;
47class vtkMatrix4x4;
49class vtkRenderer;
50class vtkTransform;
52class vtkCameraCallbackCommand;
53
54class VTKRENDERINGCORE_EXPORT vtkCamera : public vtkObject
55{
56public:
57 vtkTypeMacro(vtkCamera, vtkObject);
58 void PrintSelf(ostream& os, vtkIndent indent) override;
59
65 static vtkCamera* New();
66
68
72 void SetPosition(double x, double y, double z);
73 void SetPosition(const double a[3]) { this->SetPosition(a[0], a[1], a[2]); }
74 vtkGetVector3Macro(Position, double);
76
78
82 void SetFocalPoint(double x, double y, double z);
83 void SetFocalPoint(const double a[3]) { this->SetFocalPoint(a[0], a[1], a[2]); }
84 vtkGetVector3Macro(FocalPoint, double);
86
88
92 void SetViewUp(double vx, double vy, double vz);
93 void SetViewUp(const double a[3]) { this->SetViewUp(a[0], a[1], a[2]); }
94 vtkGetVector3Macro(ViewUp, double);
96
103
108 void SetDistance(double);
109
111
115 vtkGetMacro(Distance, double);
117
119
124 vtkGetVector3Macro(DirectionOfProjection, double);
126
133 void Dolly(double value);
134
136
139 void SetRoll(double angle);
140 double GetRoll();
142
147 void Roll(double angle);
148
155 void Azimuth(double angle);
156
164 void Yaw(double angle);
165
172 void Elevation(double angle);
173
179 void Pitch(double angle);
180
182
189 vtkGetMacro(ParallelProjection, vtkTypeBool);
190 vtkBooleanMacro(ParallelProjection, vtkTypeBool);
192
194
205 vtkGetMacro(UseHorizontalViewAngle, vtkTypeBool);
206 vtkBooleanMacro(UseHorizontalViewAngle, vtkTypeBool);
208
210
221 void SetViewAngle(double angle);
222 vtkGetMacro(ViewAngle, double);
224
226
236 vtkGetMacro(ParallelScale, double);
238
246 void Zoom(double factor);
247
249
262 void SetClippingRange(double dNear, double dFar);
263 void SetClippingRange(const double a[2]) { this->SetClippingRange(a[0], a[1]); }
264 vtkGetVector2Macro(ClippingRange, double);
266
268
275 void SetThickness(double);
276 vtkGetMacro(Thickness, double);
278
280
289 void SetWindowCenter(double x, double y);
290 vtkGetVector2Macro(WindowCenter, double);
292
306 void SetObliqueAngles(double alpha, double beta);
307
314
316
321 vtkGetVector3Macro(ViewPlaneNormal, double);
323
325
333 void SetViewShear(double dxdz, double dydz, double center);
334 void SetViewShear(double d[3]);
335 vtkGetVector3Macro(ViewShear, double);
337
339
343 vtkSetMacro(EyeAngle, double);
344 vtkGetMacro(EyeAngle, double);
346
348
354 vtkSetMacro(FocalDisk, double);
355 vtkGetMacro(FocalDisk, double);
357
359
367 vtkSetMacro(FocalDistance, double);
368 vtkGetMacro(FocalDistance, double);
370
372
381 vtkSetMacro(UseOffAxisProjection, vtkTypeBool);
382 vtkGetMacro(UseOffAxisProjection, vtkTypeBool);
383 vtkBooleanMacro(UseOffAxisProjection, vtkTypeBool);
385
387
392 vtkSetVector3Macro(ScreenBottomLeft, double);
393 vtkGetVector3Macro(ScreenBottomLeft, double);
395
397
402 vtkSetVector3Macro(ScreenBottomRight, double);
403 vtkGetVector3Macro(ScreenBottomRight, double);
405
407
412 vtkSetVector3Macro(ScreenTopRight, double);
413 vtkGetVector3Macro(ScreenTopRight, double);
415
417
422 vtkSetMacro(EyeSeparation, double);
423 vtkGetMacro(EyeSeparation, double);
425
427
433 void SetEyePosition(double eyePosition[3]);
434 void GetEyePosition(double eyePosition[3]);
436
441 void GetEyePlaneNormal(double normal[3]);
442
444
451 vtkGetObjectMacro(EyeTransformMatrix, vtkMatrix4x4);
453
460 void SetEyeTransformMatrix(const double elements[16]);
461
463
469 vtkGetObjectMacro(ModelTransformMatrix, vtkMatrix4x4);
471
477 void SetModelTransformMatrix(const double elements[16]);
478
483
488
497
508
516 vtkGetObjectMacro(ExplicitProjectionTransformMatrix, vtkMatrix4x4);
524 vtkSetMacro(UseExplicitProjectionTransformMatrix, bool);
525 vtkGetMacro(UseExplicitProjectionTransformMatrix, bool);
526 vtkBooleanMacro(UseExplicitProjectionTransformMatrix, bool);
534 vtkSetMacro(ExplicitAspectRatio, double);
535 vtkGetMacro(ExplicitAspectRatio, double);
544 vtkSetMacro(UseExplicitAspectRatio, bool);
545 vtkGetMacro(UseExplicitAspectRatio, bool);
546 vtkBooleanMacro(UseExplicitAspectRatio, bool);
559 virtual vtkMatrix4x4* GetProjectionTransformMatrix(double aspect, double nearz, double farz);
560
572 double aspect, double nearz, double farz);
573
586 double aspect, double nearz, double farz);
587
596
598
604 vtkGetObjectMacro(UserViewTransform, vtkHomogeneousTransform);
606
608
614 vtkGetObjectMacro(UserTransform, vtkHomogeneousTransform);
616
622 virtual void Render(vtkRenderer*) {}
623
628
634
645 virtual void GetFrustumPlanes(double aspect, double planes[24]);
646
648
658 virtual void UpdateIdealShiftScale(double aspect);
659 vtkGetVector3Macro(FocalPointShift, double);
660 vtkGetMacro(FocalPointScale, double);
661 vtkGetVector3Macro(NearPlaneShift, double);
662 vtkGetMacro(NearPlaneScale, double);
663 vtkSetMacro(ShiftScaleThreshold, double);
664 vtkGetMacro(ShiftScaleThreshold, double);
666
668
672 double* GetOrientationWXYZ() VTK_SIZEHINT(4);
674
679 void ComputeViewPlaneNormal();
680
686 vtkMatrix4x4* GetCameraLightTransformMatrix();
687
691 virtual void UpdateViewport(vtkRenderer* vtkNotUsed(ren)) {}
692
694
697 vtkGetMacro(Stereo, int);
699
701
704 vtkSetMacro(LeftEye, int);
705 vtkGetMacro(LeftEye, int);
707
715
723
725
730 vtkSetMacro(FreezeFocalPoint, bool);
731 vtkGetMacro(FreezeFocalPoint, bool);
733
735
738 vtkSetMacro(UseScissor, bool);
739 vtkGetMacro(UseScissor, bool);
741
743
746 void SetScissorRect(vtkRecti scissorRect);
747 void GetScissorRect(vtkRecti& scissorRect);
749
751
754 vtkGetObjectMacro(Information, vtkInformation);
757
758protected:
760 ~vtkCamera() override;
761
763
767 virtual void ComputeViewTransform();
769
773 virtual void ComputeProjectionTransform(double aspect, double nearz, double farz);
774
778 void ComputeCompositeProjectionTransform(double aspect, double nearz, double farz);
779
781
787
792
797
805
806 double WindowCenter[2];
807 double ObliqueAngles[2];
808 double FocalPoint[3];
809 double Position[3];
810 double ViewUp[3];
811 double ViewAngle;
812 double ClippingRange[2];
813 double EyeAngle;
818 double Thickness;
819 double Distance;
820 double DirectionOfProjection[3];
821 double ViewPlaneNormal[3];
822 double ViewShear[3];
824
826
827 double ScreenBottomLeft[3];
828 double ScreenBottomRight[3];
829 double ScreenTopRight[3];
830
832
835
837
839
842
845
848
853
855
856 double FocalDisk;
858
859 double FocalPointShift[3];
861 double NearPlaneShift[3];
864
865 vtkCameraCallbackCommand* UserViewTransformCallbackCommand;
866 friend class vtkCameraCallbackCommand;
867
868 // ViewingRaysMtime keeps track of camera modifications which will
869 // change the calculation of viewing rays for the camera before it is
870 // transformed to the camera's location and orientation.
874
876
877 // Arbitrary extra information associated with this camera.
879
880private:
881 vtkCamera(const vtkCamera&) = delete;
882 void operator=(const vtkCamera&) = delete;
883};
884
885#endif
supports function callbacks
a virtual camera for 3D rendering
Definition: vtkCamera.h:55
bool UseExplicitProjectionTransformMatrix
Definition: vtkCamera.h:844
void ComputeOffAxisProjectionFrustum()
Compute and use frustum using offaxis method.
vtkInformation * Information
Definition: vtkCamera.h:878
virtual void SetInformation(vtkInformation *)
Set/Get the information object associated with this camera.
vtkMatrix4x4 * EyeTransformMatrix
Definition: vtkCamera.h:836
void Roll(double angle)
Rotate the camera about the direction of projection.
vtkTypeBool ParallelProjection
Definition: vtkCamera.h:814
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.
vtkPerspectiveTransform * Transform
Definition: vtkCamera.h:851
void ComputeCameraLightTransform()
void SetViewUp(const double a[3])
Set/Get the view up direction for the camera.
Definition: vtkCamera.h:93
vtkTransform * ViewTransform
Definition: vtkCamera.h:849
double FocalDistance
Definition: vtkCamera.h:857
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:860
bool FreezeFocalPoint
Definition: vtkCamera.h:872
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:73
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:813
void Azimuth(double angle)
Rotate the camera about the view up vector centered at the focal point.
vtkHomogeneousTransform * UserTransform
Definition: vtkCamera.h:840
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,...
vtkTypeBool UseOffAxisProjection
Definition: vtkCamera.h:825
vtkMatrix4x4 * ExplicitProjectionTransformMatrix
Definition: vtkCamera.h:843
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...
double NearPlaneScale
Definition: vtkCamera.h:862
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:817
double EyeSeparation
Definition: vtkCamera.h:831
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 * ModelTransformMatrix
Definition: vtkCamera.h:838
void ShallowCopy(vtkCamera *source)
Copy the properties of ‘source’ into ‘this’.
double FocalDisk
Definition: vtkCamera.h:856
double Distance
Definition: vtkCamera.h:819
bool UseExplicitAspectRatio
Definition: vtkCamera.h:847
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.
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:622
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:83
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 the eye transform matrix.
double Thickness
Definition: vtkCamera.h:818
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 ComputeCompositeProjectionTransform(double aspect, double nearz, double farz)
These methods should only be used within vtkCamera.cxx.
vtkRecti ScissorRect
Definition: vtkCamera.h:875
vtkMatrix4x4 * WorldToScreenMatrix
Definition: vtkCamera.h:833
vtkTransform * CameraLightTransform
Definition: vtkCamera.h:852
bool UseScissor
Definition: vtkCamera.h:873
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:823
void ComputeWorldToScreenMatrix()
Given screen screen top, bottom left and top right calculate screen rotation.
void OrthogonalizeViewUp()
Recompute the ViewUp vector to force it to be perpendicular to camera->focalpoint vector.
vtkTimeStamp WorldToScreenMatrixMTime
Definition: vtkCamera.h:834
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:816
~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.
virtual vtkTransform * GetViewTransformObject()
For backward compatibility.
double ViewAngle
Definition: vtkCamera.h:811
void SetViewShear(double d[3])
Set/get the shear transform of the viewing frustum.
double ParallelScale
Definition: vtkCamera.h:815
vtkHomogeneousTransform * UserViewTransform
Definition: vtkCamera.h:841
vtkPerspectiveTransform * ProjectionTransform
Definition: vtkCamera.h:850
vtkCameraCallbackCommand * UserViewTransformCallbackCommand
Definition: vtkCamera.h:865
double ShiftScaleThreshold
Definition: vtkCamera.h:863
virtual vtkTransform * GetModelViewTransformObject()
Return the model view transform.
virtual void ComputeProjectionTransform(double aspect, double nearz, double farz)
These methods should only be used within vtkCamera.cxx.
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...
void ComputeDistance()
These methods should only be used within vtkCamera.cxx.
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...
vtkTransform * ModelViewTransform
Definition: vtkCamera.h:854
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:263
vtkTimeStamp ViewingRaysMTime
Definition: vtkCamera.h:871
double ExplicitAspectRatio
Definition: vtkCamera.h:846
superclass for homogeneous transformations
a simple class to control print indentation
Definition: vtkIndent.h:43
Store vtkAlgorithm input/output information.
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:45
abstract base class for most VTK objects
Definition: vtkObject.h:63
describes a 4x4 matrix transformation
abstract specification for renderers
Definition: vtkRenderer.h:73
record modification and/or execution time
Definition: vtkTimeStamp.h:42
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:64
@ value
Definition: vtkX3D.h:226
@ scale
Definition: vtkX3D.h:235
@ center
Definition: vtkX3D.h:236
@ alpha
Definition: vtkX3D.h:256
int vtkTypeBool
Definition: vtkABI.h:69
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287
#define VTK_SIZEHINT(...)