Ejemplo n.º 1
0
def controlSurfaceSmoothWeights(surface):
    """
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Early version of a weight smoother for a

    ARGUMENTS:
    surface(string)

    RETURNS:
    Nada
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    cvList = (mc.ls ([surface+'.cv[*][*]'],flatten=True))
    print cvList
    skinCluster = querySkinCluster (surface)
    influenceObjects = queryInfluences (skinCluster)
    print influenceObjects
    #find the closest influence object to the start
    startObject =  (distance.returnClosestObjToCV (cvList[0], influenceObjects))
    print startObject
    #find the closest influence object to the end
    endObject = (distance.returnClosestObjToCV (cvList[-1], influenceObjects))
    print endObject
    #getting the last cv list number
    cvChainLength =  ((len(cvList)-1)/2)
    #set the skin weights for the top and bottom
    mc.skinPercent (skinCluster,(surface+'.cv[0:1][0:1]'), tv = [startObject,1])
    mc.skinPercent (skinCluster,('%s%s%i%s%i%s' % (surface,'.cv[0:1][',(cvChainLength-1),':',cvChainLength,']')), tv = [endObject,1])
    #Blend in the nearest row to the start and end
    mc.skinPercent (skinCluster,(surface+'.cv[0:1][2]'), tv = [startObject,.4])
    mc.skinPercent (skinCluster,('%s%s%i%s' % (surface,'.cv[0:1][',(cvChainLength-1),']')), tv = [endObject,.4])
Ejemplo n.º 2
0
def controlSurfaceSmoothWeights(surface):
    """
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Early version of a weight smoother for a

    ARGUMENTS:
    surface(string)

    RETURNS:
    Nada
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    cvList = (mc.ls ([surface+'.cv[*][*]'],flatten=True))
    print cvList
    skinCluster = querySkinCluster (surface)
    influenceObjects = queryInfluences (skinCluster)
    print influenceObjects
    #find the closest influence object to the start
    startObject =  (distance.returnClosestObjToCV (cvList[0], influenceObjects))
    print startObject
    #find the closest influence object to the end
    endObject = (distance.returnClosestObjToCV (cvList[-1], influenceObjects))
    print endObject
    #getting the last cv list number
    cvChainLength =  ((len(cvList)-1)/2)
    #set the skin weights for the top and bottom
    mc.skinPercent (skinCluster,(surface+'.cv[0:1][0:1]'), tv = [startObject,1])
    mc.skinPercent (skinCluster,('%s%s%i%s%i%s' % (surface,'.cv[0:1][',(cvChainLength-1),':',cvChainLength,']')), tv = [endObject,1])
    #Blend in the nearest row to the start and end
    mc.skinPercent (skinCluster,(surface+'.cv[0:1][2]'), tv = [startObject,.4])
    mc.skinPercent (skinCluster,('%s%s%i%s' % (surface,'.cv[0:1][',(cvChainLength-1),']')), tv = [endObject,.4])
Ejemplo n.º 3
0
def nurbsCVSmoothWeights(cv):
    surface = '.'.join(cv.split('.')[0:-1])
    skinCluster = querySkinCluster (surface)
    cvPos = mc.pointPosition (cv,world=True)
    wantedName = (cv + 'loc')
    actualName = mc.spaceLocator (n= wantedName)
    mc.move (cvPos[0],cvPos[1],cvPos[2], [actualName[0]])
    influenceObjects = queryInfluences (skinCluster)
    culledList = influenceObjects
    """figure out our closest objects"""
    bestChoices = []
    cnt = 5
    while cnt >= 0:
        goodChoice =  (distance.returnClosestObjToCV (cv, culledList))
        culledList.remove(goodChoice)
        bestChoices.append (goodChoice)
        print bestChoices
        cnt-=1
    distanceList = []
    for obj in bestChoices:
        distanceList.append (distance.returnDistanceBetweenObjects(actualName[0],obj))
        print distanceList
    """ return normalization value """
    buffer=0
    y = 1 + (x-A)*(10-1)/(B-A)
    for value in distanceList:
        buffer += value
    print buffer
    normalize = ((len(distanceList))*.1)
    print normalize
    mc.delete (actualName[0])
Ejemplo n.º 4
0
def nurbsCVSmoothWeights(cv):
    surface = '.'.join(cv.split('.')[0:-1])
    skinCluster = querySkinCluster (surface)
    cvPos = mc.pointPosition (cv,world=True)
    wantedName = (cv + 'loc')
    actualName = mc.spaceLocator (n= wantedName)
    mc.move (cvPos[0],cvPos[1],cvPos[2], [actualName[0]])
    influenceObjects = queryInfluences (skinCluster)
    culledList = influenceObjects
    """figure out our closest objects"""
    bestChoices = []
    cnt = 5
    while cnt >= 0:
        goodChoice =  (distance.returnClosestObjToCV (cv, culledList))
        culledList.remove(goodChoice)
        bestChoices.append (goodChoice)
        print bestChoices
        cnt-=1
    distanceList = []
    for obj in bestChoices:
        distanceList.append (distance.returnDistanceBetweenObjects(actualName[0],obj))
        print distanceList
    """ return normalization value """
    buffer=0
    y = 1 + (x-A)*(10-1)/(B-A)
    for value in distanceList:
        buffer += value
    print buffer
    normalize = ((len(distanceList))*.1)
    print normalize
    mc.delete (actualName[0])
Ejemplo n.º 5
0
def simpleControlSurfaceSmoothWeights(surface,maxBlend = 3):
    """
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Early version of a weight smoother for a

    ARGUMENTS:
    surface(string)

    RETURNS:
    Nada
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    cvList = (mc.ls ([surface+'.cv[*][*]'],flatten=True))
    skinCluster = querySkinCluster (surface)
    influenceObjects = queryInfluences (skinCluster)

    #find the closest influence object to the start
    startObject =  (distance.returnClosestObjToCV (cvList[0], influenceObjects))
    #find the closest influence object to the end
    endObject = (distance.returnClosestObjToCV (cvList[-1], influenceObjects))
    #getting the last cv list number
    cvChainLength =  ((len(cvList)-1)/2)

    #Smooth interior weights
    """ get our interior CVs """
    interiorCvList = []
    cnt = 1
    for i in range(cvChainLength):
        interiorCvList.append('%s%s%i%s' % (surface,'.cv[0][',cnt,']'))
        interiorCvList.append('%s%s%i%s' % (surface,'.cv[1][',cnt,']'))
        cnt += 1

    """ overall blend """
    for cv in interiorCvList:
        closestObject = (distance.returnClosestObjToCV (cv, influenceObjects))
        closestObjectsDict = distance.returnClosestObjectsFromAim(closestObject,influenceObjects)
        upObjects = closestObjectsDict.get('up')
        downObjects = closestObjectsDict.get('dn')
        objectsToCheck = []
        if upObjects != None:
            objectsToCheck += upObjects
        if downObjects != None:
            objectsToCheck += downObjects
        blendInfluences =[]
        blendInfluences.append(closestObject)
        distances = []
        cnt = 1
        print objectsToCheck
        while cnt < maxBlend and cnt < len(objectsToCheck):
            closestSubObj = distance.returnClosestObject(closestObject, objectsToCheck)
            blendInfluences.append(closestSubObj)
            objectsToCheck.remove(closestSubObj)
            cnt+=1

        """ get our distances to normalize """
        locBuffer = locators.locMeSurfaceCV(cv)
        for obj in blendInfluences:
            distances.append(distance.returnDistanceBetweenObjects(locBuffer,obj))
        normalizedDistances = cgmMath.normList(distances, normalizeTo=1)
        cnt = 0
        for obj in blendInfluences:
            mc.skinPercent (skinCluster,cv, tv = [obj,normalizedDistances[cnt]])
            cnt +=1
        mc.delete(locBuffer)

    """ Set closest cv's to respective infuences to max """
    cvList1 = []
    cvList2 = []
    for i in range(cvChainLength):
        cvList1.append('%s%s%i%s' % (surface,'.cv[0][',cnt,']'))
        cvList2.append('%s%s%i%s' % (surface,'.cv[1][',cnt,']'))
        cnt += 1
    for obj in influenceObjects:
        closestCV1 = distance.returnClosestCVFromList(obj, cvList1)
        mc.skinPercent (skinCluster,closestCV1, tv = [obj,1])
        closestCV2 = distance.returnClosestCVFromList(obj, cvList2)
        mc.skinPercent (skinCluster,closestCV2, tv = [obj,1])

    #set the skin weights for the top and bottom
    mc.skinPercent (skinCluster,(surface+'.cv[0:1][0:1]'), tv = [startObject,1])
    mc.skinPercent (skinCluster,('%s%s%i%s%i%s' % (surface,'.cv[0:1][',(cvChainLength-1),':',cvChainLength,']')), tv = [endObject,1])
    #Blend in the nearest row to the start and end
    mc.skinPercent (skinCluster,(surface+'.cv[0:1][2]'), tv = [startObject,1])
    mc.skinPercent (skinCluster,('%s%s%i%s' % (surface,'.cv[0:1][',(cvChainLength-2),']')), tv = [endObject,1])

    mc.skinPercent (skinCluster,(surface+'.cv[0:1][3]'), tv = [startObject,.7])
    mc.skinPercent (skinCluster,('%s%s%i%s' % (surface,'.cv[0:1][',(cvChainLength-3),']')), tv = [endObject,.7])
Ejemplo n.º 6
0
def simpleControlSurfaceSmoothWeights(surface,maxBlend = 3):
    """
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Early version of a weight smoother for a

    ARGUMENTS:
    surface(string)

    RETURNS:
    Nada
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    cvList = (mc.ls ([surface+'.cv[*][*]'],flatten=True))
    skinCluster = querySkinCluster (surface)
    influenceObjects = queryInfluences (skinCluster)

    #find the closest influence object to the start
    startObject =  (distance.returnClosestObjToCV (cvList[0], influenceObjects))
    #find the closest influence object to the end
    endObject = (distance.returnClosestObjToCV (cvList[-1], influenceObjects))
    #getting the last cv list number
    cvChainLength =  ((len(cvList)-1)/2)

    #Smooth interior weights
    """ get our interior CVs """
    interiorCvList = []
    cnt = 1
    for i in range(cvChainLength):
        interiorCvList.append('%s%s%i%s' % (surface,'.cv[0][',cnt,']'))
        interiorCvList.append('%s%s%i%s' % (surface,'.cv[1][',cnt,']'))
        cnt += 1

    """ overall blend """
    for cv in interiorCvList:
        closestObject = (distance.returnClosestObjToCV (cv, influenceObjects))
        closestObjectsDict = distance.returnClosestObjectsFromAim(closestObject,influenceObjects)
        upObjects = closestObjectsDict.get('up')
        downObjects = closestObjectsDict.get('dn')
        objectsToCheck = []
        if upObjects != None:
            objectsToCheck += upObjects
        if downObjects != None:
            objectsToCheck += downObjects
        blendInfluences =[]
        blendInfluences.append(closestObject)
        distances = []
        cnt = 1
        print objectsToCheck
        while cnt < maxBlend and cnt < len(objectsToCheck):
            closestSubObj = distance.returnClosestObject(closestObject, objectsToCheck)
            blendInfluences.append(closestSubObj)
            objectsToCheck.remove(closestSubObj)
            cnt+=1

        """ get our distances to normalize """
        locBuffer = locators.locMeSurfaceCV(cv)
        for obj in blendInfluences:
            distances.append(distance.returnDistanceBetweenObjects(locBuffer,obj))
        normalizedDistances = cgmMath.normList(distances, normalizeTo=1)
        cnt = 0
        for obj in blendInfluences:
            mc.skinPercent (skinCluster,cv, tv = [obj,normalizedDistances[cnt]])
            cnt +=1
        mc.delete(locBuffer)

    """ Set closest cv's to respective infuences to max """
    cvList1 = []
    cvList2 = []
    for i in range(cvChainLength):
        cvList1.append('%s%s%i%s' % (surface,'.cv[0][',cnt,']'))
        cvList2.append('%s%s%i%s' % (surface,'.cv[1][',cnt,']'))
        cnt += 1
    for obj in influenceObjects:
        closestCV1 = distance.returnClosestCVFromList(obj, cvList1)
        mc.skinPercent (skinCluster,closestCV1, tv = [obj,1])
        closestCV2 = distance.returnClosestCVFromList(obj, cvList2)
        mc.skinPercent (skinCluster,closestCV2, tv = [obj,1])

    #set the skin weights for the top and bottom
    mc.skinPercent (skinCluster,(surface+'.cv[0:1][0:1]'), tv = [startObject,1])
    mc.skinPercent (skinCluster,('%s%s%i%s%i%s' % (surface,'.cv[0:1][',(cvChainLength-1),':',cvChainLength,']')), tv = [endObject,1])
    #Blend in the nearest row to the start and end
    mc.skinPercent (skinCluster,(surface+'.cv[0:1][2]'), tv = [startObject,1])
    mc.skinPercent (skinCluster,('%s%s%i%s' % (surface,'.cv[0:1][',(cvChainLength-2),']')), tv = [endObject,1])

    mc.skinPercent (skinCluster,(surface+'.cv[0:1][3]'), tv = [startObject,.7])
    mc.skinPercent (skinCluster,('%s%s%i%s' % (surface,'.cv[0:1][',(cvChainLength-3),']')), tv = [endObject,.7])