-
Notifications
You must be signed in to change notification settings - Fork 10
/
rigPrim_misc.py
67 lines (44 loc) · 2.24 KB
/
rigPrim_misc.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
from baseRigPrimitive import *
from skeletonPart_arbitraryChain import ArbitraryChain
class ControlHierarchy(PrimaryRigPart):
__version__ = 0
#part doesn't have a CONTROL_NAMES list because parts are dynamic - use indices to refer to controls
SKELETON_PRIM_ASSOC = ( SkeletonPart.GetNamedSubclass( 'ArbitraryChain' ), )
def _build( self, part, controlShape=DEFAULT_SHAPE_DESC, spaceSwitchTranslation=False, parents=(), rigOrphans=False, **kw ):
joints = list( part ) + (part.getOrphanJoints() if rigOrphans else [])
return controlChain( self, joints, controlShape, spaceSwitchTranslation, parents, rigOrphans, **kw ), ()
class WeaponControlHierarchy(PrimaryRigPart):
__version__ = 0
SKELETON_PRIM_ASSOC = ( SkeletonPart.GetNamedSubclass( 'WeaponRoot' ), )
def _build( self, part, controlShape=DEFAULT_SHAPE_DESC, spaceSwitchTranslation=True, parents=(), **kw ):
return controlChain( self, part.selfAndOrphans(), controlShape, spaceSwitchTranslation, parents, True, **kw ), ()
def controlChain( rigPart, joints, controlShape=DEFAULT_SHAPE_DESC, spaceSwitchTranslation=False, parents=(), rigOrphans=False, **kw ):
scale = kw[ 'scale' ]
#discover parent nodes
namespace = ''
try:
namespace = getNamespaceFromReferencing( joints[ 0 ] )
except IndexError: pass
parents = tuple( '%s%s' % (namespace, p) for p in parents )
### DETERMINE THE PART'S PARENT CONTROL AND THE ROOT CONTROL ###
parentControl, rootControl = getParentAndRootControl( joints[ 0 ] )
ctrls = []
prevParent = parentControl
for item in joints:
ctrl = buildControl( '%s_ctrl' % item, item, PivotModeDesc.BASE, controlShape, size=AUTO_SIZE )
ctrlSpace = getNodeParent( ctrl )
#do parenting
parent( ctrlSpace, prevParent )
#stuff objects into appropriate variables
prevParent = ctrl
ctrls.append( ctrl )
#lock un-needed axes
if not spaceSwitchTranslation:
attrState( ctrl, 't', *LOCK_HIDE )
#setup space switching
buildKwargs = {} if spaceSwitchTranslation else spaceSwitching.NO_TRANSLATION
for n, (ctrl, j) in enumerate( zip( ctrls, joints ) ):
buildDefaultSpaceSwitching( j, ctrl, parents, reverseHierarchy=False, **buildKwargs )
createLineOfActionMenu( joints, ctrls )
return ctrls
#end