The operation method of vtk on camera is as follows

The operation method of camera is as follows: 
vtkCamera *aCamera = vtkCamera::New(); 
aCamera->SetViewUp (0, 0, -1);//Set the viewing angle position 
aCamera->SetPosition (0, 1, 0);// Set the observation object position
aCamera->SetFocalPoint (0, 0, 0);//Set the focus 
aCamera->ComputeViewPlaneNormal();//Automatic
aRenderer->SetActiveCamera(aCamera);

1. SetClippingPlane
      sets the distance between the nearest and farthest slices in the camera's shooting direction. The feeling parameters are like the position information of the previous and last slices projected by the parallel light onto the volume data. (Represented by the world coordinate system) It seems that the out-of-plane data is clipped when rendering.

2.SetFocalPoint /SetPosition
(world coordinate system), control the camera distance.

3. ComputeViewPlaneNormal
        resets the view plane normal, based on the current position and focus. Otherwise, the oblique shearing effect will appear.

4.SetViewUp
sets the upward direction of the camera.

5.Zoom
enlarges the object by changing the angle of view.

6.SetViewAngle
sets the angle of view of the camera, the default angle is 30 degrees, if it is a parallel projection, the angle is invalid.
Usually the perfect viewing angle is calculated = 2*atan((h/2)/d), h is the height of the renderwindow, and d is the distance from the eye to the screen.
OrthogonalizeViewup()--Sets the orthogonalize angle.

7. Modify the camera position
After setting the focus, use Azimuth() to modify the azimuth and Elevation() to modify the camera position. Move the camera in spherical latitude around the focal point. Example:
Azimuth(150)//Indicates that the camera's viewpoint position is rotated 150 degrees clockwise 
Elevation(60)// Indicates that the camera's viewpoint position is rotated 60 degrees in the upward direction

 

初始化相机
vtkCamera* cam1 = vtkCamera::New();
cam1->SetClippingRange(0.0475572, 2.337786);                     //参数分别为沿着视向的近、远剪切面的距离
cam1->SetFocalPoint(0.052665, -0.129454, -0.0573973);       //焦点:世界坐标系,控制相机方向
cam1->SetPosition(0.327637, -0.116299, -0.256418);            //位置:世界坐标系,设置相机位置
cam1->ComputeViewPlaneNormal();                                       //重置视平面法向,基于当前的位置和焦点。否则会出现斜推剪切效果
cam1->SetViewUp(-0.0225386, 0.999137, 0.034901);            //设置相机的“上”方向
ren1->SetActiveCamera(cam1);                                          //设置渲染器的相机
设置已有的相机
cam1 = ren1->GetActiveCamera();                                    //获取渲染器的相机
cam1->Zoom(1.4);                                                                  //放大相机,通过改变视角(SetViewAngle()),
另外,也可以使用Dolly()方法沿着视平面法向移动相机,实现放大或缩小可见角色物体。
基于焦点,使用Azimuth()和Elevation()方法设置相机的方位角和高度角/仰角(度,degree)[球坐标系统]。
注意其中在南极和北极存在奇异点,即视向量平行于视平面法向。此时可以使用OrthogonalizeViewUp()方法强制其正交。但这会改变相机坐标系统。
正交投影vs透视投影
vtkCamera::ParallelProjectionOn()开启平行/正交投影。此时需通过SetParallelScale()方法控制角色物体的缩放。Zoom不再有效。

 

本文来源:http://swyxgc.blog.163.com/blog/static/4567575320112433642190/

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324771451&siteId=291194637