-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathskeletonPart_spine.py
51 lines (38 loc) · 1.32 KB
/
skeletonPart_spine.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
from baseSkeletonBuilder import *
class Spine(SkeletonPart):
HAS_PARITY = False
@classmethod
def _build( cls, parent=None, count=3, direction='y', **kw ):
idx = kw[ 'idx' ]
partScale = kw[ 'partScale' ]
parent = getParent( parent )
directionAxis = Axis.FromName( direction )
allJoints = []
prevJoint = str( parent )
posInc = float( partScale ) / 2 / (count + 2)
moveList = list( directionAxis.asVector() * posInc )
for n in range( count ):
j = createJoint( 'spine%s%d' % ('' if idx == 0 else '%d_' % idx, n+1) )
cmd.parent( j, prevJoint, relative=True )
move( moveList[0], moveList[1], moveList[2], j, r=True, ws=True )
allJoints.append( j )
prevJoint = j
jointSize( j, 2 )
return allJoints
def _align( self, _initialAlign=False ):
for n, item in enumerate( self[ :-1 ] ):
alignAimAtItem( item, self[ n+1 ] )
#if there is a head part parented to this part, then use it as a look at for the end joint
childParts = self.getChildParts()
hasHeadPartAsChild = False
headPart = None
HeadCls = SkeletonPart.GetNamedSubclass( 'Head' ) or type( None )
for p in childParts:
if isinstance( p, HeadCls ):
headPart = p
break
if headPart is None:
autoAlignItem( self.end )
else:
alignAimAtItem( self.end, headPart.base )
#end