def test_basicBiped(): #gui = main.RigTool() # Make the default biped card.bipedSetup(spineCount=5) # Make all the bones and test their existence select(core.findNode.allCards()) main.RigTool.buildBones() for j in jointsToMake: assert objExists(j), 'Joint ' + j + ' was not made' root = core.findNode.getRoot() assert len(listRelatives(root, ad=True, type='joint')) == (len(jointsToMake) - 1), 'Too many bones were made' # Build the rig spine = PyNode('Spine_card') rigData = spine.rigData rigData['rigCmd'] = 'SplineChest' spine.rigData = rigData select(core.findNode.allCards()) main.RigTool.buildRig()
def makeCard(jointCount=5, jointNames={'repeat': 'DEFAULT'}, rigInfo=None, size=(4, 6), suffix=''): ''' .. todo:: Do not use defaults. &&& names is really joints names, make it so. ''' if isinstance(jointNames, basestring): head, repeat, tail = util.parse(jointNames) jointNames = {'head': head, 'repeat': repeat, 'tail': tail} elif isinstance(jointNames, list): jointNames = {'head': jointNames} leadName = jointNames.get('head')[0] if jointNames.get( 'head') else jointNames.get('repeat', 'DEFAULT') joints = [] width, height = size # Base the card name off the lead joint cardName = leadName if not isinstance(cardName, basestring): cardName = cardName[0] #jointNames = ' '.join(jointNames) if not cardName.endswith('_card'): if cardName.endswith('_'): cardName += 'card' else: cardName += '_card' # Make the actual card and tag with attrs card = nurbsPlane(w=width, lr=height / float(width), ax=(1, 0, 0), n=cardName, d=1, u=1, v=1)[0] card.addAttr('moRigData', dt='string') card.addAttr('moRigState', dt='string') addOutputControlsAttrs(card) addJointArrayAttr(card) #card.addAttr( 'skeletonInfo', at='bool' ) #card.addAttr( 'buildOrder', at='long' ) #card.addAttr( 'nameInfo', dt='string' ) #card.addAttr( 'suffix', dt='string' ) # Reassign it so it gets the proper interface now that it has the attrs card = PyNode(card) rigData = { 'buildOrder': 10, 'mirrorCode': suffix, 'nameInfo': jointNames, } card.rigData = rigData #card.buildOrder.set( 10 ) #card.suffix.set( suffix ) #card.nameInfo.set( jointNames ) # &&& I hate how I handle the names, want to put in rigInfo (I think that's the json attr...) #card.rigParams = '' #card.rigOptions = '' arrow = makeArrow() arrow.setParent(card) arrow.rename('arrow') card.scale >> arrow.inverseScale arrow.t.set(0, 0, 0) arrow.r.set(0, 0, -90) hide(arrow) card.setParent(proxy.masterGroup()) # Place all the joints delta = height / float(jointCount - 1) if jointCount > 1 else 0 for i in range(jointCount): newJoint = card.addJoint() joints.append(newJoint) newJoint.ty.set(height / 2.0 - delta * i) if len(joints) > 1: for parentBpj, childBpj in zip(joints[0:-1], joints[1:]): proxy.pointer(parentBpj, childBpj) elif joints: proxy.makeProxy(joints[0], proxy.getProxyGroup()) joints[0].ty.set(0) if joints: card.setTempNames() pivToStart(card) return card