-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathskeletonPart_quadrupedLimbs.py
191 lines (137 loc) · 5.96 KB
/
skeletonPart_quadrupedLimbs.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
from baseSkeletonBuilder import *
class _QuadCommon(object):
AVAILABLE_IN_UI = False
def _buildPlacers( self ):
assert isinstance( self, SkeletonPart )
parity = self.getParity()
parityMultiplier = parity.asMultiplier()
scale = self.getBuildScale() / 30
toeTipPlacer = buildEndPlacer()
heelPlacer = buildEndPlacer()
innerRollPlacer = buildEndPlacer()
outerRollPlacer = buildEndPlacer()
placers = toeTipPlacer, heelPlacer, innerRollPlacer, outerRollPlacer
cmd.parent( placers, self.end, r=True )
fwd = MAYA_SIDE
side = MAYA_UP
setAttr( '%s.t' % toeTipPlacer, *(fwd * 2 * scale) )
setAttr( '%s.t' % heelPlacer, *(-fwd * scale) )
setAttr( '%s.t' % innerRollPlacer, *(side * scale * parityMultiplier) )
setAttr( '%s.t' % outerRollPlacer, *(-side * scale * parityMultiplier) )
return placers
def visualize( self ):
pass
class QuadrupedFrontLeg(_QuadCommon, SkeletonPart.GetNamedSubclass('Arm')):
'''
A quadruped's front leg is more like a biped's arm as it has clavicle/shoulder
blade functionality, but is generally positioned more like a leg. It is a separate
part because it is rigged quite differently from either a bipedal arm or a bipedal
leg.
'''
AVAILABLE_IN_UI = True
PLACER_NAMES = 'toeTip', 'innerRoll', 'outerRoll', 'heelRoll'
@classmethod
def _build( cls, parent=None, **kw ):
idx = Parity( kw[ 'idx' ] )
partScale = kw[ 'partScale' ]
parent = getParent( parent )
height = xform( parent, q=True, ws=True, rp=True )[ 1 ]
dirMult = idx.asMultiplier()
parityName = idx.asName()
clavicle = createJoint( 'quadClavicle%s' % parityName )
cmd.parent( clavicle, parent, relative=True )
move( dirMult * partScale / 10.0, -partScale / 10.0, partScale / 6.0, clavicle, r=True, ws=True )
bicep = createJoint( 'quadHumerous%s' % parityName )
cmd.parent( bicep, clavicle, relative=True )
move( 0, -height / 3.0, -height / 6.0, bicep, r=True, ws=True )
elbow = createJoint( 'quadElbow%s' % parityName )
cmd.parent( elbow, bicep, relative=True )
move( 0, -height / 3.0, height / 10.0, elbow, r=True, ws=True )
wrist = createJoint( 'quadWrist%s' % parityName )
cmd.parent( wrist, elbow, relative=True )
move( 0, -height / 3.0, 0, wrist, r=True, ws=True )
jointSize( clavicle, 2 )
jointSize( wrist, 2 )
return [ clavicle, bicep, elbow, wrist ]
class QuadrupedBackLeg(_QuadCommon, SkeletonPart.GetNamedSubclass( 'Arm' )):
'''
The creature's back leg is more like a biped's leg in terms of the joints it contains.
However, like the front leg, the creature stands on his "tip toes" at the back as well.
'''
AVAILABLE_IN_UI = False
@classmethod
def _build( cls, parent=None, **kw ):
idx = Parity( kw[ 'idx' ] )
partScale = kw[ 'partScale' ]
parent = getParent( parent )
height = xform( parent, q=True, ws=True, rp=True )[ 1 ]
dirMult = idx.asMultiplier()
parityName = idx.asName()
kneeFwdMove = height / 10.0
thigh = createJoint( 'quadThigh%s' % parityName )
thigh = cmd.parent( thigh, parent, relative=True )[ 0 ]
move( dirMult * partScale / 10.0, -partScale / 10.0, -partScale / 5.0, thigh, r=True, ws=True )
knee = createJoint( 'quadKnee%s' % parityName )
knee = cmd.parent( knee, thigh, relative=True )[ 0 ]
move( 0, -height / 3.0, kneeFwdMove, knee, r=True, ws=True )
ankle = createJoint( 'quadAnkle%s' % parityName )
ankle = cmd.parent( ankle, knee, relative=True )[ 0 ]
move( 0, -height / 3.0, -kneeFwdMove, ankle, r=True, ws=True )
toe = createJoint( 'quadToe%s' % parityName )
toe = cmd.parent( toe, ankle, relative=True )[ 0 ]
move( 0, -height / 3.0, 0, toe, r=True, ws=True )
jointSize( thigh, 2 )
jointSize( ankle, 2 )
jointSize( toe, 1.5 )
return [ thigh, knee, ankle, toe ]
class SatyrLeg(_QuadCommon, SkeletonPart.GetNamedSubclass('Leg')):
AVAILABLE_IN_UI = True
PLACER_NAMES = QuadrupedFrontLeg.PLACER_NAMES
@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, **kw ):
idx = Parity( kw[ 'idx' ] )
partScale = kw[ 'partScale' ]
parent = getParent( parent )
height = xform( parent, q=True, ws=True, rp=True )[ 1 ]
dirMult = idx.asMultiplier()
parityName = idx.asName()
legDrop = partScale / 12.0
sectionDist = (height - legDrop) / 3.0
kneeFwdMove = (height - legDrop) / 3.0
thigh = createJoint( 'thigh%s' % parityName )
thigh = cmd.parent( thigh, parent, relative=True )[ 0 ]
move( dirMult * partScale / 10.0, -legDrop, 0, thigh, r=True, ws=True )
knee = createJoint( 'knee%s' % parityName )
knee = cmd.parent( knee, thigh, relative=True )[ 0 ]
move( 0, -sectionDist, kneeFwdMove, knee, r=True, ws=True )
ankle = createJoint( 'ankle%s' % parityName )
ankle = cmd.parent( ankle, knee, relative=True )[ 0 ]
move( 0, -sectionDist, -kneeFwdMove, ankle, r=True, ws=True )
toe = createJoint( 'toeBall%s' % parityName )
toe = cmd.parent( toe, ankle, relative=True )[ 0 ]
move( 0, -sectionDist, kneeFwdMove / 2.0, toe, r=True, ws=True )
jointSize( thigh, 2 )
jointSize( ankle, 2 )
jointSize( toe, 1.5 )
return [ thigh, knee, ankle, toe ]
def _align( self, _initialAlign=False ):
upperNormal = getPlaneNormalForObjects( self.thigh, self.knee, self.ankle )
upperNormal *= self.getParityMultiplier()
parity = self.getParity()
alignAimAtItem( self.thigh, self.knee, parity, worldUpVector=upperNormal )
alignAimAtItem( self.knee, self.ankle, parity, worldUpVector=upperNormal )
if self.toe:
lowerNormal = getPlaneNormalForObjects( self.knee, self.ankle, self.toe )
lowerNormal *= self.getParityMultiplier()
alignAimAtItem( self.ankle, self.toe, parity, worldUpVector=upperNormal )
for i in self.getOrphanJoints():
alignItemToLocal( i )
#end