forked from Mwni/blender-animation-retargeting
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcorrections.py
75 lines (52 loc) · 2.02 KB
/
corrections.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
75
import bpy
from .utilfuncs import *
def draw_panel(layout):
s = state()
layout.prop(s, 'correct_root_pivot', text='Correct Root Pivot')
if s.correct_root_pivot:
layout.box().prop_search(s, 'root_bone', s.get_target_armature(), 'bones', text='Root Bone', icon='BONE_DATA')
layout.prop(s, 'correct_feet', text='Correct Feet Position')
if s.correct_feet:
row = layout.box().row()
draw_limb_section(row.column(), 'Left Foot', 'Left Thigh', s, s.get_ik_limb('left-foot'))
draw_limb_section(row.column(), 'Right Foot', 'Right Thigh', s, s.get_ik_limb('right-foot'))
layout.prop(s, 'correct_hands', text='Correct Hands Position')
if s.correct_hands:
row = layout.box().row()
draw_limb_section(row.column(), 'Left Hand', 'Left Upper Arm', s, s.get_ik_limb('left-hand'))
draw_limb_section(row.column(), 'Right Hand', 'Right Upper Arm', s, s.get_ik_limb('right-hand'))
def draw_limb_section(layout, target_label, origin_label, s, prop):
layout.label(text=origin_label)
layout.prop_search(prop, 'origin_bone', s.get_target_armature(), 'bones', text='', icon='BONE_DATA')
layout.label(text=target_label)
layout.prop_search(prop, 'target_bone', s.get_target_armature(), 'bones', text='', icon='BONE_DATA')
class TransferOperator(bpy.types.Operator):
bl_idname = 'retarget_anim.transfer'
bl_label = 'Transfer Animation'
def execute(self, context):
return {'FINISHED'}
class AddIKOperator(bpy.types.Operator):
bl_idname = 'retarget_corrections.add_ik'
bl_label = 'Add'
def execute(self, context):
s = state()
limb = s.ik_limbs.add()
return {'FINISHED'}
class RemoveIKOperator(bpy.types.Operator):
bl_idname = 'retarget_corrections.remove_ik'
bl_label = 'Remove'
index: bpy.props.IntProperty()
def execute(self, context):
state().ik_limbs.clear()
return {'FINISHED'}
class ApplyIKOperator(bpy.types.Operator):
bl_idname = 'retarget_corrections.apply_ik'
bl_label = 'Apply'
def execute(self, context):
state().build_ik()
return {'FINISHED'}
classes = (
AddIKOperator,
RemoveIKOperator,
ApplyIKOperator
)