[英]VTK, two disks are same size despite different radius?
Attempting to overlay two disks in VTK using the following code: 尝试使用以下代码在VTK中覆盖两个磁盘:
source = vtk.vtkDiskSource()
source.SetInnerRadius(0)
source.SetOuterRadius(100)
source.SetCircumferentialResolution(300)
source.SetRadialResolution(300)
source.Update()
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(source.GetOutputPort())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
source2 = vtk.vtkDiskSource()
source2.SetInnerRadius(0)
source2.SetOuterRadius(5)
source2.SetCircumferentialResolution(300)
source2.SetRadialResolution(300)
source2.Update()
mapper2 = vtk.vtkPolyDataMapper()
mapper2.SetInputConnection(source2.GetOutputPort())
actor2 = vtk.vtkActor()
actor2.SetMapper(mapper2)
actor2.GetProperty().SetColor(1.0,0.0,0.0)
actor2.SetPosition(0,0,1)
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
ren.AddActor(actor)
ren.AddActor(actor2)
renWin.Render()
iren.Start()
This should put one large white disk and a smaller red disk in front of it. 这应该在其前面放置一个大的白色磁盘和一个较小的红色磁盘。 However what it does is render two disks, one white and one red slightly in front of it.
但是,它的作用是在其前面渲染两个磁盘,一个为白色,另一个为红色。 However both disks are the exact same size.
但是,两个磁盘的大小完全相同。 ie I have to rotate it to see the white one.
即我必须旋转它才能看到白色的。 Any idea why this is happening?
知道为什么会这样吗? I feel the answers probably very obvious!
我觉得答案可能非常明显!
Many thanks 非常感谢
It´s because of your position setting of the actor2. 这是因为您设置了actor2的位置。 The 2nd disc is closer to the camera and appears larger.
第二张光盘离摄像机更近,并且看起来更大。
Decrease the distance or remove it. 减小或减小距离。
eg 例如
actor2.SetPosition(0,0,0.1)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.