import bpy, os

# script for rendering multiple half parallax holograms in order to achieve a full parallax hologram
# Author Alaric Hamacher
# all rights reserved 2023.
# please refer

# the script requires a blender file with an appropriate animation for the half parallax hologram
# the script is to be executed on the same level as the blender file.
# a folder render with a numbered folder for each row will be created.

# helper function for setting the location of any object
def set_location(name, xyz):
     bpy.data.objects[name].location = xyz

# blender scene
s=bpy.context.scene;

# variables for the full parallax hologram
# the half parallax hologram is on the level of the origin
# values are in meters

#top camera location
top = 0.5;
#bottom camera location
bottom = -0.2;
# number of rows 
rows = 156;
# interval distance between each row
interval = (top - bottom)/rows;
# step equals the number of rows
step = 1;

# configuration to resume or separate the jobs
# startrow
startrow = 1
# endrow = rows

# render loop from top to bottom
for i in range(startrow, endrow+1, step) :
    # number of the folder
    foldernr = i;
    # absolute position for camera
    linenr = 0.50 - (foldernr -1)*interval;
    set_location("1m_circle", (0,0,linenr));
    # set proper output folder and filename
    bpy.context.scene.render.filepath = os.path.join("./render",str(foldernr).zfill(3),"HogelOut###.png")

    #render
    bpy.ops.render.render( #{'dict': "override"},
                          #'INVOKE_DEFAULT',
                          False,            # undo support
                          animation=True,
                          write_still=True
                         )
