| 1 |
""" |
| 2 |
Render animation in 8 rotations |
| 3 |
adapted from http://clintbellanger.net/articles/isometric_tiles/ |
| 4 |
|
| 5 |
Args: |
| 6 |
- layer |
| 7 |
- action |
| 8 |
- frames |
| 9 |
- name |
| 10 |
""" |
| 11 |
import bpy |
| 12 |
import sys |
| 13 |
from math import radians |
| 14 |
|
| 15 |
C = bpy.context |
| 16 |
D = bpy.data |
| 17 |
|
| 18 |
argv = sys.argv[sys.argv.index("--") + 1:] |
| 19 |
collections = argv[0].split(',') |
| 20 |
action = argv[1] |
| 21 |
frames = int(argv[2]) |
| 22 |
name = '{}_{}'.format(argv[3], action) |
| 23 |
|
| 24 |
RESOLUTION = 32 |
| 25 |
FRAME_SKIP = 10 |
| 26 |
|
| 27 |
angle = -45 |
| 28 |
axis = 2 |
| 29 |
platform = D.objects["armature"] |
| 30 |
scene = D.scenes[0] |
| 31 |
|
| 32 |
scene.camera.data.ortho_scale = RESOLUTION |
| 33 |
try: |
| 34 |
platform.animation_data.action = D.actions[action] |
| 35 |
except KeyError: |
| 36 |
print(f"action {action} not found") |
| 37 |
sys.exit(1) |
| 38 |
|
| 39 |
for collection in D.collections.keys(): |
| 40 |
D.collections[collection].hide_render = collection not in collections |
| 41 |
|
| 42 |
render = scene.render |
| 43 |
render.image_settings.file_format = 'PNG' |
| 44 |
render.image_settings.color_mode ='RGBA' |
| 45 |
render.resolution_x = RESOLUTION |
| 46 |
render.resolution_y = RESOLUTION |
| 47 |
render.frame_map_new = 100 // FRAME_SKIP |
| 48 |
render.engine = 'BLENDER_EEVEE_NEXT' |
| 49 |
render.film_transparent = True |
| 50 |
scene.frame_end = (frames - 1) // FRAME_SKIP |
| 51 |
original_path = 'out/{}##'.format(name) |
| 52 |
path = 'out/{}_{}_##' |
| 53 |
platform.rotation_euler[axis] = 0 |
| 54 |
for i in range(0, 8): |
| 55 |
|
| 56 |
platform.rotation_euler[axis] = radians(angle) * (i + 1) |
| 57 |
|
| 58 |
render.filepath = path.format(name, (i + 6) % 8) |
| 59 |
|
| 60 |
bpy.ops.render.render(animation=True) |
| 61 |
|
| 62 |
platform.rotation_euler[axis] = 0 |