用户是通过相机来观察三位场景中的物体,精准控制相机来实现用户从不同角度、不同位置来观察三位物体。
我们可以通过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是相机到焦点距离的一个除数 // 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);