VTK Camera简介
来源:互联网 发布:淘宝店铺链接在哪里 编辑:程序博客网 时间:2024/05/16 15:49
参考网址
介绍:
vtkCamera 是三维渲染的虚拟相机。它提供视角的位置、角度、方向, 焦点。
vtkCamera投影示意图
与相机投影相关的因素主要有:
l 相机位置:即相机所在的位置,用方法vtkCamera::SetPosition()设置。
l 相机焦点:用方法vtkCamera::SetFocalPoint()设置,默认的焦点位置在世界坐标系的原点。
l 朝上方向:即哪个方向为相机朝上的方向。就好比我们直立看东西,方向为头朝上,看到的东西也是直立的,如果我们倒立看某个东西,这时方向为头朝下,看到的东西当然就是倒立的。相机位置、相机焦点和朝上方向三个因素确定了相机的实际方向,即确定相机的视图。
l 投影方向:相机位置到相机焦点的向量方向即为投影方向。
l 投影方法:确定Actor是如何映射到像平面的。vtkCamera定义了两种投影方法,一种是正交投影(OrthographicProjection),也叫平行投影(Parallel Projection),即进入相机的光线与投影方向是平行的。另一种是透视投影(PerspectiveProjection),即所有的光线相交于一点。
l 视角: 透视投影时需要指定相机的视角(View Angle),默认的视角大小为30º,可以用方法vtkCamera::SetViewAngle()设置。
l 前后裁剪平面:裁剪平面与投影方向相交,一般与投影方向也是垂直的。裁剪平面主要用于评估Actor与相机距离的远近,只有在前后裁剪平面之间的Actor才是可见的。裁剪平面的位置可以用方法vtkCamera::SetClippingRange()设置。
如果你想获取vtkRenderer里默认的相机,可以用方法vtkRenderer::GetActiveCamera()。
相机vtkCamera的使用方法:
vtkSmartPointer<vtkCamera>myCamera = vtkSmartPointer<vtkCamera>::New();myCamera->SetClippingRange(0.0475,2.3786); //这些值随便设置的,为了演示用法而已myCamera->SetFocalPoint(0.0573,-0.2134, -0.0523);myCamera->SetPosition(0.3245,-0.1139, -0.2932);myCamera->ComputeViewPlaneNormal();myCamera->SetViewUp(-0.2234,0.9983, 0.0345);renderer->SetActiveCamera(myCamera);
上述我们用SetClippingRange();SetFocalPoint();SetPosition()分别设置相机的前后裁剪平面,焦点和位置。ComputeViewPlaneNormal()方法是根据设置的相机位置、焦点等信息,重新计算视平面(View Plane)的法向量。一般该法向量与视平面是垂直的,如果不是垂直的话,Actor等看起来会有一些特殊的效果,如错切。SetViewUp()方法用于设置相机朝上方向。最后用方法vtkRenderer::SetActiveCamera()把相机设置到渲染场景中。
vtkCamera 除了提供设置与相机投影因素相关的方法之外,还提供了大量的控制相机运动的方法,如:vtkCamera::Dolly(),vtkCamera::Roll(),vtkCamera::Azimuth()(纬度),vtkCamera::Yaw(),vtkCamera::Elevation()(经度),vtkCamera::Pitch(),vtkCamera::Zoom()。这些方法具体表示相机是怎么运动,以及相对哪个位置或者方向运动,请参考下图或者关于类vtkCamera的文档说明。
Rotate the camera about the direction of projection. This will spin the camera about its axis.
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.
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.
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.
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.
本来想写点不一样的东西的,结果直接复制过来了。
- VTK Camera简介
- vtk Camera
- vtk Camera
- vtk Camera
- VTK简介
- VTK简介
- VTK简介
- VTK简介
- VTK简介
- VTK简介(1)
- VTK简介(2)
- VTK简介(3)
- VTK简介(4)
- VTK简介及安装
- VTK简介及安装
- VTK简介及安装
- VTK 编程简介
- vtk对 camera 的操作方法如下
- 一行的代码
- jsp实现全选
- 数组知识点
- 异常 断言 try except finally assert
- oracle 数据操纵语言(DML)-简单查询
- VTK Camera简介
- Android LRecyclerView实现Item侧滑菜单、长按拖拽Item、滑动删除Item等功能
- Libevent学习
- PHP安全编程之从URL的语义进行攻击
- HTTP协议
- 找词的位置
- Office 365 利用并行工作流构建威客式任务管理系统之使用SharePoint Designer 定制任务过期提醒!
- Spring Boot学习记录(一)--环境搭建
- 深入理解Redis主键失效原理及实现机制