VTK
|
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 "vtkObject.h" 00038 00039 class vtkHomogeneousTransform; 00040 class vtkMatrix4x4; 00041 class vtkPerspectiveTransform; 00042 class vtkRenderer; 00043 class vtkTransform; 00044 class vtkCallbackCommand; 00045 class vtkCameraCallbackCommand; 00046 00047 class VTK_RENDERING_EXPORT vtkCamera : public vtkObject 00048 { 00049 public: 00050 void PrintSelf(ostream& os, vtkIndent indent); 00051 vtkTypeMacro(vtkCamera,vtkObject); 00052 00056 static vtkCamera *New(); 00057 00059 00061 void SetPosition(double x, double y, double z); 00062 void SetPosition(const double a[3]) { 00063 this->SetPosition(a[0], a[1], a[2]); }; 00064 vtkGetVector3Macro(Position,double); 00066 00068 00070 void SetFocalPoint(double x, double y, double z); 00071 void SetFocalPoint(const double a[3]) { 00072 this->SetFocalPoint(a[0], a[1], a[2]);}; 00073 vtkGetVector3Macro(FocalPoint,double); 00075 00077 00079 void SetViewUp(double vx, double vy, double vz); 00080 void SetViewUp(const double a[3]) { 00081 this->SetViewUp(a[0], a[1], a[2]); } 00082 vtkGetVector3Macro(ViewUp,double); 00084 00088 void OrthogonalizeViewUp(); 00089 00092 void SetDistance(double); 00093 00095 00097 vtkGetMacro(Distance,double); 00099 00101 00104 vtkGetVector3Macro(DirectionOfProjection,double); 00106 00111 void Dolly(double value); 00112 00114 00115 void SetRoll(double angle); 00116 double GetRoll(); 00118 00121 void Roll(double angle); 00122 00127 void Azimuth(double angle); 00128 00134 void Yaw(double angle); 00135 00140 void Elevation(double angle); 00141 00145 void Pitch(double angle); 00146 00148 00151 void SetParallelProjection(int flag); 00152 vtkGetMacro(ParallelProjection,int); 00153 vtkBooleanMacro(ParallelProjection,int); 00155 00157 00163 void SetUseHorizontalViewAngle(int flag); 00164 vtkGetMacro(UseHorizontalViewAngle, int); 00165 vtkBooleanMacro(UseHorizontalViewAngle, int); 00167 00169 00176 void SetViewAngle(double angle); 00177 vtkGetMacro(ViewAngle,double); 00179 00181 00186 void SetParallelScale(double scale); 00187 vtkGetMacro(ParallelScale,double); 00189 00194 void Zoom(double factor); 00195 00197 00206 void SetClippingRange(double dNear, double dFar); 00207 void SetClippingRange(const double a[2]) { 00208 this->SetClippingRange(a[0], a[1]); }; 00209 vtkGetVector2Macro(ClippingRange,double); 00211 00213 00216 void SetThickness(double); 00217 vtkGetMacro(Thickness,double); 00219 00221 00226 void SetWindowCenter(double x, double y); 00227 vtkGetVector2Macro(WindowCenter,double); 00229 00238 void SetObliqueAngles(double alpha, double beta); 00239 00243 void ApplyTransform(vtkTransform *t); 00244 00246 00249 vtkGetVector3Macro(ViewPlaneNormal,double); 00251 00253 00257 void SetViewShear(double dxdz, double dydz, double center); 00258 void SetViewShear(double d[3]); 00259 vtkGetVector3Macro(ViewShear, double); 00261 00263 00265 vtkSetMacro(EyeAngle,double); 00266 vtkGetMacro(EyeAngle,double); 00268 00270 00274 vtkSetMacro(FocalDisk,double); 00275 vtkGetMacro(FocalDisk,double); 00277 00279 00283 vtkSetMacro(UseOffAxisProjection, int); 00284 vtkGetMacro(UseOffAxisProjection, int); 00285 vtkBooleanMacro(UseOffAxisProjection, int); 00287 00289 00291 vtkSetVector3Macro(ScreenBottomLeft, double); 00292 vtkGetVector3Macro(ScreenBottomLeft, double); 00294 00296 00298 vtkSetVector3Macro(ScreenBottomRight, double); 00299 vtkGetVector3Macro(ScreenBottomRight, double); 00301 00303 00305 vtkSetVector3Macro(ScreenTopRight, double); 00306 vtkGetVector3Macro(ScreenTopRight, double); 00308 00310 00312 vtkSetMacro(EyeSeparation, double); 00313 vtkGetMacro(EyeSeparation, double); 00315 00317 00321 void SetEyePosition(double eyePosition[3]); 00322 void GetEyePosition(double eyePosition[3]); 00324 00327 void GetEyePlaneNormal(double normal[3]); 00328 00330 00333 void SetEyeTransformMatrix(vtkMatrix4x4* matrix); 00334 vtkGetObjectMacro(EyeTransformMatrix, vtkMatrix4x4); 00336 00340 void SetEyeTransformMatrix(const double elements[16]); 00341 00343 00346 void SetModelTransformMatrix(vtkMatrix4x4 *matrix); 00347 vtkGetObjectMacro(ModelTransformMatrix, vtkMatrix4x4); 00349 00353 void SetModelTransformMatrix(const double elements[16]); 00354 00356 virtual vtkMatrix4x4 *GetModelViewTransformMatrix(); 00357 00359 virtual vtkTransform *GetModelViewTransformObject(); 00360 00366 virtual vtkMatrix4x4 *GetViewTransformMatrix(); 00367 00373 virtual vtkTransform *GetViewTransformObject(); 00374 00376 00385 VTK_LEGACY(virtual vtkMatrix4x4 *GetPerspectiveTransformMatrix(double aspect, 00386 double nearz, 00387 double farz)); 00389 00391 00397 virtual vtkMatrix4x4 *GetProjectionTransformMatrix(double aspect, 00398 double nearz, 00399 double farz); 00401 00403 00409 virtual vtkPerspectiveTransform *GetProjectionTransformObject(double aspect, 00410 double nearz, 00411 double farz); 00413 00414 00416 00426 VTK_LEGACY(virtual vtkMatrix4x4 *GetCompositePerspectiveTransformMatrix( 00427 double aspect, 00428 double nearz, 00429 double farz)); 00431 00433 00440 virtual vtkMatrix4x4 *GetCompositeProjectionTransformMatrix(double aspect, 00441 double nearz, 00442 double farz); 00444 00445 00447 00451 void SetUserViewTransform(vtkHomogeneousTransform *transform); 00452 vtkGetObjectMacro(UserViewTransform,vtkHomogeneousTransform); 00454 00456 00460 void SetUserTransform(vtkHomogeneousTransform *transform); 00461 vtkGetObjectMacro(UserTransform,vtkHomogeneousTransform); 00463 00467 virtual void Render(vtkRenderer *) {} 00468 00471 unsigned long GetViewingRaysMTime(); 00472 00475 void ViewingRaysModified(); 00476 00484 virtual void GetFrustumPlanes(double aspect, double planes[24]); 00485 00487 00488 double *GetOrientation(); 00489 double *GetOrientationWXYZ(); 00491 00493 00495 VTK_LEGACY(void SetViewPlaneNormal(double x, double y, double z)); 00496 VTK_LEGACY(void SetViewPlaneNormal(const double a[3])); 00498 00501 void ComputeViewPlaneNormal(); 00502 00506 vtkMatrix4x4 *GetCameraLightTransformMatrix(); 00507 00509 virtual void UpdateViewport(vtkRenderer *vtkNotUsed(ren)) {} 00510 00512 00513 vtkSetMacro(LeftEye,int); 00514 vtkGetMacro(LeftEye,int); 00516 00519 void ShallowCopy(vtkCamera *source); 00520 00523 void DeepCopy(vtkCamera *source); 00524 00525 protected: 00526 vtkCamera(); 00527 ~vtkCamera(); 00528 00530 00531 void ComputeDistance(); 00532 void ComputeViewTransform(); 00534 00535 #ifndef VTK_LEGACY_REMOVE 00536 00537 00538 void ComputePerspectiveTransform(double aspect, 00539 double nearz, 00540 double farz); 00542 00544 00546 void ComputeCompositePerspectiveTransform(double aspect, 00547 double nearz, 00548 double farz); 00549 #endif 00550 00551 00553 00554 void ComputeProjectionTransform(double aspect, 00555 double nearz, 00556 double farz); 00558 00560 00561 void ComputeCompositeProjectionTransform(double aspect, 00562 double nearz, 00563 double farz); 00565 00566 void ComputeCameraLightTransform(); 00567 00568 00571 void ComputeWorldToScreenMatrix(); 00572 00574 void ComputeOffAxisProjectionFrustum(); 00575 00577 void ComputeModelViewMatrix(); 00578 00581 void PartialCopy(vtkCamera *source); 00582 00583 double WindowCenter[2]; 00584 double ObliqueAngles[2]; 00585 double FocalPoint[3]; 00586 double Position[3]; 00587 double ViewUp[3]; 00588 double ViewAngle; 00589 double ClippingRange[2]; 00590 double EyeAngle; 00591 int ParallelProjection; 00592 double ParallelScale; 00593 int Stereo; 00594 int LeftEye; 00595 double Thickness; 00596 double Distance; 00597 double DirectionOfProjection[3]; 00598 double ViewPlaneNormal[3]; 00599 double ViewShear[3]; 00600 int UseHorizontalViewAngle; 00601 00602 int UseOffAxisProjection; 00603 00604 double ScreenBottomLeft[3]; 00605 double ScreenBottomRight[3]; 00606 double ScreenTopRight[3]; 00607 00608 double EyeSeparation; 00609 00610 vtkMatrix4x4 *WorldToScreenMatrix; 00611 vtkTimeStamp WorldToScreenMatrixMTime; 00612 00613 vtkMatrix4x4 *EyeTransformMatrix; 00614 00615 vtkMatrix4x4 *ModelTransformMatrix; 00616 00617 vtkHomogeneousTransform *UserTransform; 00618 vtkHomogeneousTransform *UserViewTransform; 00619 00620 vtkTransform *ViewTransform; 00621 vtkPerspectiveTransform *ProjectionTransform; 00622 vtkPerspectiveTransform *Transform; 00623 vtkTransform *CameraLightTransform; 00624 00625 vtkTransform *ModelViewTransform; 00626 00627 double FocalDisk; 00628 //BTX 00629 vtkCameraCallbackCommand *UserViewTransformCallbackCommand; 00630 friend class vtkCameraCallbackCommand; 00631 //ETX 00632 00633 // ViewingRaysMtime keeps track of camera modifications which will 00634 // change the calculation of viewing rays for the camera before it is 00635 // transformed to the camera's location and orientation. 00636 vtkTimeStamp ViewingRaysMTime; 00637 00638 private: 00639 vtkCamera(const vtkCamera&); // Not implemented. 00640 void operator=(const vtkCamera&); // Not implemented. 00641 }; 00642 00643 #endif 00644