コード例 #1
0
def createCondition(inputOne,inputOneType,inputTwo,inputTwoType,conditionType,outputTrue,outputTrueType,outputFalse,outputFalseType):
    conditionNode = shadingNode('condition',asUtility=True)
    if inputOneType == 'value':
        conditionNode.setAttr('firstTerm',inputOne)
    elif inputOneType == 'connection':
        connectAttr(inputOne,conditionNode+'.firstTerm')
    if inputTwoType == 'value':
        conditionNode.setAttr('secondTerm',inputTwo)
    elif inputTwoType == 'connection':
        connectAttr(inputTwo,conditionNode+'.secondTerm')
    if conditionType == '=':
        conditionNode.setAttr('operation', 0)
    elif conditionType == '!=':
        conditionNode.setAttr('operation', 1)
    elif conditionType == '>':
        conditionNode.setAttr('operation', 2)
    elif conditionType == '>=':
        conditionNode.setAttr('operation', 3)
    elif conditionType == '<':
        conditionNode.setAttr('operation', 4)
    elif conditionType == '<=':
        conditionNode.setAttr('operation', 5)
    if outputTrueType == 'value':
        conditionNode.setAttr('colorIfTrueR',outputTrue)
    elif outputTrueType == 'connection':
        connectAttr(outputTrue,conditionNode+'.colorIfTrueR')
    if outputFalseType == 'value':
        conditionNode.setAttr('colorIfFalseR',outputFalse)
    elif outputFalseType == 'connection':
        connectAttr(outputFalse,conditionNode+'.colorIfFalseR')
    return conditionNode
コード例 #2
0
def createMultiplyDivide(inputOne,inputOneType,inputTwo,inputTwoType,operationType):
    mathNode = shadingNode('multiplyDivide',asUtility=True)
    if inputOneType == 'value':
        mathNode.setAttr('input1X',inputOne)
    elif inputOneType == 'connection':
        connectAttr(inputOne,mathNode+'.input1X')
    if inputTwoType == 'value':
        mathNode.setAttr('input2X',inputTwo)
    elif inputTwoType == 'connection':
        connectAttr(inputTwo,mathNode+'.input2X')
    if operationType == '*':
        mathNode.setAttr('operation',1)
    elif operationType == '/':
        mathNode.setAttr('operation',2)
    elif operationType == '^':
        mathNode.setAttr('operation',3)
    return mathNode
コード例 #3
0
def createBlendNode(inputOne,inputTwo,output):
    myNode = shadingNode('blendTwoAttr',asUtility=True)
    connectAttr(inputOne,myNode.name()+'.input[0]',f=True)
    connectAttr(inputTwo,myNode.name()+'.input[1]',f=True)
    disconnectAttr(inputOne, output)
    connectAttr(myNode+'.output',output,f=True)        
    return myNode
コード例 #4
0
def createPlusMinusAvgNode(inputOne,inputTwo,output):
    myNode = shadingNode('plusMinusAverage',asUtility=True)
    connectAttr(inputOne,myNode.name()+'.input1D[0]',f=True)
    connectAttr(inputTwo,myNode.name()+'.input1D[1]',f=True)
    connectAttr(myNode+'.output1D',output,f=True)
    return myNode
コード例 #5
0
def createRibbonSpine(prefix,numJoints,botCtlScale,midCtlScale,topCtlScale,fkCtlScale,ribbonRotY,ctlColor):
    rc101 = rig101wireControllers.rig101()
    bindJoints = []
    fkControls = []
    fkControlNulls = []
    controlJoints = []
    ribbonSpineGrp = group(n=prefix+'RibbonSpine_GRP')
    #create a nurbs plane with a number of divisions equal to the joints
    ribbonPlane = nurbsPlane(u=1,v=numJoints,d=3,w=1,lr=numJoints,name=prefix+'RibbonSplineIK_SRF')
    ribbonPlane[0].ry.set(ribbonRotY)
    ribbonPlane[0].setAttr('visibility',0)
    ribbonPlane[0].setParent(ribbonSpineGrp)
    rebuildSurface(dir=0,du=1,su=1)
    bakePartialHistory(ribbonPlane[0],prePostDeformers=True)
    makeIdentity(apply=True,r=True,s=True)
    mel.eval('createHair 1 '+str(numJoints)+' 10 0 0 0 0 5 0 2 1 1;')
    #remove unnecessary hair nodes
    delete('hairSystem1')
    delete('hairSystem1OutputCurves')
    follicleGrp = PyNode('hairSystem1Follicles')
    follicleGrp.setParent(ribbonSpineGrp)
    follicles = follicleGrp.getChildren()
    follicleGrp.rename(prefix+'RibbonSplineFollicles_GRP')
    #create the bind joints and parent them under the corresponding follicle node
    for i in range(numJoints):
        follicles[i].rename(prefix+'RibbonSplineFollicle'+str(i)+'_FLC')
        bindJoints.append( joint(a=True,p=follicles[i].getTranslation(space='world'),rad=0.5,n=prefix+'RibbonSpline_BIND_'+str(i)+'_JNT') )
        bindJoints[-1].setParent(follicles[i])
        fkControls.append(rc101.rig101WC2NailLong())
        fkControls[-1].rename(prefix+'RibbonSpine_FK'+str(i+1)+'_CTL')
        fkControls[-1].setTranslation(bindJoints[-1].getTranslation(space='world'))
        fkControls[-1].ry.set(ribbonRotY)
        fkControls[-1].setScale((fkCtlScale,fkCtlScale,fkCtlScale))
        setControllerColor(fkControls[-1], ctlColor)
        select(fkControls[-1],r=True)
        makeIdentity(apply=True,r=True,s=True)
        fkControlNulls.append(makeHomeNull(fkControls[-1]))
        fkControlNulls[-1].setParent(ribbonSpineGrp)
        #orientConstraint(fkControls[-1],bindJoints[-1],mo=True)
        #pointConstraint(fkControls[-1],bindJoints[-1],mo=True)
        parentConstraint(fkControls[-1],bindJoints[-1],mo=True)
        parentConstraint(follicles[i],bindJoints[-1],mo=True)
        parentConstraint(follicles[i],fkControlNulls[-1],mo=True)
        lockHideAttrs(fkControls[-1], False, False, False, False, False, False, True, True, True, True)
        select(cl=True)
    #create the control joints used by controllers to deform the ribbon spine
    controlJoints.append(joint(a=True,p=(0,-numJoints/2.0,0),rad=1.0,n=prefix+'RibbonSpline_bottomDriver0_JNT'))
    controlJoints[0].setAttr('visibility',0)
    controlJoints.append(joint(a=True,p=(0,-numJoints/2.0+numJoints/4.0,0),rad=1.0,n=prefix+'RibbonSpline_bottomDriver1_JNT'))
    controlJoints[1].setAttr('visibility',0)
    select(cl=True)
    controlJoints.append(joint(a=True,p=(0,0,0),rad=1.0,n=prefix+'RibbonSpline_middleDriver0_JNT'))
    controlJoints[2].setAttr('visibility',0)
    select(cl=True)
    controlJoints.append(joint(a=True,p=(0,numJoints/2.0,0),rad=1.0,n=prefix+'RibbonSpline_topDriver0_JNT'))
    controlJoints[3].setAttr('visibility',0)
    controlJoints.append(joint(a=True,p=(0,numJoints/2.0-numJoints/4.0,0),rad=1.0,n=prefix+'RibbonSpline_topDriver1_JNT'))
    controlJoints[4].setAttr('visibility',0)
    select(cl=True)
    #create bottom controller and locators
    bottomControl = circle(nr=(0,1,0),name=prefix+'RibbonSpine_Bottom_CTL')
    bottomControl[0].setTranslation(controlJoints[0].getTranslation(space='world'))
    bottomControl[0].setScale((botCtlScale,botCtlScale,botCtlScale))
    setControllerColor(bottomControl[0], ctlColor)
    makeIdentity(s=True,apply=True)
    lockHideAttrs(bottomControl[0], False, False, False, False, False, False, True, True, True, True)
    bottomControlNull = makeHomeNull(bottomControl[0])
    bottomControlNull.setParent(ribbonSpineGrp)
    bottomAim = spaceLocator(r=False,n=prefix+'RibbonSpine_bottomAim_LOC')
    bottomAim.setTranslation(bottomControl[0].getTranslation(space='world'))
    bottomAim.setParent(bottomControl[0])
    bottomAim.setAttr('visibility',0)
    bottomUp = spaceLocator(r=False,n=prefix+'RibbonSpine_bottomUp_LOC')
    bottomUp.setTranslation(bottomControl[0].getTranslation(space='world'))
    bottomUp.translateBy((1,0,0))
    bottomUp.setParent(bottomControl[0])
    bottomUp.setAttr('visibility',0)
    #create top controller and locators
    topControl = circle(nr=(0,1,0),name=prefix+'RibbonSpine_Top_CTL')
    topControl[0].setTranslation(controlJoints[3].getTranslation(space='world'))
    topControl[0].setScale((topCtlScale,topCtlScale,topCtlScale))
    setControllerColor(topControl[0], ctlColor)
    makeIdentity(s=True,apply=True)
    lockHideAttrs(topControl[0], False, False, False, False, False, False, True, True, True, True)
    topControlNull = makeHomeNull(topControl[0])
    topControlNull.setParent(ribbonSpineGrp)
    topAim = spaceLocator(r=False,n=prefix+'RibbonSpine_topAim_LOC')
    topAim.setTranslation(topControl[0].getTranslation(space='world'))
    topAim.setParent(topControl[0])
    topAim.setAttr('visibility',0)
    topUp = spaceLocator(r=False,n=prefix+'RibbonSpine_topUp_LOC')
    topUp.setTranslation(topControl[0].getTranslation(space='world'))
    topUp.translateBy((1,0,0))
    topUp.setParent(topControl[0])
    topUp.setAttr('visibility',0)
    #create middle controller and locators
    midControl = circle(nr=(0,1,0),name=prefix+'RibbonSpine_Mid_CTL')
    midControl[0].setTranslation(controlJoints[2].getTranslation(space='world'))
    midControl[0].setAttr('rotateY',keyable=False)
    midControl[0].setScale((midCtlScale,midCtlScale,midCtlScale))
    setControllerColor(midControl[0], ctlColor)
    makeIdentity(s=True,apply=True)
    lockHideAttrs(midControl[0], False, False, False, False, False, False, True, True, True, True)
    midControlNull = makeHomeNull(midControl[0])
    midControlNull.setParent(ribbonSpineGrp)
    #midAim = spaceLocator(r=False,n=prefix+'RibbonSpine_midAim_LOC')
    #midAim.setTranslation(midControl[0].getTranslation(space='world'))
    #midAim.setParent(midControl[0])
    #midAim.setAttr('visibility',0)
    #midUp = spaceLocator(r=False,n=prefix+'RibbonSpine_midUp_LOC')
    #midUp.setTranslation(midControl[0].getTranslation(space='world'))
    #midUp.translateBy((1,0,0))
    #midUp.setParent(midControl[0])
    #midUp.setAttr('visibility',0)
    #parent the control joints under their corresponding aim locators
    controlJoints[0].setParent(bottomAim)
    #controlJoints[2].setParent(midAim)
    controlJoints[2].setParent(midControl[0])
    controlJoints[3].setParent(topAim)
    #aim constrain the aim locators to the controller on the opposite side
    aimConstraint(topControl[0],bottomAim,aim=(0,1,0),upVector=(1,0,0),worldUpType='object',worldUpObject=bottomUp)
    aimConstraint(bottomControl[0],topAim,aim=(0,-1,0),upVector=(1,0,0),worldUpType='object',worldUpObject=topUp)
    #point constrain the bottom and top controllers to the middle control group
    pointConstraint(topControl[0],bottomControl[0],midControlNull,mo=True)
    #aimConstraint(topControl[0],midAim,aim=(0,1,0),upVector=(1,0,0),worldUpType='object',worldUpObject=midUp)
    #bind the ribbon plane to the control joints
    jointList = (controlJoints[0],controlJoints[2],controlJoints[3])
    ribbonSkin = skinCluster(jointList,ribbonPlane[0],mi=2,dr=4,tsb=True,rui=True,n=ribbonPlane[0]+'_skinCluster')
    #set skin percentages
    for i in range(numJoints+3):
        tVals = []
        for skinJoint in jointList:
            weight = None
            if numJoints == 5:
                if skinJoint == jointList[0]:
                    if i == 0:
                        weight = 1.0
                    elif i == 1:
                        weight = 0.9
                    elif i == 2:
                        weight = 0.6
                    elif i == 3:
                        weight = 0.2
                    else:
                        weight = 0.0
                elif skinJoint == jointList[1]:
                    if i == 1 or i == 6:
                        weight = 0.1
                    elif i == 2 or i == 5:
                        weight = 0.4
                    elif i == 3 or i == 4:
                        weight = 0.8
                    else:
                        weight = 0.0
                elif skinJoint == jointList[2]:
                    if i == 4:
                        weight = 0.2
                    elif i == 5:
                        weight = 0.6
                    elif i == 6:
                        weight = 0.9
                    elif i == 7:
                        weight = 1.0
                    else:
                        weight = 0.0
            if numJoints == 3:
                if skinJoint == jointList[0]:
                    if i == 0:
                        weight = 1.0
                    elif i == 1:
                        weight = 0.8
                    elif i == 2:
                        weight = 0.1
                    else:
                        weight = 0.0
                elif skinJoint == jointList[1]:
                    if i == 4 or i == 1:
                        weight = 0.2
                    elif i == 3 or i == 2:
                        weight = 0.9
                    else:
                        weight = 0.0
                elif skinJoint == jointList[2]:
                    if i == 3:
                        weight = 0.1
                    elif i == 4:
                        weight = 0.8
                    elif i == 5:
                        weight = 1.0
                    else:
                        weight = 0.0
            tVals.append((skinJoint,weight))
        skinPercent(ribbonSkin,ribbonPlane[0]+'.cv[0]['+str(i)+']',ribbonPlane[0]+'.cv[1]['+str(i)+']', transformValue=tVals)
    connectAttr(topControl[0]+'.rotate',controlJoints[3]+'.rotate',f=True)
    connectAttr(midControl[0]+'.rotate',controlJoints[2]+'.rotate',f=True)
    connectAttr(bottomControl[0]+'.rotate',controlJoints[0]+'.rotate',f=True)
    expression(s=midControl[0]+'.rotateY = ('+topControl[0]+'.rotateY + '+bottomControl[0]+'.rotateY) / 2',n=prefix+'RibbonSpineTwist_EXP')
    ikControls = [bottomControl[0],midControl[0],topControl[0]]
    return [bottomControlNull,topControlNull,ribbonSpineGrp,ikControls,midControlNull,fkControlNulls,follicleGrp,bindJoints]
コード例 #6
0
def createDistanceBetween(nodeOne,nodeTwo):
    distNode = shadingNode('distanceBetween',asUtility=True)
    connectAttr(nodeOne+'.translate',distNode+'.point1',f=True)
    connectAttr(nodeTwo+'.translate',distNode+'.point2',f=True)
    return distNode