VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkCamera.h,v $ 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 =========================================================================*/ 00031 #ifndef __vtkCamera_h 00032 #define __vtkCamera_h 00033 00034 #include "vtkObject.h" 00035 00036 class vtkMatrix4x4; 00037 class vtkPerspectiveTransform; 00038 class vtkRenderer; 00039 class vtkTransform; 00040 class vtkHomogeneousTransform; 00041 00042 class VTK_RENDERING_EXPORT vtkCamera : public vtkObject 00043 { 00044 public: 00045 void PrintSelf(ostream& os, vtkIndent indent); 00046 vtkTypeRevisionMacro(vtkCamera,vtkObject); 00047 00051 static vtkCamera *New(); 00052 00054 00056 void SetPosition(double x, double y, double z); 00057 void SetPosition(const double a[3]) { 00058 this->SetPosition(a[0], a[1], a[2]); }; 00059 vtkGetVector3Macro(Position,double); 00061 00063 00065 void SetFocalPoint(double x, double y, double z); 00066 void SetFocalPoint(const double a[3]) { 00067 this->SetFocalPoint(a[0], a[1], a[2]);}; 00068 vtkGetVector3Macro(FocalPoint,double); 00070 00072 00074 void SetViewUp(double vx, double vy, double vz); 00075 void SetViewUp(const double a[3]) { 00076 this->SetViewUp(a[0], a[1], a[2]); } 00077 vtkGetVector3Macro(ViewUp,double); 00079 00083 void OrthogonalizeViewUp(); 00084 00087 void SetDistance(double); 00088 00090 00092 vtkGetMacro(Distance,double); 00094 00096 00099 vtkGetVector3Macro(DirectionOfProjection,double); 00101 00105 void Dolly(double distance); 00106 00108 00109 void SetRoll(double angle); 00110 double GetRoll(); 00112 00114 void Roll(double angle); 00115 00119 void Azimuth(double angle); 00120 00124 void Yaw(double angle); 00125 00128 void Elevation(double angle); 00129 00132 void Pitch(double angle); 00133 00135 00138 void SetParallelProjection(int flag); 00139 vtkGetMacro(ParallelProjection,int); 00140 vtkBooleanMacro(ParallelProjection,int); 00142 00144 00150 void SetUseHorizontalViewAngle(int flag); 00151 vtkGetMacro(UseHorizontalViewAngle, int); 00152 vtkBooleanMacro(UseHorizontalViewAngle, int); 00154 00156 00163 void SetViewAngle(double angle); 00164 vtkGetMacro(ViewAngle,double); 00166 00168 00173 void SetParallelScale(double scale); 00174 vtkGetMacro(ParallelScale,double); 00176 00181 void Zoom(double factor); 00182 00184 00191 void SetClippingRange(double dNear, double dFar); 00192 void SetClippingRange(const double a[2]) { 00193 this->SetClippingRange(a[0], a[1]); }; 00194 vtkGetVector2Macro(ClippingRange,double); 00196 00198 00201 void SetThickness(double); 00202 vtkGetMacro(Thickness,double); 00204 00206 00211 void SetWindowCenter(double x, double y); 00212 vtkGetVector2Macro(WindowCenter,double); 00214 00223 void SetObliqueAngles(double alpha, double beta); 00224 00228 void ApplyTransform(vtkTransform *t); 00229 00231 00234 vtkGetVector3Macro(ViewPlaneNormal,double); 00236 00238 00242 void SetViewShear(double dxdz, double dydz, double center); 00243 void SetViewShear(double d[3]); 00244 vtkGetVector3Macro(ViewShear, double); 00246 00248 00250 vtkSetMacro(EyeAngle,double); 00251 vtkGetMacro(EyeAngle,double); 00253 00255 00259 vtkSetMacro(FocalDisk,double); 00260 vtkGetMacro(FocalDisk,double); 00262 00267 virtual vtkMatrix4x4 *GetViewTransformMatrix(); 00268 00270 00274 virtual vtkTransform *GetViewTransformObject() 00275 { 00276 return this->ViewTransform; 00277 } 00279 00281 00290 VTK_LEGACY(virtual vtkMatrix4x4 *GetPerspectiveTransformMatrix(double aspect, 00291 double nearz, 00292 double farz)); 00294 00296 00302 virtual vtkMatrix4x4 *GetProjectionTransformMatrix(double aspect, 00303 double nearz, 00304 double farz); 00306 00308 00314 virtual vtkPerspectiveTransform *GetProjectionTransformObject(double aspect, 00315 double nearz, 00316 double farz); 00318 00319 00321 00331 VTK_LEGACY(virtual vtkMatrix4x4 *GetCompositePerspectiveTransformMatrix( 00332 double aspect, 00333 double nearz, 00334 double farz)); 00336 00338 00345 virtual vtkMatrix4x4 *GetCompositeProjectionTransformMatrix(double aspect, 00346 double nearz, 00347 double farz); 00349 00350 00352 00356 void SetUserTransform(vtkHomogeneousTransform *transform); 00357 vtkGetObjectMacro(UserTransform,vtkHomogeneousTransform); 00359 00363 virtual void Render(vtkRenderer *) {} 00364 00367 unsigned long GetViewingRaysMTime(); 00368 00371 void ViewingRaysModified(); 00372 00380 virtual void GetFrustumPlanes(double aspect, double planes[24]); 00381 00383 00384 double *GetOrientation(); 00385 double *GetOrientationWXYZ(); 00387 00389 00391 VTK_LEGACY(void SetViewPlaneNormal(double x, double y, double z)); 00392 VTK_LEGACY(void SetViewPlaneNormal(const double a[3])); 00394 00397 void ComputeViewPlaneNormal(); 00398 00402 vtkMatrix4x4 *GetCameraLightTransformMatrix(); 00403 00405 virtual void UpdateViewport(vtkRenderer *vtkNotUsed(ren)) {} 00406 00408 00409 vtkSetMacro(LeftEye,int); 00410 vtkGetMacro(LeftEye,int); 00412 00413 protected: 00414 vtkCamera(); 00415 ~vtkCamera(); 00416 00418 00419 void ComputeDistance(); 00420 void ComputeViewTransform(); 00422 00423 #ifndef VTK_LEGACY_REMOVE 00424 00425 00426 void ComputePerspectiveTransform(double aspect, 00427 double nearz, 00428 double farz); 00430 00432 00434 void ComputeCompositePerspectiveTransform(double aspect, 00435 double nearz, 00436 double farz); 00438 #endif 00439 00441 00442 void ComputeProjectionTransform(double aspect, 00443 double nearz, 00444 double farz); 00446 00448 00449 void ComputeCompositeProjectionTransform(double aspect, 00450 double nearz, 00451 double farz); 00453 00454 00455 void ComputeCameraLightTransform(); 00456 00457 double WindowCenter[2]; 00458 double ObliqueAngles[2]; 00459 double FocalPoint[3]; 00460 double Position[3]; 00461 double ViewUp[3]; 00462 double ViewAngle; 00463 double ClippingRange[2]; 00464 double EyeAngle; 00465 int ParallelProjection; 00466 double ParallelScale; 00467 int Stereo; 00468 int LeftEye; 00469 double Thickness; 00470 double Distance; 00471 double DirectionOfProjection[3]; 00472 double ViewPlaneNormal[3]; 00473 double ViewShear[3]; 00474 int UseHorizontalViewAngle; 00475 vtkHomogeneousTransform *UserTransform; 00476 00477 vtkTransform *ViewTransform; 00478 vtkPerspectiveTransform *ProjectionTransform; 00479 vtkPerspectiveTransform *Transform; 00480 vtkTransform *CameraLightTransform; 00481 00482 double FocalDisk; 00483 00484 // ViewingRaysMtime keeps track of camera modifications which will 00485 // change the calculation of viewing rays for the camera before it is 00486 // transformed to the camera's location and orientation. 00487 vtkTimeStamp ViewingRaysMTime; 00488 private: 00489 vtkCamera(const vtkCamera&); // Not implemented. 00490 void operator=(const vtkCamera&); // Not implemented. 00491 }; 00492 00493 #endif 00494