#!/usr/bin/env python3 # -*- coding: utf-8 -*- import bpy import os import sys from math import * # ************************************************************ # LECTURA DE DATOS ruta = sys.argv[5] imagenNum = sys.argv[6] w = int(sys.argv[7]) h = int(sys.argv[8]) celdas_propuestas = int(sys.argv[9]) render = sys.argv[10] # ************************************************************ if (render == 'True'): renderizar = True elif (render == 'False'): renderizar = False print(renderizar) # ************************************************************ # Cálculo de las posiciones de xMin, xMax, yMin, yMax como arrays. X = sqrt(w * h) nx = sqrt(celdas_propuestas) x = X / nx xw = x / w xh = x / h xMin = [] xMax = [] suma = 0.0 while (suma < 1.0): xMin.append(suma) suma += xw if (suma > 1.0): suma = 1.0 xMax.append(suma) yMin = [] yMax = [] suma = 0.0 while (suma < 1.0): yMin.append(suma) suma += xh if (suma > 1.0): suma = 1.0 yMax.append(suma) print('Tamaño del render: {0} px de ancho por {1} px de alto'.format(w, h)) print('Ancho de celda cuadrada: {0:.0f} px'.format(x)) print('Celdas a lo ancho: {0:.2f} ({1})'.format(w / x, ceil(w / x))) print('Celdas a lo alto: {0:.2f} ({1})'.format(h / x, ceil(h / x))) print('Total de celdas (completas o incompletas): {0}\n'.format(len(xMin) * len(yMin))) # ************************************************************ # ************************************************************ # PROCESO DE RENDERIZADO if (renderizar == True): print('Renderizando . . .') # bpy.context.scene.render.use_border = True bpy.context.scene.render.use_crop_to_border = True tile = 0 for i in range(len(xMin)): bpy.data.scenes['Scene'].render.border_min_x = xMin[i] bpy.data.scenes['Scene'].render.border_max_x = xMax[i] for j in range(len(yMin)): bpy.context.scene.render.filepath = os.path.join(ruta, (imagenNum % (tile+1))) bpy.data.scenes['Scene'].render.border_min_y = yMin[j] bpy.data.scenes['Scene'].render.border_max_y = yMax[j] print('\n\nRenderizando celda {0} de {1}: columna {2} de {3}, fila {4} de {5}'.format( tile+1, len(xMin) * len(yMin), i+1, len(xMin), j+1, len(yMin))) bpy.ops.render.render(write_still = True) tile += 1 # ************************************************************