Skip to content
Sections
Personal tools
You are here: Home » BALLView » Support » PythonScripts » Scripts » Movie.py

Movie.py

Document Actions
Render a simple movie of the current models being rotated around the look-at vector of the camera by 360 degrees. Output is written as POVRay models, so make sure your file system has sufficient space left if you render larger surfaces.
# The step size in degrees between subsequent frames. # 2 obviously leads to 180 frames being generated
step = 5
# directory for storing the POVRay files
# (Warning: these can get HUGE!)
movie_dir = '.'
# base filename for the movie files. a number and .pob will be appended
movie_base = 'movie'

import os

camera = Camera(getScene().getStage().getCamera())

vv = Vector3(camera.getViewPoint())
la = Vector3(camera.getLookAtPosition())

# Compute rotation matrix for rotation about (camera) Y-axis
frame_angle = Angle(step, 0)
matrix = Matrix4x4()
matrix.setRotation(frame_angle, camera.getLookUpVector())

for snap in range(360. / step):
  print "writing snapshot",snap, "of", (360 / step)
  vv = camera.getViewPoint() - la
  vv = Vector3(matrix.m11 * vv.x + matrix.m12 * vv.y + matrix.m13 * vv.z + matrix.m14, matrix.m21 * vv.x + matrix.m22 * vv.y + matrix.m23 * vv.z +matrix.m24, matrix.m31 * vv.x + matrix.m32 * vv.y + matrix.m33 * vv.z + matrix.m34)
   camera.setViewPoint(vv + la)
   getScene().setCamera(camera)
   filename = os.path.join(movie_dir, movie_base + "_%04d.pov" % snap)
   getScene().exportScene(POVRenderer(filename))
 
 

Powered by Plone

This site conforms to the following standards: