[vtkusers] problem saving series of images
John Hunter
jdhunter at ace.bsd.uchicago.edu
Thu Oct 9 17:44:48 EDT 2003
I am storing a series of camera positions/directions/focal points in a
list and then I want to iterate over that list, set the camera
position, render, and save the image. Once I get this working, I'll
use spline animation between the saved points to make the animation
smooth. In the current incarnation, however, the last frame is saved
in every image. Any idea what I'm doing wrong.
#I add frames with
def add_frame(button):
global frames
camera = renderer.GetActiveCamera()
fpu = camera.GetFocalPoint(), camera.GetPosition(), camera.GetViewUp()
frames.append(fpu)
#And save the movie with
def save_movie(button):
camera = renderer.GetActiveCamera()
for i,fpu in enumerate(frames):
focal, position, up = fpu
print 'frame',i,fpu
camera.SetFocalPoint(focal)
camera.SetPosition(position)
camera.SetViewUp(up)
renderer.ResetCameraClippingRange()
renderer.Render()
save_image('test%d.png'%i)
#Where save_image is
def save_image(fname):
renSrc = vtk.vtkRendererSource()
renSrc.SetInput(renderer)
renSrc.WholeWindowOn()
writer = vtk.vtkPNGWriter()
writer.SetInput(renSrc.GetOutput())
writer.SetFileName(fname)
writer.Write()
>From the print statement in the save_movie loop, I see that the frames
are iterated over and the position changes, but this doesn't seem to
affect the image saved.
PS, if there is a better way to make a movie, please advise.
Thanks for any advice,
John Hunter
More information about the vtkusers
mailing list