-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathptx_op.py
74 lines (59 loc) · 2.26 KB
/
ptx_op.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import bpy
import os
from bpy.types import (
Operator,
)
class PTX_OT_Change_Posemode_OP(Operator):
bl_idname = "object.change_posemode"
bl_label = "Change posemode"
bl_description = "Change current mode to posemode"
@classmethod
def poll(cls, context):
current_mode = bpy.context.object.mode
if current_mode == "POSE":
return False
return True
def execute(self, context):
bpy.ops.object.mode_set(mode='POSE')
return {'FINISHED'}
class PTX_OT_Export_All_Pose_Op(Operator):
bl_idname = "object.export_all_pose"
bl_label = "Export All Pose thumbnail"
bl_description = "Export all Pose thumbnail"
@classmethod
def poll(cls, context):
current_mode = bpy.context.object.mode
if current_mode == "POSE":
return True
return False
def execute(self, context):
# armature 오브젝트 찾기
for obj in bpy.data.objects:
target = obj.find_armature()
if target is not None:
armatureObj = target
# skybox 렌더 제외
if obj.name == "skybox":
obj.hide_render=True
# 포즈 개수 배열
actionsLength = len(bpy.data.actions)
armatureObj.animation_data_create()
# 렌더 세팅 설정하기
bpy.context.scene.frame_start = 0
bpy.context.scene.frame_end = actionsLength
bpy.context.scene.render.engine = 'BLENDER_WORKBENCH'
bpy.context.scene.render.resolution_x = 768
bpy.context.scene.render.resolution_y = 768
filename = bpy.path.basename(bpy.data.filepath)
print(filename)
print(bpy.context.scene.directory, ':::bpy.types.Scene.directory:::')
for idx in range(actionsLength):
# 키프레임 이동
bpy.context.scene.frame_set(idx)
action = bpy.data.actions[idx]
# 포즈 적용
armatureObj.animation_data.action = action
bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
bpy.context.scene.render.filepath = os.path.join(bpy.context.scene.directory, ('pose_thumb_%d.jpg' % idx))
bpy.ops.render.render(write_still = True)
return {'FINISHED'}