-
Notifications
You must be signed in to change notification settings - Fork 10
/
skeletonPart_leg.py
124 lines (93 loc) · 3.53 KB
/
skeletonPart_leg.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
from baseSkeletonBuilder import *
class Leg(SkeletonPart):
HAS_PARITY = True
PLACER_NAMES = 'footTip', 'footInner', 'footOuter', 'heel'
@property
def thigh( self ): return self[ 0 ]
@property
def knee( self ): return self[ 1 ]
@property
def ankle( self ): return self[ 2 ]
@property
def toe( self ): return self[ 3 ] if len( self ) > 3 else None
@classmethod
def _build( cls, parent=None, buildToe=True, toeCount=0, **kw ):
idx = Parity( kw[ 'idx' ] )
partScale = kw[ 'partScale' ]
parent = getParent( parent )
root = getRoot()
height = xform( root, q=True, ws=True, rp=True )[ 1 ]
dirMult = idx.asMultiplier()
parityName = idx.asName()
sidePos = dirMult * partScale / 10.0
upPos = partScale / 20.0
fwdPos = -(idx / 2) * partScale / 5.0
footHeight = height / 15.0 if buildToe else 0
kneeOutMove = dirMult * partScale / 35.0
kneeFwdMove = partScale / 20.0
thigh = createJoint( 'thigh%s' % parityName )
cmd.parent( thigh, parent, relative=True )
move( sidePos, -upPos, fwdPos, thigh, r=True, ws=True )
knee = createJoint( 'knee%s' % parityName )
cmd.parent( knee, thigh, relative=True )
move( 0, -(height - footHeight) / 2.0, kneeFwdMove, knee, r=True, ws=True )
ankle = createJoint( 'ankle%s' % parityName )
cmd.parent( ankle, knee, relative=True )
move( 0, -(height - footHeight) / 2.0, -kneeFwdMove, ankle, r=True, ws=True )
jointSize( thigh, 2 )
jointSize( ankle, 2 )
allJoints = []
if buildToe:
toe = createJoint( 'toeBase%s' % parityName )
cmd.parent( toe, ankle, relative=True )
move( 0, -footHeight, footHeight * 3, toe, r=True, ws=True )
allJoints.append( toe )
jointSize( toe, 1.5 )
for n in range( toeCount ):
toeN = createJoint( 'toe_%d_%s' % (n, parityName) )
allJoints.append( toeN )
#move( dirMult * partScale / 50.0, 0, partScale / 25.0, toeN, ws=True )
cmd.parent( toeN, toe, relative=True )
rotate( 0, dirMult * 15, 0, thigh, r=True, ws=True )
return [ thigh, knee, ankle ] + allJoints
def _buildPlacers( self ):
placers = []
scale = getItemScale( self.ankle )
p = buildEndPlacer()
p = parent( p, self.toe, r=True )[0]
move( 0, 0, scale/3, p, r=True )
move( 0, 0, 0, p, moveY=True, a=True, ws=True )
placers.append( p )
p = buildEndPlacer()
p = parent( p, self.ankle, r=True )[0]
setAttr( '%s.ty' % p, -scale/1.5 )
move( 0, 0, 0, p, moveY=True, a=True, ws=True )
placers.append( p )
p = buildEndPlacer()
p = parent( p, self.ankle, r=True )[0]
setAttr( '%s.ty' % p, scale/1.5 )
move( 0, 0, 0, p, moveY=True, a=True, ws=True )
placers.append( p )
p = buildEndPlacer()
p = parent( p, self.ankle, r=True )[0]
move( 0, 0, -scale/3, p, r=True )
move( 0, 0, 0, p, moveY=True, a=True, ws=True )
placers.append( p )
return placers
def _align( self, _initialAlign=False ):
normal = getPlaneNormalForObjects( self.thigh, self.knee, self.ankle )
normal *= self.getParityMultiplier()
parity = self.getParity()
alignAimAtItem( self.thigh, self.knee, parity, worldUpVector=normal )
alignAimAtItem( self.knee, self.ankle, parity, worldUpVector=normal )
if self.toe:
alignAimAtItem( self.ankle, self.toe, parity, upVector=ENGINE_UP, upType='scene' )
else:
autoAlignItem( self.ankle, parity, upVector=ENGINE_UP, upType='scene' )
for i in self.getOrphanJoints():
alignItemToLocal( i )
def visualize( self ):
pass
def getIkFkItems( self ):
return self.thigh, self.knee, self.ankle
#end