I am using vtkInteractorStyleTrackballActor
with Spin
method.
For Spin
method, the actor would rotate along the actor center.
How can I change the rotation center? Does actor.SetOrigin
work? The explanation of SetOrigin
is:
Set/Get the origin of the Prop3D. This is the point about which all rotations take place.
However, when I use actor.SetOrigin
, the Spin
still rotate along the actor center.
The demo code is:
import vtkmodules.all as vtk
cylinder = vtk.vtkCylinderSource()
cylinder.Update()
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputData(cylinder.GetOutput())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
bounds = actor.GetBounds()
xmin, xmax, ymin, ymax, zmin, zmax = bounds
actor.SetOrigin(xmin, ymin, zmin) ############################# change the origin
render = vtk.vtkRenderer()
render.AddActor(actor)
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(render)
renWin.Render()
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
iren.SetInteractorStyle(vtk.vtkInteractorStyleTrackballActor())
iren.Initialize()
iren.Start()
Use ctrl+left mouse press and move
to trigger Spin
method.
Any suggestion is appreciated~~~