def spineCard(spineCount, orientation=Orientation.VERTICAL, isStart=True): ''' Makes a spine with a Pelvis as the core joint and sub joints of the spine and hips occupying the same space. ''' hasHips = True hasPelvis = True spine = makeCard(spineCount, 'Spine*', size=meters(0.5, 1)) spine.rigCommand = 'RotateChain' util.annotateSelectionHandle(spine.joints[0], 'Spine Start', (0, -2, 0)) if hasPelvis: pelvis = makeCard(1, 'Pelvis', size=meters(0.2, 0.2)) pelvis.fkControllerOptions = '-shape band -size 20 -color blue .65' pelvis.start().orientTarget = '-world-' pelvis.rz.set(90) pelvis.start().t.lock() moveCard.toObjByCenter(pelvis, spine.start()) pelvis.rigCommand = 'TranslateChain' #proxy.pointer( pelvis.start(), spine.start()) spine.start().setBPParent(pelvis.start()) pointConstraint(spine.start(), pelvis) util.annotateSelectionHandle(pelvis.start(), 'Pelvis (top joint)', (0, 0, -2)) if hasHips: hips = makeCard(1, 'Hips', size=meters(0.2, 0.2)) hips.fkControllerOptions = '-shape band -size 15 -color red .65' hips.start().orientTarget = '-world-' hips.ry.set(-90) hips.start().t.lock() moveCard.toObjByCenter(hips, spine.start()) hips.rigCommand = 'RotateChain' #proxy.pointer( pelvis.start(), hips.start() ) hips.start().setBPParent(pelvis.start()) pointConstraint(spine.start(), hips) util.annotateSelectionHandle(hips.start(), 'Hips', (0, -2, 0)) if orientation == Orientation.VERTICAL: spine.rx.set(180) else: spine.rx.set(-90) moveCard.up(spine, meters(0.5)) #spine.buildOrder.set( 0 ) # Probably not needed since (when?) proper build order is enforced if isStart: if hasPelvis: pelvis.start().proxy.setParent(proxy.getProxyGroup()) else: spine.start().proxy.setParent(proxy.getProxyGroup()) return spine, hips
def weaponCard(parentName, name, asymmetric=True): ''' I think parent might be a joint name and have it figure more stuff out than normal. It seems logical that the anticipated things are Wrist and spine. Then the rest of the joints can be listed out. ''' card = makeCard(1, name, size=meters(.15, .15)) card.rigCommand = 'TranslateChain' parent, direct = util.findTempJoint(parentName) if asymmetric: if parent.cardCon.node().isCardMirrored(): card.mirror = False if not direct: # Put card under root and set future parent card.start().postCommand = 'reparent {extraNode0};' card.start().extraNode[0] = parent else: card.start().setBPParent(parent) else: card.start().setBPParent(parent) else: card.start().setBPParent(parent)
def hindleg(startJoint=None, dist=0.20): suffix = 'left' if dist > 0 else 'right' leg = makeCard(4, ['Hip', 'Knee', 'Ankle', 'Toe'], size=meters(.2, 1), suffix=suffix) leg.rigCommand = 'DogHindleg' placeJoints(leg, [(0, 1), (-1, 0.1), (1, -0.5), (0.1, -1)]) if startJoint: moveCard.to(leg, startJoint) leg.start().setBPParent(startJoint) moveCard.left(leg, meters(dist)) leg.start().postCommand = 'mirror;' return leg
def arm(clav, side): leftArm = makeCard(3, ['Shoulder', 'Elbow', 'Wrist'], size=meters(.2, 1), suffix=side) leftArm.rigCommand = 'IkChain' placeJoints(leftArm, [(0, 1), (0.5, 0), (0, -1)]) rigData = leftArm.rigData rigData['ikParams'] = {'name': 'Arm', 'endOrientType': 'True_Zero'} leftArm.rigData = rigData #clavicleEnd = getattr(clav, attrMap[side] )[0] moveCard.to(leftArm, clav.end()) moveCard.farther(leftArm, meters(.25)) #proxy.pointer( clav.end(), leftArm.start() ) leftArm.start().setBPParent(clav.end()) return leftArm
def handSetup(leftArm, numFingers, makeThumb): #hand = Container('Hand', meters(0.20, 0.20) ) hand = makeCard(1, 'Hand', size=meters(0.20, 0.20)) # It makes sense that the wrist is oriented to the hand leftArm.end().customUp = hand.getUpArrow() placeJoints(hand, [(0, -.7)]) hand.joints[0].isHelper = True leftArm.end().orientTarget = hand.joints[0] hand.joints[0].setBPParent(leftArm.end()) xform(hand, ws=True, t=xform(leftArm.end(), q=True, ws=True, t=True)) moveCard.down(hand, meters(.1)) #hand.setParent( leftArm.end() ) xform(hand, ws=True, piv=xform(leftArm.end(), q=True, ws=True, t=True)) pointConstraint(leftArm.end(), core.dagObj.zero(hand), mo=True) [hand.attr('t' + a).lock() for a in 'xyz'] mod = 0.15 / (numFingers - 1) if numFingers > 1 else 0 for i, finger in enumerate(['Index', 'Middle', 'Ring', 'Pinky'][:numFingers]): card = makeCard(4, finger + '*', suffix='left') moveCard.to(card, leftArm.end()) moveCard.backward(card, meters(i * mod - 0.1)) moveCard.down(card, meters(0.20)) grp = group(card, n=finger + "_grp") card.setParent(grp) parentConstraint(hand, grp, mo=True) card.ry.set(90) card.joints[-1].isHelper = True #proxy.pointer( leftArm.end(), card.start() ) card.start().setBPParent(leftArm.end()) card.rigCommand = 'RotateChain' card.rigOptions = '-size 2 -visGroup fingers' if makeThumb: thumb = makeCard(4, 'Thumb*', suffix='left') moveCard.to(thumb, leftArm.end()) thumb.ry.set(-90) moveCard.to(thumb, leftArm.end()) moveCard.forward(thumb, meters(0.1)) moveCard.down(thumb, meters(0.1)) moveCard.closer(thumb, meters(0.05)) thumb.end().isHelper = True grp = group(thumb, n="Thumb_grp") parentConstraint(hand, grp, mo=True) #proxy.pointer( leftArm.end(), thumb.start() ) thumb.start().setBPParent(leftArm.end()) thumb.rigCommand = 'RotateChain' thumb.rigOptions = '-size 2 -visGroup fingers'
def foot(legCard): foot = makeCard(3, ['Ball', 'Toe', 'ToeEnd'], size=meters(.4, 0.2), suffix='left') placeJoints(foot, [(0.5, -1), (-0.7, -1), (-1, -1)]) foot.joints[-1].isHelper = True pivTo(foot, 1, 1) pointConstraint(legCard.end(), foot) foot.t.lock() foot.start().setBPParent(legCard.end()) return foot
def leg(startJoint, dist): ''' dist, pos moves left ''' suffix = 'left' if dist > 0 else 'right' leftLeg = makeCard(3, ['Hip', 'Knee', 'Ankle'], size=meters(.2, 1), suffix=suffix) leftLeg.rigCommand = 'IkChain' rigData = leftLeg.rigData rigData['ikParams'] = {'name': 'Leg', 'endOrientType': 'True_Zero_Foot'} leftLeg.rigData = rigData placeJoints(leftLeg, [(0, 1), (-0.23, 0.1), (0, -0.6)]) moveCard.to(leftLeg, startJoint) moveCard.left(leftLeg, meters(dist)) leftLeg.start().setBPParent(startJoint) leftLeg.mirror = '' return leftLeg
def bipedSetup(spineCount=4, neckCount=1, numFingers=4, legType='Human', thumb=True, spineOrient=Orientation.VERTICAL): spine, hips = spineCard(spineCount, spineOrient) # Neck neck = makeCard(neckCount, 'Neck*', size=meters(.15, .4)) neck.rigCommand = 'RotateChain' neck.rx.set(180) moveCard.to(neck, spine.end()) moveCard.up(neck, meters(0.10)) neck.start().setBPParent(spine.end()) # Head head = makeCard(2, 'Head HeadTip', size=meters(.3, .3)) head.rigCommand = 'TranslateChain' head.rx.set(180) moveCard.to(head, neck.end()) moveCard.up(head, meters(0.10)) head.end().isHelper = True head.start().setBPParent(neck.end()) spine.end().orientTarget = neck.start() # Arms clav = makeCard(1, 'Clavicle', size=meters(.1, .1), suffix='left') clav.rigCommand = 'RotateChain' moveCard.to(clav, spine.end()) moveCard.forward(clav, meters(0.10)) moveCard.left(clav, meters(0.2)) clav.ry.set(-90) clav.mirror = '' clav.start().setBPParent(spine.end()) leftArm = arm(clav, 'left') handSetup(leftArm, numFingers, thumb) # Legs if legType == 'Human': leftLeg = leg(hips.start(), 0.20) elif legType == 'Dogleg': leftLeg = hindleg(hips.start(), 0.20) foot(leftLeg)
def squashAndStretchCard(parent, count): ''' .. todo:: * Use parent name by default * Arrange joints in circle (as separately callable thing) * Orient card along parent's X ''' dist = 3.75 # I think this is due to meter being 0.15 card = makeCard(1, 'Squash*', size=meters(.15, .15)) angle = math.pi * 2.0 / count for i in range(count): card.addJoint() card.joints[i].tz.set(math.cos(angle * i) * dist) card.joints[i].ty.set(math.sin(angle * i) * dist) moveCard.toObjByCenter(card, parent) #card.setTempNames() card.rigCommand = 'SquashStretch' for j in card.joints: j.setBPParent(parent) #j.orientTarget = card.end() card.end().isHelper = True rot = xform(parent, q=True, ws=True, ro=True) xform(card, ws=True, ro=rot) rotate(card, [0, 0, -90], r=True, os=True) # &&& I do not get what name scheme I'm doing here cards = core.findNode.allCards() cards.remove(card) nameScheme = findUniqueNameInfo(util.parse(card.nameInfo.get()), '', cards=cards) card.nameInfo.set(' '.join(nameScheme[0]) + nameScheme[1] + '* ' + ' '.join(nameScheme[2])) return card