-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathui.py
309 lines (258 loc) · 12.1 KB
/
ui.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
#====================== BEGIN GPL LICENSE BLOCK ======================
#
# 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 2
# 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
# MERCHANTABILITY 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, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#======================= END GPL LICENSE BLOCK ========================
import bpy
from .bind_animation import *
from .keyframing import *
from .fkik import *
from _sqlite3 import Row
from .utils import isArmName, isLegName
class VIEW3D_PT_meta_bvh(bpy.types.Panel):
bl_label = "Metarig to BVH"
bl_space_type = "VIEW_3D"
bl_region_type = "TOOLS"
#bl_options = {'DEFAULT_CLOSED'}
bl_category = 'Mocanim'
def draw(self, context):
layout = self.layout
scn=context.scene
row = layout.row(align = True)
row.operator('mocanim.create_metarig',text = 'Create Mocanim Metarig', icon = 'POSE_DATA')
row = layout.row(align=True)
row.operator('mocanim.export_metarig',text='Export Metarig to BVH', icon = 'EXPORT')
row = layout.row(align=True)
row.prop(scn, "MocanimExportPath")
#row.operator('mocanim.export_path', text='', icon = 'FILESEL')
class VIEW3D_PT_bind_animation(bpy.types.Panel):
bl_label = "Create Constraints"
bl_space_type = "VIEW_3D"
bl_region_type = "TOOLS"
#bl_options = {'DEFAULT_CLOSED'}
bl_category = 'Mocanim'
def draw(self,context):
layout = self.layout
scn=context.scene
col = layout.column(align = True)
col.label(text = "Performer Rig:")
row = layout.row(align = True)
row.prop(scn, 'MocanimSrcRig', text = '', icon = 'ARMATURE_DATA')
row.operator('mocanim.select_source', text = '', icon = 'CURSOR')
col = layout.column(align = True)
col.label(text = "Character Rig:")
row = layout.row(align = True)
row.prop(scn, 'MocanimTrgRig', text = '', icon = 'ARMATURE_DATA')
row.operator('mocanim.select_target', text = '', icon = 'CURSOR')
col = layout.column(align=True)
col.separator()
layout.label('Constraints:')
row = layout.row(align = True)
row.operator('mocanim.create_constraints', text = 'Create/Update', icon = 'SNAP_ON')
row.operator('mocanim.delete_constraints', text = 'Delete', icon = 'SNAP_OFF')
row = layout.row(align = True)
row.operator('mocanim.enable_constraints', text = 'Enable all', icon = 'RESTRICT_VIEW_OFF')
row.operator('mocanim.disable_constraints', text = 'Disable all', icon = 'RESTRICT_VIEW_ON')
#layout.label('Advanced Options')
layout.prop(scn, "MocanimAdvOptions")
layout.separator()
if scn.MocanimAdvOptions:
layout.prop(scn, "MocanimConstrainRoot")
layout.prop(scn, "MocanimConstrainSpine")
if scn.MocanimConstrainSpine:
row = layout.row(align = True)
row.prop(scn, "MocanimConstrainHips")
row.prop(scn, "MocanimFollowThigh")
layout.prop(scn, "MocanimConstrainTorso")
layout.prop(scn, "MocanimConstrainChest")
layout.prop(scn, "MocanimConstrainArms")
layout.prop(scn, "MocanimConstrainLegs")
layout.prop(scn, 'MocanimUseLimits')
class VIEW3D_PT_constraint_limits(bpy.types.Panel):
bl_label = "Constraint Limits"
bl_space_type = "VIEW_3D"
bl_region_type = "TOOLS"
bl_options = {'DEFAULT_CLOSED'}
bl_category = 'Mocanim'
@classmethod
def poll(cls,context):
if context.object and context.object.type == 'ARMATURE':
return True
def draw(self, context):
scn = context.scene
rig = bpy.data.objects[scn.MocanimTrgRig]
#pbones = [pb for pb in rig.pose.bones if pb.bone.select == True]
pbones = rig.pose.bones
layout = self.layout
armbox = layout.box()
armbox.label(text='ARMS Constraint Limits')
legbox = layout.box()
legbox.label(text='LEGS Constraint Limits')
othersbox = layout.box()
othersbox.label(text='SPINE Constraint Limits')
if rig.mode == 'POSE':
for pb in pbones:
for cns in pb.constraints:
if isArmName(pb.name):
box = armbox
elif isLegName(pb.name):
box = legbox
else:
box = othersbox
if ('ik' in cns.type.lower()):
box = box.box()
row = box.row(align=True)
row.label(pb.name + ': ' + cns.name)
row.prop(cns, 'pole_angle')
row = box.row(align=False)
row.separator()
if ('limit' in cns.type.lower()) and ('-mcn' in cns.name):
# box = layout.box()
box = box.box()
row = box.row(align=True)
row.label(pb.name + ': ' + cns.name)
#row.prop(cns, 'mute')
if cns.mute:
row.prop(cns, 'mute', icon='VISIBLE_IPO_OFF', emboss= False, icon_only=True)
else:
row.prop(cns, 'mute', icon='VISIBLE_IPO_ON', emboss=False, icon_only=True)
if 'Rotation' in cns.name:
row = box.row(align=False)
col = row.column(align=True)
col.prop(cns, 'use_limit_x')
col.prop(cns, 'min_x', text='Min')
col.prop(cns, 'max_x', text='Max')
col = row.column(align=True)
col.prop(cns, 'use_limit_y')
col.prop(cns, 'min_y',text='Min')
col.prop(cns, 'max_y', text='Max')
col = row.column(align = True)
col.prop(cns, 'use_limit_z')
col.prop(cns, 'min_z',text='Min')
col.prop(cns, 'max_z', text='Max')
elif 'Location' in cns.name:
col = box.column(align=True)
col.prop(cns, 'use_min_z')
col.prop(cns, 'min_z',text='')
col.prop(cns, 'use_transform_limit')
row = box.row(align=False)
row.separator()
if ('damped' in cns.type.lower()) and ('-mcn' in cns.name) and ('spine_target' in cns.subtarget):
box = box.box()
row = box.row(align=True)
row.label(pb.name + ': ' + cns.name)
row.prop(cns, 'head_tail')
class VIEW3D_PT_keyframing(bpy.types.Panel):
bl_label = "Keyframing"
bl_space_type = "VIEW_3D"
bl_region_type = "TOOLS"
bl_options = {'DEFAULT_CLOSED'}
bl_category = 'Mocanim'
@classmethod
def poll(cls,context):
if context.object and context.object.type == 'ARMATURE':
return True
def draw(self,context):
layout = self.layout
scn = context.scene
row = layout.row(align=True)
row.prop(scn, "MocanimOnlySelected")
#row.prop(scn, "MocanimForceInsert")
#row = layout.row(align=True)
row.prop(scn, "MocanimKeepConstraints")
row = layout.row(align=True)
row.prop(scn,"MocanimNewAction")
row = layout.row(align=True)
row.operator("mocanim.keep_pose", icon='KEY_HLT')
row.operator("mocanim.clear_pose", icon='KEY_DEHLT')
row = layout.row(align=True)
row.operator("mocanim.keep_action", icon='ACTION_TWEAK')
row.operator("mocanim.clear_action", icon='CANCEL')
row = layout.row(align=True)
row.operator("mocanim.update_action", icon='FILE_REFRESH')
row = layout.row(align=True)
row.prop(scn,"MocanimStartFrame")
row.prop(scn,"MocanimEndFrame")
row.operator("mocanim.get_frame_range", icon='TIME', text='')
row = layout.row(align=True)
row.prop(scn,"MocanimFrameStep")
class VIEW3D_PT_transfer_animation(bpy.types.Panel):
bl_label = "Transfer Animation"
bl_space_type = "VIEW_3D"
bl_region_type = "TOOLS"
bl_options = {'DEFAULT_CLOSED'}
bl_category = 'Mocanim'
@classmethod
def poll(cls,context):
if context.object and context.object.type == 'ARMATURE':
return True
def draw(self,context):
layout = self.layout
scn = context.scene
row = layout.row(align=True)
row.prop(scn, "MocanimTransferOnlySelected")
row = layout.row(align=True)
row.operator("mocanim.ik2fk", text='IK2FK Pose', icon = 'SNAP_ON')
row.operator("mocanim.fk2ik", text='FK2IK Pose', icon = 'SNAP_ON')
row = layout.row(align=True)
row.operator("mocanim.transfer_fk_to_ik", text='IK2FK Action', icon = 'ACTION_TWEAK')
row.operator("mocanim.transfer_ik_to_fk", text='FK2IK Action', icon = 'ACTION_TWEAK')
row = layout.row(align=True)
row.operator("mocanim.clear_animation", text="Clear IK Action", icon = 'CANCEL').type = "IK"
row.operator("mocanim.clear_animation", text="Clear FK Action", icon = 'CANCEL').type = "FK"
row = layout.row(align=True)
row.prop(scn, 'MocanimTransferStartFrame')
row.prop(scn, 'MocanimTransferEndFrame')
row.operator("mocanim.get_transfer_frame_range", icon='TIME', text='')
# if not scn.MocanimTransferOnlySelected:
# row = layout.row(align=True)
# row.prop(scn, "MocanimFkIkArms")
# row.prop(scn, "MocanimFkIkLegs")
class VIEW3D_PT_fk_ik(bpy.types.Panel):
bl_label = "FK/IK"
bl_space_type = "VIEW_3D"
bl_region_type = "TOOLS"
bl_options = {'DEFAULT_CLOSED'}
bl_category = 'Mocanim'
@classmethod
def poll(cls, context):
if context.object and context.object.type == 'ARMATURE':
return True
def draw(self,context):
layout = self.layout
scn = context.scene
rig = context.object
#CHECK IF rig is Pitchipoy
layout.label('Use IK')
row = layout.row(align=True)
row.prop(scn, "MocanimArmsIk")
row = layout.row(align=True)
row.prop(scn, "MocanimLegsIk")
row = layout.row(align=True)
row.operator("mocanim.limb_switch", icon = "FILE_REFRESH")
def register():
bpy.utils.register_class(VIEW3D_PT_meta_bvh)
bpy.utils.register_class(VIEW3D_PT_bind_animation)
bpy.utils.register_class(VIEW3D_PT_constraint_limits)
bpy.utils.register_class(VIEW3D_PT_keyframing)
bpy.utils.register_class(VIEW3D_PT_transfer_animation)
bpy.utils.register_class(VIEW3D_PT_fk_ik)
def unregister():
bpy.utils.unregister_class(VIEW3D_PT_meta_bvh)
bpy.utils.unregister_class(VIEW3D_PT_bind_animation)
bpy.utils.unregister_class(VIEW3D_PT_constraint_limits)
bpy.utils.unregister_class(VIEW3D_PT_keyframing)
bpy.utils.unregister_class(VIEW3D_PT_transfer_animation)
bpy.utils.unregister_class(VIEW3D_PT_fk_ik)