Example #1
0
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=pdil.meters([0.5, 1]))
    with spine.rigData as data:
        data[enums.RigData.rigCmd] = 'TranslateChain'

    util.annotateSelectionHandle(spine.joints[0], 'Spine Start', (0, -2, 0))

    if hasPelvis:
        pelvis = makeCard(1, 'Pelvis', size=pdil.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())
        with pelvis.rigData as data:
            data[enums.RigData.rigCmd] = 'TranslateChain'
        #proxyskel.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=pdil.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())
        with hips.rigData as data:
            data[enums.RigData.rigCmd] = 'TranslateChain'
        #proxyskel.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, pdil.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(proxyskel.getProxyGroup())
        else:
            spine.start().proxy.setParent(proxyskel.getProxyGroup())

    return spine, hips
Example #2
0
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=pdil.meters([.15, .15]))
    with card.rigData as data:
        data[enums.RigData.rigCmd] = '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)
Example #3
0
def handSetup(leftArm, numFingers, makeThumb):
    #hand = Container('Hand', pdil.meters(0.20, 0.20) )
    hand = makeCard(1, 'Hand', size=pdil.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, pdil.meters(.1))
    #hand.setParent( leftArm.end() )
    xform(hand, ws=True, piv=xform(leftArm.end(), q=True, ws=True, t=True))

    pointConstraint(leftArm.end(), pdil.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, pdil.meters(i * mod - 0.1))
        moveCard.down(card, pdil.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())

        with card.rigData as data:
            data[enums.RigData.rigCmd] = 'TranslateChain'

    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, pdil.meters(0.1))
        moveCard.down(thumb, pdil.meters(0.1))
        moveCard.closer(thumb, pdil.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())
        with thumb.rigData as data:
            data[enums.RigData.rigCmd] = 'TranslateChain'
Example #4
0
def arm(clav, side):
    leftArm = makeCard(3, ['Shoulder', 'Elbow', 'Wrist'],
                       size=pdil.meters([.2, 1]),
                       suffix=side)
    with leftArm.rigData as data:
        data[enums.RigData.rigCmd] = '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, pdil.meters(.25))
    #proxyskel.pointer( clav.end(), leftArm.start() )
    leftArm.start().setBPParent(clav.end())
    return leftArm
Example #5
0
def hindleg(startJoint=None, dist=0.20):
    suffix = 'left' if dist > 0 else 'right'

    leg = makeCard(4, ['Hip', 'Knee', 'Ankle', 'Ball'],
                   size=pdil.meters([.2, 1]),
                   suffix=suffix)
    with leg.rigData as data:
        data[enums.RigData.rigCmd] = '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, pdil.meters(dist))

    #leg.start().postCommand = 'mirror;'
    leg.mirror = ''
    return leg
Example #6
0
def simpleCircle(radius=1, orientPosRef=None):
    '''
    Make a circle, matching the orientation and position of the `orientPosRef` object if given.
    '''
    ctrl = circle(r=pdil.meters(radius), nr=[0, 0, 1])[0]

    if orientPosRef:
        ctrl.setTranslation(orientPosRef.getTranslation(space='world'),
                            space='world')
        ctrl.setRotation(orientPosRef.getRotation(space='world'),
                         space='world')

    return ctrl
Example #7
0
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=pdil.meters([.15, .4]))
    with neck.rigData as data:
        data[enums.RigData.rigCmd] = 'TranslateChain'
    neck.rx.set(180)

    moveCard.to(neck, spine.end())
    moveCard.up(neck, pdil.meters(0.10))

    neck.start().setBPParent(spine.end())

    # Head
    head = makeCard(2, 'Head HeadTip', size=pdil.meters([.3, .3]))
    with head.rigData as data:
        data[enums.RigData.rigCmd] = 'TranslateChain'
    head.rx.set(180)

    moveCard.to(head, neck.end())
    moveCard.up(head, pdil.meters(0.10))
    head.end().isHelper = True

    head.start().setBPParent(neck.end())

    spine.end().orientTarget = neck.start()

    # Arms
    clav = makeCard(1, 'Clavicle', size=pdil.meters([.1, .1]), suffix='left')
    with clav.rigData as data:
        data[enums.RigData.rigCmd] = 'TranslateChain'
    moveCard.to(clav, spine.end())
    moveCard.forward(clav, pdil.meters(0.10))
    moveCard.left(clav, pdil.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)
        foot(leftLeg)
    elif legType == 'Dogleg':
        leftLeg = hindleg(hips.start(), 0.20)
Example #8
0
def foot(legCard):
    foot = makeCard(3, ['Ball', 'Toe', 'ToeEnd'],
                    size=pdil.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
Example #9
0
def leg(startJoint, dist):
    '''
    dist, pos moves left
    '''

    suffix = 'left' if dist > 0 else 'right'

    leftLeg = makeCard(3, ['Hip', 'Knee', 'Ankle'],
                       size=pdil.meters([.2, 1]),
                       suffix=suffix)
    with leftLeg.rigData as data:
        data[enums.RigData.rigCmd] = '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, pdil.meters(dist))

    leftLeg.start().setBPParent(startJoint)
    leftLeg.mirror = ''

    return leftLeg
Example #10
0
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=pdil.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()
    with card.rigData as data:
        data[enums.RigData.rigCmd] = '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 = find.blueprintCards()
    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