Пример #1
0
def createLatticeControls():
    """
    assume lattice is already created and xformed
    """
    lat = nt.Transform(u"CT_eyeLattice_dfmLattice")

    # defining lattice points
    lf_in_col = 5
    lf_mid_col = 6
    lf_out_col = 7
    rt_out_col = 1
    rt_mid_col = 2
    rt_in_col = 3
    up_row = 3
    dn_row = 2

    deformPoints = {
        "LT_eyeUpIn": [lat.pt[lf_in_col][up_row][0], lat.pt[lf_in_col][up_row][1]],
        "LT_eyeUpMid": [lat.pt[lf_mid_col][up_row][0], lat.pt[lf_mid_col][up_row][1]],
        "LT_eyeUpOut": [lat.pt[lf_out_col][up_row][0], lat.pt[lf_out_col][up_row][1]],
        "LT_eyeDnIn": [lat.pt[lf_in_col][dn_row][0], lat.pt[lf_in_col][dn_row][1]],
        "LT_eyeDnMid": [lat.pt[lf_mid_col][dn_row][0], lat.pt[lf_mid_col][dn_row][1]],
        "LT_eyeDnOut": [lat.pt[lf_out_col][dn_row][0], lat.pt[lf_out_col][dn_row][1]],
        "RT_eyeUpIn": [lat.pt[rt_in_col][up_row][0], lat.pt[rt_in_col][up_row][1]],
        "RT_eyeUpMid": [lat.pt[rt_mid_col][up_row][0], lat.pt[rt_mid_col][up_row][1]],
        "RT_eyeUpOut": [lat.pt[rt_out_col][up_row][0], lat.pt[rt_out_col][up_row][1]],
        "RT_eyeDnIn": [lat.pt[rt_in_col][dn_row][0], lat.pt[rt_in_col][dn_row][1]],
        "RT_eyeDnMid": [lat.pt[rt_mid_col][dn_row][0], lat.pt[rt_mid_col][dn_row][1]],
        "RT_eyeDnOut": [lat.pt[rt_out_col][dn_row][0], lat.pt[rt_out_col][dn_row][1]],
    }

    # create clusters
    clusters = {}
    dfg = pm.group(em=True, n="CT_eyeLatticeClusters_dfg")
    for name, components in deformPoints.items():
        dfm, hdl = pm.cluster(components[1], n=name + "_cluster_dfm", relative=True)
        # above: use relative - the cluster handles will be parented with the face/head control
        # so parentConstraint will only drive offset values to the handles
        # so we'll make sure to only use the local offset values
        dfm.setGeometry(components[0])
        dfg | hdl
        clusters[name] = dfm, hdl

    # create controls
    controlZOffset = 0
    childEyeShapers = []
    localReadersGrp = pm.group(em=True, n="CT_eyeLatticeClusters_localReadersGrp")
    for name, (dfm, hdl) in clusters.items():
        pt = hdl.getRotatePivot(space="world")
        pt = dt.Point(pt + (0, 0, controlZOffset))
        ctl = pm.circle(n=name + "_eyeShaper_ctl")
        ctg = pm.group(ctl, n=name + "_eyeShaper_ctg")
        cth = pm.group(ctg, n=name + "_eyeShaper_cth")
        cth.setTranslation(pt)
        # shape ctl
        ctl[1].radius.set(0.5)
        ctl[1].sweep.set(359)
        ctl[1].centerZ.set(0)
        pm.delete(ctl, ch=True)
        # scale transform
        ctl[0].sy.set(0.333)
        pm.makeIdentity(ctl[0], s=True, a=True)
        # color shape
        if "LT_" in name:
            controls.setColor(ctl[0], 18)
        elif "RT_" in name:
            controls.setColor(ctl[0], 20)
        else:
            pm.warning("unknown side %s" % name)
        # parent constraint cluster (using matrices)
        reader = localReader.create(hdl, localReadersGrp)
        pm.parentConstraint(ctl[0], reader, mo=True)
        childEyeShapers.append(cth)

    # control parents
    parentEyeShapers = []
    for parentCtlName in ("RT_eyeUp", "RT_eyeDn", "LT_eyeUp", "LT_eyeDn"):
        # create parent control at cluster location
        clusHdl = clusters[parentCtlName + "Mid"][1]
        pt = clusHdl.getRotatePivot(space="world")
        pt = pt + (0, 0, controlZOffset)
        ctl = pm.circle(n=parentCtlName + "_eyeShaper_ctl")
        ctg = pm.group(ctl, n=parentCtlName + "_eyeShaper_ctg")
        cth = pm.group(ctg, n=parentCtlName + "_eyeShaper_cth")
        cth.setTranslation(pt)
        # shape ctl
        ctl[1].radius.set(2.5)
        ctl[1].sweep.set(359)
        ctl[1].centerZ.set(0)
        pm.delete(ctl, ch=True)
        # scale transform
        ctl[0].sy.set(0.1)
        pm.makeIdentity(ctl[0], s=True, a=True)
        # color shape
        if "LT_" in parentCtlName:
            controls.setColor(ctl[0], 18)
        elif "RT_" in parentCtlName:
            controls.setColor(ctl[0], 20)
        else:
            pm.warning("unknown side %s" % name)
        # parent other controls
        children = [n for n in childEyeShapers if parentCtlName in n.name()]
        pm.parent(children, ctl[0])
        parentEyeShapers.append(cth)

    # group both controls and clusters under the CTG,
    # so cluster will only use local offsets
    eyeShaperCtg = pm.group(parentEyeShapers, localReadersGrp, n="CT_eyeLatticeControls_ctg")
    return eyeShaperCtg
Пример #2
0
def createLatticeControls():
    '''
    assume lattice is already created and xformed
    
    xform for mathilda:
    dt.Matrix([[1.08819833575, 0.0, 0.0, 0.0],
             [0.0, 0.800333468787, 0.0, 0.0],
             [0.0, 0.0, 1.08819833575, 0.0],
             [0.0, 23.1879695956, -0.00324741491951, 1.0]])
    '''
    lat = nt.Transform(u'CT_headLattice_dfmLattice')
    
    # defining lattice points  
    deformPoints = {'CT_headUpperA': [lat.pt[0:1][8][0:1], lat.pt[0:1][9:10][0:1]],
                    'CT_headUpperB': [lat.pt[0:1][11][0:1], lat.pt[0:1][12:15][0:1]],
                    'CT_headLowerA': [lat.pt[0:1][7][0:1], lat.pt[0:1][6][0:1]],
                    'CT_headLowerB': [lat.pt[0:1][5][0:1], lat.pt[0:1][0:4][0:1]]}
    
    
    # create clusters
    clusters = {}
    dfg = pm.group(em=True, n='CT_headLatticeClusters_dfg')
    for name, components in deformPoints.items():
        dfm, hdl = pm.cluster(components[0], n=name+'_cluster_dfm', relative=True)
        # above: use relative - the cluster handles will be parented with the face/head control
        # so parentConstraint will only drive offset values to the handles
        # so we'll make sure to only use the local offset values
        for component in components[1]:
            dfm.setGeometry(component)
        dfg | hdl
        clusters[name] = dfm, hdl
    
    # create controls
    controlZOffset = 0
    childEyeShapers = []
    localReadersGrp = pm.group(em=True, n='CT_headLatticeClusters_localReadersGrp')
    for name, (dfm, hdl) in clusters.items():
        pt = hdl.getRotatePivot(space='world')
        pt = dt.Point(pt + (0, 0, controlZOffset))
        ctl = pm.circle(n=name+'_headShaper_ctl')
        ctg = pm.group(ctl, n=name+'_headShaper_ctg')
        cth = pm.group(ctg, n=name+'_headShaper_cth')
        cth.setTranslation(pt)
        # shape ctl
        ctl[1].radius.set(0.5)
        ctl[1].sweep.set(359)
        ctl[1].centerZ.set(0)
        ctl[1].normal.set((0,1,0))
        pm.delete(ctl, ch=True)
        # scale transform
        pm.makeIdentity(ctl[0], s=True, a=True)
        # color shape
        '''
        if 'LT_' in name:
            controls.setColor(ctl[0], 18)
        elif 'RT_' in name:
            controls.setColor(ctl[0], 20)
        else:
            pm.warning('unknown side %s' % name)'''
        # parent constraint cluster (using matrices)
        reader = localReader.create(hdl, localReadersGrp)
        pm.parentConstraint(ctl[0], reader, mo=True)
        childEyeShapers.append(cth)
        
    # group both controls and clusters under the CTG,
    # so cluster will only use local offsets
    headShaperCtg = pm.group(childEyeShapers, localReadersGrp, n='CT_headLatticeControls_ctg')
    # headShaperCtg can then be parented under face_ctrl
    return headShaperCtg
Пример #3
0
def createLatticeControls():
    '''
    assume lattice is already created and xformed
    '''
    lat = nt.Transform(u'CT_eyeLattice_dfmLattice')

    # defining lattice points
    lf_in_col = 5
    lf_mid_col = 6
    lf_out_col = 7
    rt_out_col = 1
    rt_mid_col = 2
    rt_in_col = 3
    up_row = 3
    dn_row = 2

    deformPoints = {
        'LT_eyeUpIn':
        [lat.pt[lf_in_col][up_row][0], lat.pt[lf_in_col][up_row][1]],
        'LT_eyeUpMid':
        [lat.pt[lf_mid_col][up_row][0], lat.pt[lf_mid_col][up_row][1]],
        'LT_eyeUpOut':
        [lat.pt[lf_out_col][up_row][0], lat.pt[lf_out_col][up_row][1]],
        'LT_eyeDnIn':
        [lat.pt[lf_in_col][dn_row][0], lat.pt[lf_in_col][dn_row][1]],
        'LT_eyeDnMid':
        [lat.pt[lf_mid_col][dn_row][0], lat.pt[lf_mid_col][dn_row][1]],
        'LT_eyeDnOut':
        [lat.pt[lf_out_col][dn_row][0], lat.pt[lf_out_col][dn_row][1]],
        'RT_eyeUpIn':
        [lat.pt[rt_in_col][up_row][0], lat.pt[rt_in_col][up_row][1]],
        'RT_eyeUpMid':
        [lat.pt[rt_mid_col][up_row][0], lat.pt[rt_mid_col][up_row][1]],
        'RT_eyeUpOut':
        [lat.pt[rt_out_col][up_row][0], lat.pt[rt_out_col][up_row][1]],
        'RT_eyeDnIn':
        [lat.pt[rt_in_col][dn_row][0], lat.pt[rt_in_col][dn_row][1]],
        'RT_eyeDnMid':
        [lat.pt[rt_mid_col][dn_row][0], lat.pt[rt_mid_col][dn_row][1]],
        'RT_eyeDnOut':
        [lat.pt[rt_out_col][dn_row][0], lat.pt[rt_out_col][dn_row][1]]
    }

    # create clusters
    clusters = {}
    dfg = pm.group(em=True, n='CT_eyeLatticeClusters_dfg')
    for name, components in deformPoints.items():
        dfm, hdl = pm.cluster(components[1],
                              n=name + '_cluster_dfm',
                              relative=True)
        # above: use relative - the cluster handles will be parented with the face/head control
        # so parentConstraint will only drive offset values to the handles
        # so we'll make sure to only use the local offset values
        dfm.setGeometry(components[0])
        dfg | hdl
        clusters[name] = dfm, hdl

    # create controls
    controlZOffset = 0
    childEyeShapers = []
    localReadersGrp = pm.group(em=True,
                               n='CT_eyeLatticeClusters_localReadersGrp')
    for name, (dfm, hdl) in clusters.items():
        pt = hdl.getRotatePivot(space='world')
        pt = dt.Point(pt + (0, 0, controlZOffset))
        ctl = pm.circle(n=name + '_eyeShaper_ctl')
        ctg = pm.group(ctl, n=name + '_eyeShaper_ctg')
        cth = pm.group(ctg, n=name + '_eyeShaper_cth')
        cth.setTranslation(pt)
        # shape ctl
        ctl[1].radius.set(0.5)
        ctl[1].sweep.set(359)
        ctl[1].centerZ.set(0)
        pm.delete(ctl, ch=True)
        # scale transform
        ctl[0].sy.set(0.333)
        pm.makeIdentity(ctl[0], s=True, a=True)
        # color shape
        if 'LT_' in name:
            controls.setColor(ctl[0], 18)
        elif 'RT_' in name:
            controls.setColor(ctl[0], 20)
        else:
            pm.warning('unknown side %s' % name)
        # parent constraint cluster (using matrices)
        reader = localReader.create(hdl, localReadersGrp)
        pm.parentConstraint(ctl[0], reader, mo=True)
        childEyeShapers.append(cth)

    # control parents
    parentEyeShapers = []
    for parentCtlName in ('RT_eyeUp', 'RT_eyeDn', 'LT_eyeUp', 'LT_eyeDn'):
        # create parent control at cluster location
        clusHdl = clusters[parentCtlName + 'Mid'][1]
        pt = clusHdl.getRotatePivot(space='world')
        pt = pt + (0, 0, controlZOffset)
        ctl = pm.circle(n=parentCtlName + '_eyeShaper_ctl')
        ctg = pm.group(ctl, n=parentCtlName + '_eyeShaper_ctg')
        cth = pm.group(ctg, n=parentCtlName + '_eyeShaper_cth')
        cth.setTranslation(pt)
        # shape ctl
        ctl[1].radius.set(2.5)
        ctl[1].sweep.set(359)
        ctl[1].centerZ.set(0)
        pm.delete(ctl, ch=True)
        # scale transform
        ctl[0].sy.set(0.1)
        pm.makeIdentity(ctl[0], s=True, a=True)
        # color shape
        if 'LT_' in parentCtlName:
            controls.setColor(ctl[0], 18)
        elif 'RT_' in parentCtlName:
            controls.setColor(ctl[0], 20)
        else:
            pm.warning('unknown side %s' % name)
        # parent other controls
        children = [n for n in childEyeShapers if parentCtlName in n.name()]
        pm.parent(children, ctl[0])
        parentEyeShapers.append(cth)

    # group both controls and clusters under the CTG,
    # so cluster will only use local offsets
    eyeShaperCtg = pm.group(parentEyeShapers,
                            localReadersGrp,
                            n='CT_eyeLatticeControls_ctg')
    return eyeShaperCtg