Ejemplo n.º 1
0
def addOffsetRig():
    #===============================================================================
    # SETUP LOCATORS FOR ALIGN AND AIM
    #===============================================================================
    # add offsetAimLocs to blockAimCrv
    globalGrp = 'CT_teethOffset_mod_0'
    mc.group(n=globalGrp, em=True)
    name = 'CT_teethOffset'
    targetCrv = 'CT_teethBlockAim_crv_0'
    locs = []
    for locId in range(12):
        loc = mc.spaceLocator(n=name + '_aim_loc_%d' % locId)[0]
        mc.setAttr(loc + '.localScale', 0.1, 0.1, 0.1)
        rt.attachToMotionPath(targetCrv, (float(locId) + 0.5) / 12, loc, True)
        locs.append(loc)
    mc.group(locs, n='CT_teethOffset_aim_loc_grp', p=globalGrp)
    rt.connectVisibilityToggle(locs, globalGrp, 'aimLocs', False)

    # add offsetAlignLocs to blockDrvCrv
    targetCrv = 'CT_teethBlockDrv_crv_0'
    locs = []
    for locId in range(12):
        loc = mc.spaceLocator(n=name + '_align_loc_%d' % locId)[0]
        mc.setAttr(loc + '.localScale', 0.1, 0.1, 0.1)
        rt.alignOnMotionPath(targetCrv, (float(locId) + 0.5) / 12,
                             loc,
                             name + '_aim_loc_%d.matrix' % locId,
                             True,
                             ua=1,
                             inverseUp=True)
        locs.append(loc)
    mc.group(locs, n='CT_teethOffset_align_loc_grp', p=globalGrp)
    rt.connectVisibilityToggle(locs, globalGrp, 'alignLocs', False)
Ejemplo n.º 2
0
def addOffsetRig():
    #===============================================================================
    # SETUP LOCATORS FOR ALIGN AND AIM
    #===============================================================================
    # add offsetAimLocs to blockAimCrv
    globalGrp = 'CT_teethOffset_mod_0'
    mc.group(n=globalGrp, em=True)
    name = 'CT_teethOffset'
    targetCrv = 'CT_teethBlockAim_crv_0'
    locs=[]
    for locId in range(12):
        loc = mc.spaceLocator(n=name+'_aim_loc_%d'%locId)[0]
        mc.setAttr(loc+'.localScale', 0.1,0.1,0.1)
        rt.attachToMotionPath(targetCrv, (float(locId)+0.5)/12, loc, True)
        locs.append(loc)
    mc.group(locs, n='CT_teethOffset_aim_loc_grp', p=globalGrp)
    rt.connectVisibilityToggle(locs, globalGrp, 'aimLocs', False)
    
    # add offsetAlignLocs to blockDrvCrv
    targetCrv = 'CT_teethBlockDrv_crv_0'
    locs=[]
    for locId in range(12):
        loc = mc.spaceLocator(n=name+'_align_loc_%d'%locId)[0]
        mc.setAttr(loc+'.localScale', 0.1,0.1,0.1)
        rt.alignOnMotionPath(targetCrv, (float(locId)+0.5)/12, loc, name+'_aim_loc_%d.matrix'%locId, True, ua=1, inverseUp=True)
        locs.append(loc)
    mc.group(locs, n='CT_teethOffset_align_loc_grp', p=globalGrp)
    rt.connectVisibilityToggle(locs, globalGrp, 'alignLocs', False)
Ejemplo n.º 3
0
def globalRig():
    """
    Make global teeth rig
    """
    # teeth aim locs
    globalGrp = 'CT_teethBlockGlobal_mod_0'
    locNum = 7
    name = 'CT_teethBlock'
    targetCrv = 'CT_teethBlockAim_crv_0'
    locs = []
    for locId in range(locNum):
        loc = mc.spaceLocator(n=name + '_aim_loc_%d' % locId)[0]
        mc.setAttr(loc + '.localScale', 0.1, 0.1, 0.1)
        rt.attachToMotionPath(targetCrv,
                              float(locId) / (locNum - 1), loc, True)
        locs.append(loc)
    mc.group(locs, n='CT_teethBlock_aim_loc_grp')
    rt.connectVisibilityToggle(locs, globalGrp, 'aimLocs', False)

    # teeth bind jnt for each aimLoc
    targetCrv = 'CT_teethBlockDrv_crv_0'
    jnts = []
    for jntId in range(locNum):
        mc.select(cl=True)
        jnt = mc.joint(n=name + '_bnd_jnt_%d' % jntId)
        mc.setAttr(jnt + '.radius', 0.5)
        rt.alignOnMotionPath(targetCrv,
                             float(jntId) / (locNum - 1),
                             jnt,
                             name + '_aim_loc_%d.matrix' % jntId,
                             True,
                             ua=1,
                             inverseUp=True)
        jnts.append(jnt)
    mc.group(jnts, n='CT_teethBlock_bnd_jnts_grp')
    rt.connectVisibilityToggle(jnts, globalGrp, 'bndJnts', False)

    jnts = mc.ls(sl=True)

    import utils.wrappers.abRiggingTools as abRT
    # add bnd jnts for bite
    # for each bndjnt, make another jnt below it
    for bndJnt in jnts:
        mc.select(cl=True)
        biteJnt = mc.joint(n=bndJnt + '_bite')
        mc.setAttr(biteJnt + '.radius', 0.5)
        abRT.snapToPosition(bndJnt, biteJnt)
        mc.xform(biteJnt, t=(0, -1, 0), r=True)
        mc.parentConstraint(bndJnt, biteJnt, mo=True)
        mc.parent(biteJnt, 'CT_teethBlock_bnd_jnts_grp')
Ejemplo n.º 4
0
def globalRig():
    """
    Make global teeth rig
    """
    # teeth aim locs
    globalGrp = 'CT_teethBlockGlobal_mod_0'
    locNum = 7
    name = 'CT_teethBlock'
    targetCrv = 'CT_teethBlockAim_crv_0'
    locs=[]
    for locId in range(locNum):
        loc = mc.spaceLocator(n=name+'_aim_loc_%d'%locId)[0]
        mc.setAttr(loc+'.localScale', 0.1,0.1,0.1)
        rt.attachToMotionPath(targetCrv, float(locId)/(locNum-1), loc, True)
        locs.append(loc)
    mc.group(locs, n='CT_teethBlock_aim_loc_grp')
    rt.connectVisibilityToggle(locs, globalGrp, 'aimLocs', False)
    
    # teeth bind jnt for each aimLoc
    targetCrv = 'CT_teethBlockDrv_crv_0'
    jnts=[]
    for jntId in range(locNum):
        mc.select(cl=True)
        jnt = mc.joint(n=name+'_bnd_jnt_%d'%jntId)
        mc.setAttr(jnt+'.radius', 0.5)
        rt.alignOnMotionPath(targetCrv, float(jntId)/(locNum-1), jnt, name+'_aim_loc_%d.matrix'%jntId, True, ua=1, inverseUp=True)
        jnts.append(jnt)
    mc.group(jnts, n='CT_teethBlock_bnd_jnts_grp')
    rt.connectVisibilityToggle(jnts, globalGrp, 'bndJnts', False)
    
    jnts = mc.ls(sl=True)
    
    import utils.wrappers.abRiggingTools as abRT
    # add bnd jnts for bite
    # for each bndjnt, make another jnt below it
    for bndJnt in jnts:
        mc.select(cl=True)
        biteJnt = mc.joint(n=bndJnt+'_bite')
        mc.setAttr(biteJnt+'.radius', 0.5)
        abRT.snapToPosition(bndJnt, biteJnt)
        mc.xform(biteJnt, t=(0,-1,0), r=True)
        mc.parentConstraint(bndJnt, biteJnt, mo=True)
        mc.parent(biteJnt, 'CT_teethBlock_bnd_jnts_grp')
Ejemplo n.º 5
0
def createSplineMPs(MPs, newMPsNum, name, twistOffset):
    '''
    creates spline along mps
    adds new MPs along spline
    
    twistOffset - vector to offset twistCrv
    
    returns [(drvCrv, twistCrv, oldDrvCrv), MPJnts]
    '''
    numOfMPs = len(MPs)
    
    # create twist curve for aiming locs
    twistCrv = mc.curve(p=[(pt,pt,pt) for pt in range(numOfMPs)])
    twistCrv = mc.rename(twistCrv, name+'_twist_crv')
    
    # get point from MPs to drive curve CVs
    for mp in MPs:
        pmm = mc.createNode('pointMatrixMult', n=mp+'_pmm_0')
        mc.connectAttr(mp+'.worldMatrix', pmm+'.inMatrix', f=True)
        mc.setAttr(pmm+'.inPoint', *twistOffset)
        mc.connectAttr(pmm+'.output', twistCrv+'.cp[%d]' % MPs.index(mp))
        
    # create driver curve for locs
    drvCrv = mc.curve(p=[(pt,pt,pt) for pt in range(numOfMPs)])
    drvCrv = mc.rename(drvCrv, name+'_drv_crv')
    
    # get point from MPs to drive curve CVs
    for mp in MPs:
        pmm = mc.createNode('pointMatrixMult', n=mp+'_pmm_0')
        mc.connectAttr(mp+'.worldMatrix', pmm+'.inMatrix', f=True)
        mc.connectAttr(pmm+'.output', drvCrv+'.cp[%d]' % MPs.index(mp))
    
    # make driver curve uniform
    oldDrvCrv = drvCrv
    drvCrv = rt.makeUniformCrv(drvCrv, newMPsNum, name+'_uniform_crv')
    
    # add aimLocs to twistCurve
    aimLocs = []
    
    for locId in range(newMPsNum):
        loc = mc.spaceLocator(n=name+'_aimLoc_%d' % locId)[0]
        rt.attachToMotionPath(twistCrv, float(locId)/(newMPsNum-1), loc, 1)
        mc.setAttr(loc+'.localScale', 0.1,0.1,0.1)
        aimLocs.append(loc)
    
    aimLocsGrp = mc.group(aimLocs, n='CT_%s_aimLocs_grp'%name)
    
    MPJnts = []
    
    for jntId in range(newMPsNum):
        jnt = mc.joint(n=name+'_MPJnt_%d' % jntId)
        rt.alignOnMotionPath(drvCrv, float(jntId)/(newMPsNum-1), jnt, aimLocs[jntId]+'.worldMatrix', 1)
        MPJnts.append(jnt)
        
    MPJntsGrp = mc.group(MPJnts, n='CT_%s_MPJnts_grp'%name)
    
    # connect viz for debug
    rt.connectVisibilityToggle(oldDrvCrv, MPs[0], 'drvCrv', default=False)
    rt.connectVisibilityToggle((aimLocsGrp, twistCrv), MPs[0], 'twistLocs', default=False)
    rt.connectVisibilityToggle((MPJntsGrp, drvCrv), MPs[0], 'drvMPs', default=False)
    
    mc.group(oldDrvCrv, twistCrv, drvCrv, aimLocsGrp, MPJntsGrp, n=name+'_splineMPs_grp')
    
    return (drvCrv, twistCrv, oldDrvCrv), MPJnts