[vtkusers] Rendering a scene in which actors move
KS Jothybasu
jothybasu at gmail.com
Thu Mar 11 05:01:00 EST 2010
Have a look at http://www.cmake.org/Wiki/VTK/Examples/Python/Animation
Jothy
On Thu, Mar 11, 2010 at 5:05 AM, Gib Bogle <g.bogle at auckland.ac.nz> wrote:
> I wish to repeatedly render a scene with many actors (cones for now) that
> may change their positions as time progresses (i.e. I am creating a movie).
> I can render the scene OK, but I see that the way I'm doing it is just
> adding actors each time step, whereas I want to redraw all the actors each
> time (or possibly, if I get clever, only those that have moved). This what
> I'm doing in Python:
>
> def QVTKRenderWidgetCones(self,page_VTK):
> """A simple example that uses the QVTKRenderWindowInteractor
> class."""
> if self.first_VTK:
> self.first_VTK = False
> layout = QtGui.QVBoxLayout(page_VTK)
>
> # create the widget
> self.VTKscene = QVTKRenderWindowInteractor(page_VTK)
> self.VTKscene.Initialize()
> self.VTKscene.Start()
> renWin = self.VTKscene.GetRenderWindow()
>
> layout.addWidget(self.VTKscene)
> self.ren = vtk.vtkRenderer()
> renWin.AddRenderer(self.ren)
>
> cone = vtk.vtkConeSource()
> cone.SetResolution(8)
> self.coneMapper = vtk.vtkPolyDataMapper()
> self.coneMapper.SetInput(cone.GetOutput())
>
> # self.ren.Clear()
> # for actor in self.ren.GetActors():
> # self.ren.RemoveActor(actor)
>
> print self.ren.GetActors()
>
> n = self.ncells
> coneActor = [0]*n
> for i in range(0,n):
> coneActor[i] = vtk.vtkActor()
> coneActor[i].SetMapper(self.coneMapper)
> self.ren.AddActor(coneActor[i])
> cp = self.cellpos[i]
> x = int(cp[2])
> y = int(cp[3])
> z = int(cp[4])
> coneActor[i].SetPosition(x, y, z)
>
> # show the widget
> self.VTKscene.show()
> self.VTKscene.Render()
>
> I tried to use ren.Clear(), but that obviously clears everything, and I
> discovered that a collection is not a list and therefore my attempt to use
> ren.RemoveActor() failed. What is the right (i.e. fast) way to do this?
>
> Thanks
> Gib
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100311/c77fa8c7/attachment.htm>
More information about the vtkusers
mailing list