-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
31f6a61
commit fc24231
Showing
4 changed files
with
163 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation; either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, but | ||
# WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTIBILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
# General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
bl_info = { | ||
"name" : "pose-thumbnail-exporter", | ||
"author" : "eatdesignlove", | ||
"description" : "add-on for pose's thumbnail exporting", | ||
"blender" : (3, 2, 2), | ||
"version" : (0, 0, 1), | ||
"warning" : "", | ||
"category" : "Animation" | ||
} | ||
|
||
import bpy | ||
|
||
from . ptx_op import PTX_OT_Export_All_Pose_Op, PTX_OT_Change_Posemode_OP | ||
from . ptx_pnl import PTX_PT_Panel | ||
|
||
classes = (PTX_OT_Change_Posemode_OP, PTX_OT_Export_All_Pose_Op, PTX_PT_Panel) | ||
|
||
def register(): | ||
for c in classes: | ||
bpy.utils.register_class(c) | ||
|
||
bpy.types.Scene.directory = bpy.props.StringProperty(subtype='DIR_PATH') | ||
|
||
def unregister(): | ||
for c in classes: | ||
bpy.utils.unregister_class(c) | ||
|
||
del(bpy.types.Scene.directory) | ||
|
||
if __name__ == "__main__": | ||
register() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"folders": [ | ||
{ | ||
"path": "." | ||
} | ||
], | ||
"settings": {} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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'} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import bpy | ||
from bpy.types import Panel | ||
|
||
from .lib.easybpy import * | ||
|
||
class PTX_PT_Panel(Panel): | ||
bl_space_type = "VIEW_3D" #패널이 보여지는 화면모드 | ||
bl_region_type = "UI" | ||
bl_label = "Pose thumbnail exporter" #패널 상단 라벨 | ||
bl_category = "pose.tools" #사이드바 패널명 | ||
|
||
@classmethod | ||
def poll(cls, context): | ||
return bool( | ||
context.mode in {'OBJECT','EDIT_MESH', 'EDIT_ARMATURE','POSE'} | ||
and get_scene().clone_props.files_loaded | ||
) | ||
|
||
def draw(self, context): | ||
layout = self.layout | ||
|
||
if context.mode == 'POSE': | ||
row = layout.row().label(text="Output Path") | ||
self.layout.prop(context.scene, "directory") | ||
|
||
row = layout.row() | ||
row.scale_y = 1.5 | ||
row.operator("object.export_all_pose", text ="Export Pose Thumnails") | ||
|
||
else: | ||
row = layout.row() | ||
row.scale_y = 1.5 | ||
row.operator( | ||
"object.change_posemode", | ||
text="Switch to Pose Mode", | ||
depress=True, icon='POSE_HLT' | ||
) |