VTK: 相機參數控制

                 用戶是通過相機來觀察三位場景中的物體,精準控制相機來實現用戶從不同角度、不同位置來觀察三位物體。

我們可以通過GetActiveCamera()函數來獲取當前渲染器(vtkRenderer)中的默認相機。也可以通過SetActiveCamera()函數來設置一個新相機到渲染器中。 函數簽名如下:

 // Description:
  // Specify the camera to use for this renderer.
  void SetActiveCamera(vtkCamera *);

  // Description:
  // Get the current camera. If there is not camera assigned to the
  // renderer already, a new one is created automatically.
  // This does *not* reset the camera.
  vtkCamera *GetActiveCamera();

     相機的一些常規參數設置如下:

void vtkCamera::SetViewUp(double vx, double vy, double vz);% 朝上方向,默認爲(0, 1, 0)  
void vtkCamera::SetPosition(double x, double y, double z); % 相機位置,默認爲(0, 0, 1)  
void vtkCamera::SetFocalPoint(double x, double y, double z);% 焦點,默認爲(0, 0, 0)  
void vtkCamera::SetClippingRange(double dNear, double dFar);% 前後裁剪平面位置,默認爲(0.1, 1000)  
void vtkCamera::SetViewAngle(double angle); % 視角,默認爲30度  

    相機的運動控制,主要包括旋轉、縮放等一系列運動。旋轉主要包括相機圍繞焦點水平、垂直旋轉;焦點圍繞相機水平垂直旋轉;相機圍繞投影方向旋轉五大類。 函數標籤如下:
// Description:
  // Rotate the camera about the direction of projection.  This will
  // spin the camera about its axis.
  void Roll(double angle); //圍繞投影方向自旋轉

  // Description:
  // Rotate the camera about the view up vector centered at the focal point.
  // Note that the view up vector is whatever was set via SetViewUp, and is
  // not necessarily perpendicular to the direction of projection.  The
  // result is a horizontal rotation of the camera.
  void Azimuth(double angle);//以焦點爲中心,水平旋轉相機

  // Description:
  // Rotate the focal point about the view up vector, using the camera's
  // position as the center of rotation. Note that the view up vector is
  // whatever was set via SetViewUp, and is not necessarily perpendicular
  // to the direction of projection.  The result is a horizontal rotation
  // of the scene.
  void Yaw(double angle);//以相機爲中心水平旋轉焦點

  // Description:
  // Rotate the camera about the cross product of the negative of the
  // direction of projection and the view up vector, using the focal point
  // as the center of rotation.  The result is a vertical rotation of the
  // scene.
  void Elevation(double angle);//以焦點爲中心垂直旋轉相機

  // Description:
  // Rotate the focal point about the cross product of the view up vector
  // and the direction of projection, using the camera's position as the
  // center of rotation.  The result is a vertical rotation of the camera.
  void Pitch(double angle); //以相機爲中心 垂直旋轉焦點
     縮放主要是通過設置Dolly()或setDistance()完成。setDistance會移動焦點位置  Dolly是相機到焦點距離的一個除數
 distance/Dolly
    函數標籤如下:
 // Description:
  // Move the focal point so that it is the specified distance from
  // the camera position.  This distance must be positive.
  void SetDistance(double);

  // Description:
  // Divide the camera's distance from the focal point by the given
  // dolly value.  Use a value greater than one to dolly-in toward
  // the focal point, and use a value less than one to dolly-out away
  // from the focal point.
  void Dolly(double value);

                    相機運動示意圖                                          焦點運動示意圖                    
   

發佈了109 篇原創文章 · 獲贊 168 · 訪問量 27萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章