Last active
November 5, 2015 20:58
-
-
Save TurBoss/07450cc775d9892ebd7d to your computer and use it in GitHub Desktop.
Rotate Models for spritify ( requires spritify)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
import os | |
import math | |
angle = 45 | |
tx = 10.0 | |
ty = -10.0 | |
tz = 10.0 | |
rx = 60.0 | |
ry = 0.0 | |
rz = 45.0 | |
fov = 50.0 | |
pi = 3.14159265 | |
scene = bpy.data.scenes["Scene"] | |
obj_scene = bpy.context.scene | |
# Set render resolution | |
scene.render.resolution_x = 64 | |
scene.render.resolution_y = 64 | |
# Set camera fov in degrees | |
scene.camera.data.angle = fov*(pi/180.0) | |
# Set camera rotation in euler angles | |
scene.camera.rotation_mode = 'XYZ' | |
scene.camera.rotation_euler[0] = rx*(pi/180.0) | |
scene.camera.rotation_euler[1] = ry*(pi/180.0) | |
scene.camera.rotation_euler[2] = rz*(pi/180.0) | |
# Set camera translation | |
scene.camera.location.x = tx | |
scene.camera.location.y = ty | |
scene.camera.location.z = tz | |
bpy.ops.object.select_by_type(type="MESH") | |
bpy.ops.object.select_by_type(type="ARMATURE") | |
bpy.ops.object.select_by_type(type="EMPTY") | |
output_path = bpy.context.scene.render.filepath | |
for i in range(8): | |
bpy.context.scene.objects.active.rotation_euler[2] = math.radians(i*angle) | |
bpy.context.scene.render.filepath = os.path.join(output_path, str(i) + "-") | |
bpy.ops.render.render(animation=True) | |
bpy.context.scene.render.filepath = output_path | |
bpy.ops.render.spritify() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment