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 00204 void SetClippingRange(double dNear, double dFar); 00205 void SetClippingRange(const double a[2]) { 00206 this->SetClippingRange(a[0], a[1]); }; 00207 vtkGetVector2Macro(ClippingRange,double); 00209 00211 00214 void SetThickness(double); 00215 vtkGetMacro(Thickness,double); 00217 00219 00224 void SetWindowCenter(double x, double y); 00225 vtkGetVector2Macro(WindowCenter,double); 00227 00236 void SetObliqueAngles(double alpha, double beta); 00237 00241 void ApplyTransform(vtkTransform *t); 00242 00244 00247 vtkGetVector3Macro(ViewPlaneNormal,double); 00249 00251 00255 void SetViewShear(double dxdz, double dydz, double center); 00256 void SetViewShear(double d[3]); 00257 vtkGetVector3Macro(ViewShear, double); 00259 00261 00263 vtkSetMacro(EyeAngle,double); 00264 vtkGetMacro(EyeAngle,double); 00266 00268 00272 vtkSetMacro(FocalDisk,double); 00273 vtkGetMacro(FocalDisk,double); 00275 00280 virtual vtkMatrix4x4 *GetViewTransformMatrix(); 00281 00283 00287 virtual vtkTransform *GetViewTransformObject() 00288 { 00289 return this->ViewTransform; 00290 } 00292 00294 00303 VTK_LEGACY(virtual vtkMatrix4x4 *GetPerspectiveTransformMatrix(double aspect, 00304 double nearz, 00305 double farz)); 00307 00309 00315 virtual vtkMatrix4x4 *GetProjectionTransformMatrix(double aspect, 00316 double nearz, 00317 double farz); 00319 00321 00327 virtual vtkPerspectiveTransform *GetProjectionTransformObject(double aspect, 00328 double nearz, 00329 double farz); 00331 00332 00334 00344 VTK_LEGACY(virtual vtkMatrix4x4 *GetCompositePerspectiveTransformMatrix( 00345 double aspect, 00346 double nearz, 00347 double farz)); 00349 00351 00358 virtual vtkMatrix4x4 *GetCompositeProjectionTransformMatrix(double aspect, 00359 double nearz, 00360 double farz); 00362 00363 00365 00369 void SetUserViewTransform(vtkHomogeneousTransform *transform); 00370 vtkGetObjectMacro(UserViewTransform,vtkHomogeneousTransform); 00372 00374 00378 void SetUserTransform(vtkHomogeneousTransform *transform); 00379 vtkGetObjectMacro(UserTransform,vtkHomogeneousTransform); 00381 00385 virtual void Render(vtkRenderer *) {} 00386 00389 unsigned long GetViewingRaysMTime(); 00390 00393 void ViewingRaysModified(); 00394 00402 virtual void GetFrustumPlanes(double aspect, double planes[24]); 00403 00405 00406 double *GetOrientation(); 00407 double *GetOrientationWXYZ(); 00409 00411 00413 VTK_LEGACY(void SetViewPlaneNormal(double x, double y, double z)); 00414 VTK_LEGACY(void SetViewPlaneNormal(const double a[3])); 00416 00419 void ComputeViewPlaneNormal(); 00420 00424 vtkMatrix4x4 *GetCameraLightTransformMatrix(); 00425 00427 virtual void UpdateViewport(vtkRenderer *vtkNotUsed(ren)) {} 00428 00430 00431 vtkSetMacro(LeftEye,int); 00432 vtkGetMacro(LeftEye,int); 00434 00439 void ComputeProjAndViewParams( ); 00440 00442 00443 void SetConfigParams( double o2screen, double o2right, double o2left, 00444 double o2top, double o2bottom , double interOccDist, 00445 double scale, vtkMatrix4x4 * surfaceRot ); 00446 // Description: 00447 // This function is a convinience function intended for the Paraview 00448 // ServerManager 00449 void SetHeadPose( double x00, double x01, double x02, double x03, 00450 double x10, double x11, double x12, double x13, 00451 double x20, double x21, double x22, double x23, 00452 double x30, double x31, double x32, double x33 ); 00454 00456 00458 vtkSetMacro(HeadTracked,int); 00459 vtkGetMacro(HeadTracked,int); 00461 00464 void ShallowCopy(vtkCamera *source); 00465 00468 void DeepCopy(vtkCamera *source); 00469 00470 protected: 00471 vtkCamera(); 00472 ~vtkCamera(); 00473 00475 00476 void ComputeDistance(); 00477 void ComputeViewTransform(); 00479 00480 #ifndef VTK_LEGACY_REMOVE 00481 00482 00483 void ComputePerspectiveTransform(double aspect, 00484 double nearz, 00485 double farz); 00487 00489 00491 void ComputeCompositePerspectiveTransform(double aspect, 00492 double nearz, 00493 double farz); 00494 #endif 00495 00496 00498 00499 void ComputeProjectionTransform(double aspect, 00500 double nearz, 00501 double farz); 00503 00505 00506 void ComputeCompositeProjectionTransform(double aspect, 00507 double nearz, 00508 double farz); 00510 00513 vtkMatrix4x4* SetTranslation( vtkMatrix4x4 mat ); 00514 00515 void ComputeCameraLightTransform(); 00516 00519 void SetSurface2Base( vtkMatrix4x4 *head ); 00520 00523 void PartialCopy(vtkCamera *source); 00524 00525 double WindowCenter[2]; 00526 double ObliqueAngles[2]; 00527 double FocalPoint[3]; 00528 double Position[3]; 00529 double ViewUp[3]; 00530 double ViewAngle; 00531 double ClippingRange[2]; 00532 double EyeAngle; 00533 int ParallelProjection; 00534 double ParallelScale; 00535 int Stereo; 00536 int LeftEye; 00537 double Thickness; 00538 double Distance; 00539 double DirectionOfProjection[3]; 00540 double ViewPlaneNormal[3]; 00541 double ViewShear[3]; 00542 int UseHorizontalViewAngle; 00543 vtkHomogeneousTransform *UserTransform; 00544 vtkHomogeneousTransform *UserViewTransform; 00545 00546 vtkTransform *ViewTransform; 00547 vtkPerspectiveTransform *ProjectionTransform; 00548 vtkPerspectiveTransform *Transform; 00549 vtkTransform *CameraLightTransform; 00550 00551 double FocalDisk; 00552 //BTX 00553 vtkCameraCallbackCommand *UserViewTransformCallbackCommand; 00554 friend class vtkCameraCallbackCommand; 00555 //ETX 00556 00557 // ViewingRaysMtime keeps track of camera modifications which will 00558 // change the calculation of viewing rays for the camera before it is 00559 // transformed to the camera's location and orientation. 00560 vtkTimeStamp ViewingRaysMTime; 00561 00562 // Asymmetric Frustum 00563 int HeadTracked; 00564 vtkMatrix4x4 *HeadPose; 00565 vtkTransform *Surface2Base; 00566 vtkMatrix4x4 *HeadTrackedViewMat; 00567 00568 double AsymLeft, AsymRight, AsymBottom, AsymTop; 00569 double EyePos[3]; 00570 double O2Screen; 00571 double O2Right; 00572 double O2Left; 00573 double O2Top; 00574 double O2Bottom; 00575 double EyeOffset; 00576 double ScaleFactor; 00577 00578 // temp 00579 vtkMatrix4x4 *eyePosMat; 00580 vtkMatrix4x4 *negEyePosMat; 00581 vtkMatrix4x4 *eyeOffsetMat; 00582 00583 private: 00584 vtkCamera(const vtkCamera&); // Not implemented. 00585 void operator=(const vtkCamera&); // Not implemented. 00586 }; 00587 00588 #endif 00589