-
Notifications
You must be signed in to change notification settings - Fork 1
/
poseSymUI.py
97 lines (72 loc) · 3.55 KB
/
poseSymUI.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
from baseMelUI import *
from filesystem import Path
import maya.cmds as cmd
import poseSym
import os
LabelledIconButton = labelledUIClassFactory( MelIconButton )
class PoseSymLayout(MelVSingleStretchLayout):
ICONS = ICON_SWAP, ICON_MIRROR, ICON_MATCH = 'poseSym_swap.xpm', 'poseSym_mirror.xpm', 'poseSym_match.xpm'
def __init__( self, parent ):
self.UI_swap = swap = LabelledIconButton( self, llabel='swap pose', llabelWidth=65, llabelAlign='right', c=self.on_swap )
swap.setImage( self.ICON_SWAP )
self.UI_mirror = mirror = LabelledIconButton( self, llabel='mirror pose', llabelWidth=65, llabelAlign='right', c=self.on_mirror )
mirror.setImage( self.ICON_MATCH )
#self.UI_match = match = LabelledIconButton( self, llabel='match pose', llabelWidth=65, llabelAlign='right', c=self.on_match )
#match.setImage( self.ICON_MATCH )
spacer = MelSpacer( self )
hLayout = MelHLayout( self )
MelLabel( hLayout, l='mirror: ' )
self.UI_mirror_t = MelCheckBox( hLayout, l='translate', v=1 )
self.UI_mirror_r = MelCheckBox( hLayout, l='rotate', v=1 )
self.UI_mirror_other = MelCheckBox( hLayout, l='other', v=1 )
hLayout.layout()
self.setStretchWidget( spacer )
self.layout()
### EVENT HANDLERS ###
def on_swap( self, *a ):
for pair, obj in poseSym.iterPairAndObj( cmd.ls( sl=True ) ):
pair.swap( t=self.UI_mirror_t.getValue(), r=self.UI_mirror_r.getValue(), other=self.UI_mirror_other.getValue() )
def on_mirror( self, *a ):
for pair, obj in poseSym.iterPairAndObj( cmd.ls( sl=True ) ):
pair.mirror( obj==pair.controlA, t=self.UI_mirror_t.getValue(), r=self.UI_mirror_r.getValue(), other=self.UI_mirror_other.getValue() )
def on_match( self, *a ):
for pair, obj in poseSym.iterPairAndObj( cmd.ls( sl=True ) ):
pair.match( obj==pair.controlA, t=self.UI_mirror_t.getValue(), r=self.UI_mirror_r.getValue(), other=self.UI_mirror_other.getValue() )
class PoseSymWindow(BaseMelWindow):
WINDOW_NAME = 'PoseSymTool'
WINDOW_TITLE = 'Pose Symmetry Tool'
DEFAULT_SIZE = 280, 200
DEFAULT_MENU = 'Setup'
HELP_MENU = WINDOW_NAME, 'hamish@valvesoftware.com', 'https://intranet.valvesoftware.com/wiki/index.php/Pose_Mirror_Tool'
FORCE_DEFAULT_SIZE = True
def __init__( self ):
self.editor = PoseSymLayout( self )
self.setupMenu()
self.show()
def setupMenu( self ):
menu = self.getMenu( 'Setup' )
menu.clear()
MelMenuItem( menu, l='Create Paired Mirror', ann='Will put the two selected objects into a "paired" relationship - they will know how to mirror/exchange poses with one another', c=self.on_setupPair )
MelMenuItem( menu, l='Create Single Mirror For Selected', ann='Will setup each selected control with a mirror node so it knows how to mirror poses on itself', c=self.on_setupSingle )
MelMenuItemDiv( menu )
MelMenuItem( menu, l='Auto Setup Skeleton Builder', ann='Tries to determine mirroring relationships from skeleton builder', c=self.on_setupSingle )
### EVENT HANDLERS ###
def on_setupPair( self, *a ):
sel = cmd.ls( sl=True, type='transform' )
if len( sel ) == 1:
pair = poseSym.ControlPair.Create( sel[0] )
cmd.select( pair.node )
elif len( sel ) >= 2:
pair = poseSym.ControlPair.Create( sel[0], sel[1] )
cmd.select( pair.node )
def on_setupSingle( self, *a ):
sel = cmd.ls( sl=True, type='transform' )
nodes = []
for s in sel:
pair = poseSym.ControlPair.Create( s )
nodes.append( pair.node )
cmd.select( nodes )
def on_setupSkeletonBuilder( self, *a ):
import rigPrimitives
rigPrimitives.setupMirroring()
#end