VTK
dox/Rendering/Core/vtkCamera.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkCamera.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00034 #ifndef __vtkCamera_h
00035 #define __vtkCamera_h
00036 
00037 #include "vtkRenderingCoreModule.h" // For export macro
00038 #include "vtkObject.h"
00039 
00040 class vtkHomogeneousTransform;
00041 class vtkMatrix4x4;
00042 class vtkPerspectiveTransform;
00043 class vtkRenderer;
00044 class vtkTransform;
00045 class vtkCallbackCommand;
00046 class vtkCameraCallbackCommand;
00047 
00048 class VTKRENDERINGCORE_EXPORT vtkCamera : public vtkObject
00049 {
00050 public:
00051   vtkTypeMacro(vtkCamera, vtkObject);
00052   void PrintSelf(ostream& os, vtkIndent indent);
00053 
00057   static vtkCamera *New();
00058 
00060 
00062   void SetPosition(double x, double y, double z);
00063   void SetPosition(const double a[3]) {
00064     this->SetPosition(a[0], a[1], a[2]); };
00065   vtkGetVector3Macro(Position, double);
00067 
00069 
00071   void SetFocalPoint(double x, double y, double z);
00072   void SetFocalPoint(const double a[3]) {
00073     this->SetFocalPoint(a[0], a[1], a[2]);};
00074   vtkGetVector3Macro(FocalPoint, double);
00076 
00078 
00080   void SetViewUp(double vx, double vy, double vz);
00081   void SetViewUp(const double a[3]) {
00082     this->SetViewUp(a[0], a[1], a[2]); }
00083   vtkGetVector3Macro(ViewUp, double);
00085 
00089   void OrthogonalizeViewUp();
00090 
00093   void SetDistance(double);
00094 
00096 
00098   vtkGetMacro(Distance, double);
00100 
00102 
00105   vtkGetVector3Macro(DirectionOfProjection, double);
00107 
00112   void Dolly(double value);
00113 
00115 
00116   void SetRoll(double angle);
00117   double GetRoll();
00119 
00122   void Roll(double angle);
00123 
00128   void Azimuth(double angle);
00129 
00135   void Yaw(double angle);
00136 
00141   void Elevation(double angle);
00142 
00146   void Pitch(double angle);
00147 
00149 
00152   void SetParallelProjection(int flag);
00153   vtkGetMacro(ParallelProjection, int);
00154   vtkBooleanMacro(ParallelProjection, int);
00156 
00158 
00164   void SetUseHorizontalViewAngle(int flag);
00165   vtkGetMacro(UseHorizontalViewAngle, int);
00166   vtkBooleanMacro(UseHorizontalViewAngle, int);
00168 
00170 
00177   void SetViewAngle(double angle);
00178   vtkGetMacro(ViewAngle, double);
00180 
00182 
00187   void SetParallelScale(double scale);
00188   vtkGetMacro(ParallelScale ,double);
00190 
00195   void Zoom(double factor);
00196 
00198 
00207   void SetClippingRange(double dNear, double dFar);
00208   void SetClippingRange(const double a[2])
00209     { this->SetClippingRange(a[0], a[1]); }
00210   vtkGetVector2Macro(ClippingRange, double);
00212 
00214 
00217   void SetThickness(double);
00218   vtkGetMacro(Thickness, double);
00220 
00222 
00227   void SetWindowCenter(double x, double y);
00228   vtkGetVector2Macro(WindowCenter, double);
00230 
00239   void SetObliqueAngles(double alpha, double beta);
00240 
00244   void ApplyTransform(vtkTransform *t);
00245 
00247 
00250   vtkGetVector3Macro(ViewPlaneNormal, double);
00252 
00254 
00258   void SetViewShear(double dxdz, double dydz, double center);
00259   void SetViewShear(double d[3]);
00260   vtkGetVector3Macro(ViewShear, double);
00262 
00264 
00266   vtkSetMacro(EyeAngle, double);
00267   vtkGetMacro(EyeAngle, double);
00269 
00271 
00275   vtkSetMacro(FocalDisk, double);
00276   vtkGetMacro(FocalDisk, double);
00278 
00280 
00284   vtkSetMacro(UseOffAxisProjection, int);
00285   vtkGetMacro(UseOffAxisProjection, int);
00286   vtkBooleanMacro(UseOffAxisProjection, int);
00288 
00290 
00292   vtkSetVector3Macro(ScreenBottomLeft, double);
00293   vtkGetVector3Macro(ScreenBottomLeft, double);
00295 
00297 
00299   vtkSetVector3Macro(ScreenBottomRight, double);
00300   vtkGetVector3Macro(ScreenBottomRight, double);
00302 
00304 
00306   vtkSetVector3Macro(ScreenTopRight, double);
00307   vtkGetVector3Macro(ScreenTopRight, double);
00309 
00311 
00313   vtkSetMacro(EyeSeparation, double);
00314   vtkGetMacro(EyeSeparation, double);
00316 
00318 
00322   void SetEyePosition(double eyePosition[3]);
00323   void GetEyePosition(double eyePosition[3]);
00325 
00328   void GetEyePlaneNormal(double normal[3]);
00329 
00331 
00334   void SetEyeTransformMatrix(vtkMatrix4x4* matrix);
00335   vtkGetObjectMacro(EyeTransformMatrix, vtkMatrix4x4);
00337 
00341   void SetEyeTransformMatrix(const double elements[16]);
00342 
00344 
00347   void SetModelTransformMatrix(vtkMatrix4x4 *matrix);
00348   vtkGetObjectMacro(ModelTransformMatrix, vtkMatrix4x4);
00350 
00354   void SetModelTransformMatrix(const double elements[16]);
00355 
00357   virtual vtkMatrix4x4 *GetModelViewTransformMatrix();
00358 
00360   virtual vtkTransform *GetModelViewTransformObject();
00361 
00367   virtual vtkMatrix4x4 *GetViewTransformMatrix();
00368 
00374   virtual vtkTransform *GetViewTransformObject();
00375 
00377 
00383    virtual vtkMatrix4x4 *GetProjectionTransformMatrix(double aspect,
00384                                                       double nearz,
00385                                                       double farz);
00387 
00389 
00395   virtual vtkPerspectiveTransform *GetProjectionTransformObject(double aspect,
00396                                                                 double nearz,
00397                                                                 double farz);
00399 
00401 
00408   virtual vtkMatrix4x4 *GetCompositeProjectionTransformMatrix(double aspect,
00409                                                               double nearz,
00410                                                               double farz);
00412 
00413 
00415 
00419   void SetUserViewTransform(vtkHomogeneousTransform *transform);
00420   vtkGetObjectMacro(UserViewTransform,vtkHomogeneousTransform);
00422 
00424 
00428   void SetUserTransform(vtkHomogeneousTransform *transform);
00429   vtkGetObjectMacro(UserTransform,vtkHomogeneousTransform);
00431 
00435   virtual void Render(vtkRenderer *) {}
00436 
00439   unsigned long GetViewingRaysMTime();
00440 
00443   void ViewingRaysModified();
00444 
00452   virtual void GetFrustumPlanes(double aspect, double planes[24]);
00453 
00455 
00456   double *GetOrientation();
00457   double *GetOrientationWXYZ();
00459 
00462   void ComputeViewPlaneNormal();
00463 
00467   vtkMatrix4x4 *GetCameraLightTransformMatrix();
00468 
00470   virtual void UpdateViewport(vtkRenderer *vtkNotUsed(ren)) {}
00471 
00473 
00474   vtkSetMacro(LeftEye, int);
00475   vtkGetMacro(LeftEye, int);
00477 
00480   void ShallowCopy(vtkCamera *source);
00481 
00484   void DeepCopy(vtkCamera *source);
00485 
00487 
00490   vtkSetMacro(FreezeFocalPoint, bool);
00491   vtkGetMacro(FreezeFocalPoint, bool);
00493 
00494 protected:
00495   vtkCamera();
00496   ~vtkCamera();
00497 
00499 
00500   void ComputeDistance();
00501   void ComputeViewTransform();
00503 
00505 
00506   void ComputeProjectionTransform(double aspect,
00507                                   double nearz,
00508                                   double farz);
00510 
00512 
00513   void ComputeCompositeProjectionTransform(double aspect,
00514                                            double nearz,
00515                                            double farz);
00517 
00518   void ComputeCameraLightTransform();
00519 
00520 
00523   void ComputeWorldToScreenMatrix();
00524 
00526   void ComputeOffAxisProjectionFrustum();
00527 
00529   void ComputeModelViewMatrix();
00530 
00533   void PartialCopy(vtkCamera *source);
00534 
00535   double WindowCenter[2];
00536   double ObliqueAngles[2];
00537   double FocalPoint[3];
00538   double Position[3];
00539   double ViewUp[3];
00540   double ViewAngle;
00541   double ClippingRange[2];
00542   double EyeAngle;
00543   int    ParallelProjection;
00544   double ParallelScale;
00545   int    Stereo;
00546   int    LeftEye;
00547   double Thickness;
00548   double Distance;
00549   double DirectionOfProjection[3];
00550   double ViewPlaneNormal[3];
00551   double ViewShear[3];
00552   int    UseHorizontalViewAngle;
00553 
00554   int    UseOffAxisProjection;
00555 
00556   double ScreenBottomLeft[3];
00557   double ScreenBottomRight[3];
00558   double ScreenTopRight[3];
00559 
00560   double EyeSeparation;
00561 
00562   vtkMatrix4x4 *WorldToScreenMatrix;
00563   vtkTimeStamp  WorldToScreenMatrixMTime;
00564 
00565   vtkMatrix4x4 *EyeTransformMatrix;
00566 
00567   vtkMatrix4x4 *ModelTransformMatrix;
00568 
00569   vtkHomogeneousTransform *UserTransform;
00570   vtkHomogeneousTransform *UserViewTransform;
00571 
00572   vtkTransform *ViewTransform;
00573   vtkPerspectiveTransform *ProjectionTransform;
00574   vtkPerspectiveTransform *Transform;
00575   vtkTransform *CameraLightTransform;
00576 
00577   vtkTransform *ModelViewTransform;
00578 
00579   double FocalDisk;
00580   //BTX
00581   vtkCameraCallbackCommand *UserViewTransformCallbackCommand;
00582   friend class vtkCameraCallbackCommand;
00583   //ETX
00584 
00585   // ViewingRaysMtime keeps track of camera modifications which will
00586   // change the calculation of viewing rays for the camera before it is
00587   // transformed to the camera's location and orientation.
00588   vtkTimeStamp ViewingRaysMTime;
00589   bool FreezeFocalPoint;
00590 
00591 private:
00592   vtkCamera(const vtkCamera&);  // Not implemented.
00593   void operator=(const vtkCamera&);  // Not implemented.
00594 };
00595 
00596 #endif