I am trying to create a 3D scene using blender. I have made a model and camera path using blender interface. However, I want camera matrix to be exported frame by frame as well.

I know using Python script interface might do the job. Thus, I am wondering if I can animate frame by frame and in processing each frame, I can output camera matrix as well.

I know bpy.ops.render.render(animation=True) can render all the frames at once. Is there a way that I can do frame-basis?

Any comments are appreciated.

import bpy
import os

scn = bpy.context.scene

for f in range(scn.frame_start, scn.frame_end + 1, scn.frame_step):

    # go to frame f

    # output the camera matrix on the current frame
    mat = scn.camera.matrix_world

    # set the filepath
    scn.render.filepath = os.path.join("C:/my/path/to/file/basename", str(f).zfill(4)

    # render the current frame

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.