VTK
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 =========================================================================*/
35 #ifndef vtkCamera_h
36 #define vtkCamera_h
37 
38 #include "vtkRenderingCoreModule.h" // For export macro
39 #include "vtkObject.h"
40 #include "vtkRect.h" // for ivar
41 
43 class vtkMatrix4x4;
45 class vtkRenderer;
46 class vtkTransform;
47 class vtkCallbackCommand;
48 class vtkCameraCallbackCommand;
49 
50 class VTKRENDERINGCORE_EXPORT vtkCamera : public vtkObject
51 {
52 public:
53  vtkTypeMacro(vtkCamera, vtkObject);
54  void PrintSelf(ostream& os, vtkIndent indent);
55 
61  static vtkCamera *New();
62 
64 
68  void SetPosition(double x, double y, double z);
69  void SetPosition(const double a[3]) {
70  this->SetPosition(a[0], a[1], a[2]); };
71  vtkGetVector3Macro(Position, double);
73 
75 
79  void SetFocalPoint(double x, double y, double z);
80  void SetFocalPoint(const double a[3]) {
81  this->SetFocalPoint(a[0], a[1], a[2]);};
82  vtkGetVector3Macro(FocalPoint, double);
84 
86 
90  void SetViewUp(double vx, double vy, double vz);
91  void SetViewUp(const double a[3]) {
92  this->SetViewUp(a[0], a[1], a[2]); }
93  vtkGetVector3Macro(ViewUp, double);
95 
102 
107  void SetDistance(double);
108 
110 
114  vtkGetMacro(Distance, double);
116 
118 
123  vtkGetVector3Macro(DirectionOfProjection, double);
125 
132  void Dolly(double value);
133 
135 
138  void SetRoll(double angle);
139  double GetRoll();
141 
146  void Roll(double angle);
147 
154  void Azimuth(double angle);
155 
163  void Yaw(double angle);
164 
171  void Elevation(double angle);
172 
178  void Pitch(double angle);
179 
181 
185  void SetParallelProjection(int flag);
186  vtkGetMacro(ParallelProjection, int);
187  vtkBooleanMacro(ParallelProjection, int);
189 
191 
200  vtkGetMacro(UseHorizontalViewAngle, int);
201  vtkBooleanMacro(UseHorizontalViewAngle, int);
203 
205 
214  void SetViewAngle(double angle);
215  vtkGetMacro(ViewAngle, double);
217 
219 
226  void SetParallelScale(double scale);
227  vtkGetMacro(ParallelScale ,double);
229 
235  void Zoom(double factor);
236 
238 
249  void SetClippingRange(double dNear, double dFar);
250  void SetClippingRange(const double a[2])
251  { this->SetClippingRange(a[0], a[1]); }
252  vtkGetVector2Macro(ClippingRange, double);
254 
256 
261  void SetThickness(double);
262  vtkGetMacro(Thickness, double);
264 
266 
273  void SetWindowCenter(double x, double y);
274  vtkGetVector2Macro(WindowCenter, double);
276 
288  void SetObliqueAngles(double alpha, double beta);
289 
296 
298 
303  vtkGetVector3Macro(ViewPlaneNormal, double);
305 
307 
313  void SetViewShear(double dxdz, double dydz, double center);
314  void SetViewShear(double d[3]);
315  vtkGetVector3Macro(ViewShear, double);
317 
319 
323  vtkSetMacro(EyeAngle, double);
324  vtkGetMacro(EyeAngle, double);
326 
328 
334  vtkSetMacro(FocalDisk, double);
335  vtkGetMacro(FocalDisk, double);
337 
339 
346  vtkSetMacro(UseOffAxisProjection, int);
347  vtkGetMacro(UseOffAxisProjection, int);
348  vtkBooleanMacro(UseOffAxisProjection, int);
350 
352 
357  vtkSetVector3Macro(ScreenBottomLeft, double);
358  vtkGetVector3Macro(ScreenBottomLeft, double);
360 
362 
367  vtkSetVector3Macro(ScreenBottomRight, double);
368  vtkGetVector3Macro(ScreenBottomRight, double);
370 
372 
377  vtkSetVector3Macro(ScreenTopRight, double);
378  vtkGetVector3Macro(ScreenTopRight, double);
380 
382 
387  vtkSetMacro(EyeSeparation, double);
388  vtkGetMacro(EyeSeparation, double);
390 
392 
398  void SetEyePosition(double eyePosition[3]);
399  void GetEyePosition(double eyePosition[3]);
401 
406  void GetEyePlaneNormal(double normal[3]);
407 
409 
416  vtkGetObjectMacro(EyeTransformMatrix, vtkMatrix4x4);
418 
425  void SetEyeTransformMatrix(const double elements[16]);
426 
428 
434  vtkGetObjectMacro(ModelTransformMatrix, vtkMatrix4x4);
436 
442  void SetModelTransformMatrix(const double elements[16]);
443 
448 
453 
462 
473 
483  double nearz,
484  double farz);
485 
495  double nearz,
496  double farz);
497 
508  double nearz,
509  double farz);
510 
518 
520 
526  vtkGetObjectMacro(UserViewTransform,vtkHomogeneousTransform);
528 
530 
536  vtkGetObjectMacro(UserTransform,vtkHomogeneousTransform);
538 
544  virtual void Render(vtkRenderer *) {}
545 
550 
556 
566  virtual void GetFrustumPlanes(double aspect, double planes[24]);
567 
569 
572  double *GetOrientation();
575 
581 
588 
592  virtual void UpdateViewport(vtkRenderer *vtkNotUsed(ren)) {}
593 
595 
598  vtkSetMacro(LeftEye, int);
599  vtkGetMacro(LeftEye, int);
601 
609 
617 
619 
624  vtkSetMacro(FreezeFocalPoint, bool);
625  vtkGetMacro(FreezeFocalPoint, bool);
627 
629 
632  vtkSetMacro(UseScissor, bool);
633  vtkGetMacro(UseScissor, bool);
635 
637 
640  void SetScissorRect(vtkRecti scissorRect);
641  void GetScissorRect(vtkRecti& scissorRect);
643 
644 protected:
647 
649 
653  virtual void ComputeViewTransform();
655 
659  virtual void ComputeProjectionTransform(double aspect,
660  double nearz,
661  double farz);
662 
667  double nearz,
668  double farz);
669 
671 
672 
678 
683 
688 
696 
697  double WindowCenter[2];
698  double ObliqueAngles[2];
699  double FocalPoint[3];
700  double Position[3];
701  double ViewUp[3];
702  double ViewAngle;
703  double ClippingRange[2];
704  double EyeAngle;
707  int Stereo;
708  int LeftEye;
709  double Thickness;
710  double Distance;
711  double DirectionOfProjection[3];
712  double ViewPlaneNormal[3];
713  double ViewShear[3];
715 
717 
718  double ScreenBottomLeft[3];
719  double ScreenBottomRight[3];
720  double ScreenTopRight[3];
721 
723 
726 
728 
730 
733 
738 
740 
741  double FocalDisk;
742 
743  vtkCameraCallbackCommand *UserViewTransformCallbackCommand;
744  friend class vtkCameraCallbackCommand;
745 
746  // ViewingRaysMtime keeps track of camera modifications which will
747  // change the calculation of viewing rays for the camera before it is
748  // transformed to the camera's location and orientation.
752 
754 
755 
756 private:
757  vtkCamera(const vtkCamera&) VTK_DELETE_FUNCTION;
758  void operator=(const vtkCamera&) VTK_DELETE_FUNCTION;
759 };
760 
761 #endif
vtkCamera::ViewTransform
vtkTransform * ViewTransform
Definition: vtkCamera.h:734
vtkCamera::UseScissor
bool UseScissor
Definition: vtkCamera.h:751
vtkCamera::DeepCopy
void DeepCopy(vtkCamera *source)
Copy the properties of ‘source’ into ‘this’.
vtkCamera::CameraLightTransform
vtkTransform * CameraLightTransform
Definition: vtkCamera.h:737
vtkHomogeneousTransform
superclass for homogeneous transformations
Definition: vtkHomogeneousTransform.h:35
vtkCamera::GetViewTransformMatrix
virtual vtkMatrix4x4 * GetViewTransformMatrix()
For backward compatibility.
vtkX3D::alpha
@ alpha
Definition: vtkX3D.h:250
vtkX3D::scale
@ scale
Definition: vtkX3D.h:229
vtkCamera::GetViewingRaysMTime
vtkMTimeType GetViewingRaysMTime()
Return the MTime that concerns recomputing the view rays of the camera.
vtkX3D::value
@ value
Definition: vtkX3D.h:220
vtkCamera::PartialCopy
void PartialCopy(vtkCamera *source)
Copy the ivars.
vtkCamera::GetModelViewTransformMatrix
virtual vtkMatrix4x4 * GetModelViewTransformMatrix()
Return the model view matrix of model view transform.
vtkCamera::GetEyePosition
void GetEyePosition(double eyePosition[3])
vtkCamera::OrthogonalizeViewUp
void OrthogonalizeViewUp()
Recompute the ViewUp vector to force it to be perpendicular to camera->focalpoint vector.
vtkCamera::ComputeViewPlaneNormal
void ComputeViewPlaneNormal()
This method is called automatically whenever necessary, it should never be used outside of vtkCamera....
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:36
vtkCamera::SetDistance
void SetDistance(double)
Move the focal point so that it is the specified distance from the camera position.
vtkCamera::New
static vtkCamera * New()
Construct camera instance with its focal point at the origin, and position=(0,0,1).
vtkCamera::ViewingRaysMTime
vtkTimeStamp ViewingRaysMTime
Definition: vtkCamera.h:749
vtkCamera::GetProjectionTransformMatrix
virtual vtkMatrix4x4 * GetProjectionTransformMatrix(double aspect, double nearz, double farz)
Return the projection transform matrix, which converts from camera coordinates to viewport coordinate...
vtkCamera::SetViewUp
void SetViewUp(const double a[3])
Definition: vtkCamera.h:91
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:60
vtkCamera::LeftEye
int LeftEye
Definition: vtkCamera.h:708
vtkCamera::SetParallelProjection
void SetParallelProjection(int flag)
Set/Get the value of the ParallelProjection instance variable.
vtkX3D::center
@ center
Definition: vtkX3D.h:230
vtkCamera::SetUseHorizontalViewAngle
void SetUseHorizontalViewAngle(int flag)
Set/Get the value of the UseHorizontalViewAngle instance variable.
vtkCamera::SetClippingRange
void SetClippingRange(const double a[2])
Definition: vtkCamera.h:250
vtkCamera::UseHorizontalViewAngle
int UseHorizontalViewAngle
Definition: vtkCamera.h:714
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:61
vtkCamera::SetObliqueAngles
void SetObliqueAngles(double alpha, double beta)
Get/Set the oblique viewing angles.
vtkCamera::Stereo
int Stereo
Definition: vtkCamera.h:707
vtkCamera::Transform
vtkPerspectiveTransform * Transform
Definition: vtkCamera.h:736
vtkCamera::GetCameraLightTransformMatrix
vtkMatrix4x4 * GetCameraLightTransformMatrix()
Returns a transformation matrix for a coordinate frame attached to the camera, where the camera is lo...
vtkCamera::SetFocalPoint
void SetFocalPoint(double x, double y, double z)
Set/Get the focal of the camera in world coordinates.
vtkCamera::EyeAngle
double EyeAngle
Definition: vtkCamera.h:704
vtkMTimeType
vtkTypeUInt64 vtkMTimeType
Definition: vtkType.h:248
source
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
Definition: vtkBoostGraphAdapter.h:822
vtkCamera::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkCamera::GetViewTransformObject
virtual vtkTransform * GetViewTransformObject()
For backward compatibility.
vtkCamera::ViewingRaysModified
void ViewingRaysModified()
Mark that something has changed which requires the view rays to be recomputed.
vtkCamera::~vtkCamera
~vtkCamera()
vtkCamera::GetRoll
double GetRoll()
vtkCamera::ComputeCameraLightTransform
void ComputeCameraLightTransform()
vtkCamera::ComputeWorldToScreenMatrix
void ComputeWorldToScreenMatrix()
Given screen screen top, bottom left and top right calculate screen rotation.
vtkCamera::SetEyePosition
void SetEyePosition(double eyePosition[3])
Set/Get the eye position (center point between two eyes).
vtkCamera::GetProjectionTransformObject
virtual vtkPerspectiveTransform * GetProjectionTransformObject(double aspect, double nearz, double farz)
Return the projection transform matrix, which converts from camera coordinates to viewport coordinate...
vtkCamera::SetScissorRect
void SetScissorRect(vtkRecti scissorRect)
Set/Get the vtkRect value of the scissor.
vtkCamera::ScissorRect
vtkRecti ScissorRect
Definition: vtkCamera.h:753
vtkCamera::UseOffAxisProjection
int UseOffAxisProjection
Definition: vtkCamera.h:716
vtkCamera::ComputeModelViewMatrix
void ComputeModelViewMatrix()
Compute model view matrix for the camera.
vtkRect.h
vtkCamera::SetParallelScale
void SetParallelScale(double scale)
Set/Get the scaling used for a parallel projection, i.e.
vtkCamera::GetModelViewTransformObject
virtual vtkTransform * GetModelViewTransformObject()
Return the model view transform.
vtkCamera::GetOrientationWXYZ
double * GetOrientationWXYZ()
vtkCamera::GetScissorRect
void GetScissorRect(vtkRecti &scissorRect)
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:42
vtkCamera::ModelTransformMatrix
vtkMatrix4x4 * ModelTransformMatrix
Definition: vtkCamera.h:729
vtkCamera::SetViewAngle
void SetViewAngle(double angle)
Set/Get the camera view angle, which is the angular height of the camera view measured in degrees.
vtkCamera::GetProjectionTransformMatrix
virtual vtkMatrix4x4 * GetProjectionTransformMatrix(vtkRenderer *ren)
Return the projection transform matrix, which converts from camera coordinates to viewport coordinate...
vtkCamera
a virtual camera for 3D rendering
Definition: vtkCamera.h:51
vtkCamera::SetPosition
void SetPosition(const double a[3])
Definition: vtkCamera.h:69
vtkCamera::GetFrustumPlanes
virtual void GetFrustumPlanes(double aspect, double planes[24])
Get the plane equations that bound the view frustum.
vtkCamera::WorldToScreenMatrixMTime
vtkTimeStamp WorldToScreenMatrixMTime
Definition: vtkCamera.h:725
vtkCamera::SetPosition
void SetPosition(double x, double y, double z)
Set/Get the position of the camera in world coordinates.
vtkCamera::ComputeCompositeProjectionTransform
void ComputeCompositeProjectionTransform(double aspect, double nearz, double farz)
These methods should only be used within vtkCamera.cxx.
vtkCamera::SetEyeTransformMatrix
void SetEyeTransformMatrix(vtkMatrix4x4 *matrix)
Set/Get eye transformation matrix.
vtkCamera::ComputeProjectionTransform
virtual void ComputeProjectionTransform(double aspect, double nearz, double farz)
These methods should only be used within vtkCamera.cxx.
vtkCamera::ShallowCopy
void ShallowCopy(vtkCamera *source)
Copy the properties of ‘source’ into ‘this’.
vtkCamera::ParallelProjection
int ParallelProjection
Definition: vtkCamera.h:705
vtkCamera::UpdateViewport
virtual void UpdateViewport(vtkRenderer *vtkNotUsed(ren))
Update the viewport.
Definition: vtkCamera.h:592
vtkCamera::SetUserViewTransform
void SetUserViewTransform(vtkHomogeneousTransform *transform)
In addition to the instance variables such as position and orientation, you can add an additional tra...
vtkCamera::SetViewShear
void SetViewShear(double dxdz, double dydz, double center)
Set/get the shear transform of the viewing frustum.
vtkCamera::Thickness
double Thickness
Definition: vtkCamera.h:709
vtkPerspectiveTransform
describes a 4x4 matrix transformation
Definition: vtkPerspectiveTransform.h:57
vtkObject.h
vtkCamera::SetEyeTransformMatrix
void SetEyeTransformMatrix(const double elements[16])
Set the eye transform matrix.
vtkCamera::vtkCamera
vtkCamera()
vtkBooleanMacro
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkSetMacro
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkCamera::FreezeFocalPoint
bool FreezeFocalPoint
Definition: vtkCamera.h:750
vtkCamera::GetCompositeProjectionTransformMatrix
virtual vtkMatrix4x4 * GetCompositeProjectionTransformMatrix(double aspect, double nearz, double farz)
Return the concatenation of the ViewTransform and the ProjectionTransform.
vtkCamera::SetThickness
void SetThickness(double)
Set the distance between clipping planes.
vtkCamera::UserTransform
vtkHomogeneousTransform * UserTransform
Definition: vtkCamera.h:731
vtkCamera::FocalDisk
double FocalDisk
Definition: vtkCamera.h:741
vtkCamera::EyeSeparation
double EyeSeparation
Definition: vtkCamera.h:722
vtkCamera::Render
virtual void Render(vtkRenderer *)
This method causes the camera to set up whatever is required for viewing the scene.
Definition: vtkCamera.h:544
vtkCamera::ComputeOffAxisProjectionFrustum
void ComputeOffAxisProjectionFrustum()
Compute and use frustum using offaxis method.
vtkCamera::SetModelTransformMatrix
void SetModelTransformMatrix(const double elements[16])
Set model transformation matrix.
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:64
vtkCamera::Zoom
void Zoom(double factor)
In perspective mode, decrease the view angle by the specified factor.
vtkCamera::ProjectionTransform
vtkPerspectiveTransform * ProjectionTransform
Definition: vtkCamera.h:735
vtkCamera::SetRoll
void SetRoll(double angle)
Set the roll angle of the camera about the direction of projection.
vtkCamera::ParallelScale
double ParallelScale
Definition: vtkCamera.h:706
vtkCallbackCommand
supports function callbacks
Definition: vtkCallbackCommand.h:51
vtkCamera::SetViewShear
void SetViewShear(double d[3])
vtkCamera::SetUserTransform
void SetUserTransform(vtkHomogeneousTransform *transform)
In addition to the instance variables such as position and orientation, you can add an additional tra...
vtkCamera::SetWindowCenter
void SetWindowCenter(double x, double y)
Set/Get the center of the window in viewport coordinates.
vtkCamera::SetClippingRange
void SetClippingRange(double dNear, double dFar)
Set/Get the location of the near and far clipping planes along the direction of projection.
vtkCamera::UserViewTransformCallbackCommand
vtkCameraCallbackCommand * UserViewTransformCallbackCommand
Definition: vtkCamera.h:743
vtkCamera::Roll
void Roll(double angle)
Rotate the camera about the direction of projection.
vtkCamera::SetFocalPoint
void SetFocalPoint(const double a[3])
Definition: vtkCamera.h:80
vtkCamera::GetOrientation
double * GetOrientation()
Get the orientation of the camera.
vtkRecti
Definition: vtkRect.h:288
vtkCamera::ComputeDistance
void ComputeDistance()
These methods should only be used within vtkCamera.cxx.
vtkCamera::Pitch
void Pitch(double angle)
Rotate the focal point about the cross product of the view up vector and the direction of projection,...
vtkCamera::Yaw
void Yaw(double angle)
Rotate the focal point about the view up vector, using the camera's position as the center of rotatio...
vtkCamera::Elevation
void Elevation(double angle)
Rotate the camera about the cross product of the negative of the direction of projection and the view...
vtkCamera::Dolly
void Dolly(double value)
Divide the camera's distance from the focal point by the given dolly value.
vtkCamera::SetViewUp
void SetViewUp(double vx, double vy, double vz)
Set/Get the view up direction for the camera.
vtkCamera::Azimuth
void Azimuth(double angle)
Rotate the camera about the view up vector centered at the focal point.
vtkCamera::Distance
double Distance
Definition: vtkCamera.h:710
vtkCamera::UserViewTransform
vtkHomogeneousTransform * UserViewTransform
Definition: vtkCamera.h:732
vtkCamera::ApplyTransform
void ApplyTransform(vtkTransform *t)
Apply a transform to the camera.
vtkCamera::SetModelTransformMatrix
void SetModelTransformMatrix(vtkMatrix4x4 *matrix)
Set/Get model transformation matrix.
vtkCamera::ModelViewTransform
vtkTransform * ModelViewTransform
Definition: vtkCamera.h:739
vtkCamera::EyeTransformMatrix
vtkMatrix4x4 * EyeTransformMatrix
Definition: vtkCamera.h:727
vtkCamera::GetEyePlaneNormal
void GetEyePlaneNormal(double normal[3])
Get normal vector from eye to screen rotated by EyeTransformMatrix.
vtkCamera::ViewAngle
double ViewAngle
Definition: vtkCamera.h:702
vtkCamera::ComputeViewTransform
virtual void ComputeViewTransform()
vtkCamera::WorldToScreenMatrix
vtkMatrix4x4 * WorldToScreenMatrix
Definition: vtkCamera.h:724