Rouzbeh,
I've attached an example script showing how to create a camera
animation. This example simply orbits the camera about the focal
point.
Utkarsh
On Tue, Mar 10, 2009 at 12:30 PM, Rouzbeh Maani <[email protected]> wrote:
> Hello everybody
>
> I want to create an animation by Python scripting. I would like to set the
> position of camera in each frame(e.g. in the animation I want the camera
> to rotate around the object), but I could not find any example in which
> the position of the camera can be set in each frame.
> I would appreciate if anybody could help me.
>
> best regards
>
> Rouzbeh
>
> _______________________________________________
> 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 ParaView Wiki at:
> http://paraview.org/Wiki/ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://www.paraview.org/mailman/listinfo/paraview
>
from paraview.servermanager import *
# Initialization to set up some visualization
if not ActiveConnection:
Connect()
cylinder = sources.CylinderSource()
view = CreateRenderView()
repr = CreateRepresentation(cylinder, view)
view.ResetCamera()
# Create an animation scene
scene = animation.AnimationScene()
# Add the view to the scene
scene.ViewModules = [view]
# Set the number of frame in one loop.
scene.NumberOfFrames = 1000
# Create an animation cue for the camera. This represents the "track" shown in
# the Animation View.
cue = animation.CameraAnimationCue()
cue.AnimatedProxy = view
# Add this cue to the scene.
scene.Cues = [cue]
# Now create keyframes. Let's say we are going to orbit around the object.
camera = view.GetActiveCamera()
num_of_keyframes = 10
for i in range(0, num_of_keyframes):
camera.Azimuth(360.0/num_of_keyframes)
keyframe = animation.CameraKeyFrame()
# set the value of the key frame to the current camera location.
keyframe.KeyTime = i*1.0/num_of_keyframes
keyframe.Position = camera.GetPosition()
keyframe.FocalPoint = camera.GetFocalPoint()
keyframe.ViewUp = camera.GetViewUp()
keyframe.ViewAngle = camera.GetViewAngle()
cue.KeyFrames.append(keyframe)
# Play the animation
scene.Play()
_______________________________________________
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 ParaView Wiki at:
http://paraview.org/Wiki/ParaView
Follow this link to subscribe/unsubscribe:
http://www.paraview.org/mailman/listinfo/paraview