Beispiel #1
0
 def _water(self):
     node = cmds.shadingNode('water', asTexture=True)
     tex = cmds.shadingNode('place2dTexture', asUtility=True)
     cmds.connectAttr(tex + '.outUV', node + '.uvCoord')
     cmds.connectAttr(tex + '.outUvFilterSize', node + '.uvFilterSize')
     cmds.setAttr(tex + '.repeatU', 1)
     cmds.setAttr(tex + '.repeatV', 1)
Beispiel #2
0
def substanceOutput():
    node = cmds.shadingNode('substanceOutput', asTexture=True)
    tex = cmds.shadingNode('place2dTexture', asUtility=True)
    cmds.connectAttr(tex + '.outUV', node + '.uvCoord')
    cmds.connectAttr(tex + '.outUvFilterSize', node + '.uvFilterSize')
    cmds.setAttr(tex + '.repeatU', 1)
    cmds.setAttr(tex + '.repeatV', 1)
Beispiel #3
0
def grid():
    node = cmds.shadingNode('grid', asTexture=True)
    tex = cmds.shadingNode('place2dTexture', asUtility=True)
    cmds.connectAttr(tex + '.outUV', node + '.uvCoord')
    cmds.connectAttr(tex + '.outUvFilterSize', node + '.uvFilterSize')
    cmds.setAttr(tex + '.repeatU', 4)
    cmds.setAttr(tex + '.repeatV', 4)
Beispiel #4
0
def createShader(textureNode, shaderType='blinn', fromColour=False, fromNormal=True, fromSpecular=True):

    if fromColour and fromNormal and fromSpecular:
        raise UserWarning('You have to choose which component to start from')
    if not fromColour and not fromNormal and not fromSpecular:
        raise UserWarning('You have to choose which component to start from')
    if not fromColour and fromNormal and fromSpecular:
        raise UserWarning('You have to choose which component to start from')
       
    colorTexture = textureNode
    alphaTexture = textureNode
    normalTexture = textureNode
    specularTexture = textureNode
    
    if shaderType == 'blinn':
        # createShader and shadingGroup
        shader = cmds.shadingNode('blinn', asShader=True)
        shadingGroup = cmds.sets(shader)
    if fromColour and fromSpecular:
        # create bump/normal node
        bumpNode = cmds.shadingNode('bump2d', asUtility=True)
        cmds.setAttr(bumpNode+'.bumpInterp', 1)
        # connect normal map to bump node
        cmds.connectAttr(normalTexture+'.outAlpha', bumpNode+'.bumpValue')
        # connect bump to shader
        cmds.connectAttr(bumpNode+'.outNormal', shader+'.normalCamera')
def blendS(name, fk, ik, child):
    cmds.shadingNode( 'blendColors', n=name, au=True)
    cmds.connectAttr( '%s.scale' % fk , '%s.color1' % name)
    cmds.connectAttr( '%s.scale' % ik , '%s.color2' % name)
    cmds.connectAttr('%s.output' % name, '%s.scale' % child)
    cmds.setAttr('%s.blender' % name, 0)
    return name
Beispiel #6
0
 def updateColor(self, mID, colorname):
     """
     Update the color of the Maya's Mesh Node associated with a this
     StrandItem, this is done by creating a shadingNode for each color or
     connecting the Mesh Mode to an existing shadingNode if one exists
     for a given color.
     """
     m = Mom()
     meshName = "%s%s" % (m.helixMeshName, mID)
     color = QColor(colorname)
     colorval = "%d_%d_%d" % (color.red(), color.green(), color.blue())
     shaderName = "%s%d_%d_%d" % (m.helixShaderName, color.red(),
                                               color.green(),
                                               color.blue())
     if not cmds.objExists(shaderName):
         # Shader does not exist create one
         cmds.shadingNode('lambert', asShader=True, name=shaderName)
         cmds.sets(n="%sSG" % shaderName, r=True, nss=True, em=True)
         cmds.connectAttr("%s.outColor" % shaderName,
                          "%sSG.surfaceShader" % shaderName)
         cmds.setAttr("%s.color" % shaderName,
                      color.redF(), color.greenF(), color.blueF(),
                      type="double3")
         cmds.sets(meshName, forceElement="%sSG" % shaderName)
     else:
         #shader exist connect
         cmds.sets(meshName, forceElement="%sSG" % shaderName)
Beispiel #7
0
    def createShaders(self):
        """Create only once the different shaders used to bake for the different modes"""
        if not self.prepared:
            # OCC
            self.occ = cmds.createNode('ilrOccSampler') # create shader
            self.occSG = cmds.sets(renderable=True, noSurfaceShader=True, empty=True, name=self.occ + 'SG')
            cmds.connectAttr(self.occ + '.outColor', self.occSG + '.surfaceShader', force=True)

            # THICKNESS
            thickShader = cmds.shadingNode('surfaceShader', asShader=True)
            self.thickSG = cmds.sets(renderable=True, noSurfaceShader=True, empty=True, name=thickShader + 'SG')
            cmds.connectAttr(thickShader + '.outColor', self.thickSG + '.surfaceShader', force=True)
            self.thick = cmds.shadingNode('ilrSurfaceThickness', asUtility=True)
            cmds.connectAttr(self.thick + '.outThickness', thickShader + '.outColor', force=True)

            # DIRT
            nodes = cmds.file('path_to_your_file_shader.ma', reference=True, returnNewNodes=True, namespace='DIRT')
            self.dirt = cmds.ls(nodes, type='surfaceShader')[0]
            self.dirtSG = tdLib.getFirstItem(cmds.listConnections(self.dirt + '.outColor', source=False))
            if not self.dirtSG:
                self.dirtSG = cmds.sets(renderable=True, noSurfaceShader=True, empty=True, name=self.dirt + 'SG')
                cmds.connectAttr(self.dirt + '.outColor', self.dirtSG + '.surfaceShader', force=True)
            self.dirt = self.dirtSG

            # RGB
            self.rgb = cmds.shadingNode('surfaceShader', asShader=True)
            self.rgbSG = cmds.sets(renderable=True, noSurfaceShader=True, empty=True, name=self.rgb + 'SG')
            cmds.connectAttr(self.rgb + '.outColor', self.rgbSG + '.surfaceShader', force=True)

            self.prepared = True
def linkFileToSpecular(src, dst):
    cmds.shadingNode('remapHsv', n = '%s_remapHsc'%dst, au = 1)
    cmds.shadingNode('solidFractal', n = '%s_solidFractal'%dst, at = 1)
    cmds.shadingNode('place3dTexture', n = '%s_place3dTexture'%dst, at = 1)
    cmds.shadingNode('multiplyDivide', n = '%s_multiplyDivide'%dst, au = 1)
    cmds.shadingNode('ramp', n = '%s_ramp'%dst, at = 1)
    cmds.setAttr('%s.saturation[1].saturation_Position'%('%s_remapHsc'%dst), 1)
    cmds.setAttr('%s.saturation[1].saturation_FloatValue'%('%s_remapHsc'%dst), 0)
    cmds.setAttr('%s.value[0].value_FloatValue'%('%s_remapHsc'%dst), 0)
    cmds.setAttr('%s.value[0].value_Position'%('%s_remapHsc'%dst), 0.025)
    cmds.setAttr('%s.value[1].value_FloatValue'%('%s_remapHsc'%dst), 1)
    cmds.setAttr('%s.value[1].value_Position'%('%s_remapHsc'%dst), 0.075)
    cmds.connectAttr('%s.worldInverseMatrix[0]'%('%s_place3dTexture'%dst), '%s.placementMatrix'%('%s_solidFractal'%dst), f = 1)
    cmds.connectAttr('%s.outColor'%src, '%s.color'%('%s_remapHsc'%dst), f = 1)
    cmds.connectAttr('%s.outColor'%('%s_remapHsc'%dst), '%s.input1'%('%s_multiplyDivide'%dst), f = 1)
    cmds.connectAttr('%s.outColor'%('%s_solidFractal'%dst), '%s.input2'%('%s_multiplyDivide'%dst), f = 1)
    cmds.connectAttr('%s.output'%('%s_multiplyDivide'%dst), '%s.colorGain'%('%s_ramp'%dst), f = 1)
    if cmds.nodeType(dst) == 'RedshiftArchitectural':
        # cmds.disconnectAttr('%s.outColor'%(src), '%s.diffuse'%dst)
        cmds.connectAttr('%s.outColor'%('%s_ramp'%dst), '%s.refl_color'%dst, f = 1)
    elif cmds.nodeType(dst) == 'aiStandard':
        # cmds.disconnectAttr('%s.outColor'%(src), '%s.color'%dst)
        cmds.connectAttr('%s.outColor'%('%s_ramp'%dst), '%s.KsColor'%dst, f = 1)
        # cmds.connectAttr('%s.outColor'%('%s_ramp'%dst), '%s.color'%dst, f = 1)
    else:
        # cmds.disconnectAttr('%s.outColor'%(src), '%s.color'%dst)
        cmds.connectAttr('%s.outColor'%('%s_ramp'%dst), '%s.reflectedColor'%dst, f = 1)
        # cmds.connectAttr('%s.outColor'%('%s_ramp'%dst), '%s.color'%dst, f = 1)
    linkTopRemapNodeToAll('%s_ramp'%dst)
    getRemapAndMutilplyNodes(dst)
    def createDecoratorNodes(self, coords, mID):
        """Create a actual Maya Nodes for a new Pre-Decortators"""
        m = Mom()
        stapleModIndicatorName = "%s%s" % (m.decoratorNodeName, mID)
        transformName = "%s%s" % (m.decoratorTransformName, mID)
        meshName = "%s%s" % (m.decoratorMeshName, mID)
        shaderName = "%s" % m.decoratorShaderName

        cmds.createNode("transform", name=transformName, skipSelect=True)
        cmds.setAttr("%s.rotateX" % transformName, 90)
        cmds.setAttr("%s.translateX" % transformName, coords[0])
        cmds.setAttr("%s.translateY" % transformName, coords[1])
        cmds.setAttr("%s.translateZ" % transformName, coords[2])
        cmds.createNode("mesh", name=meshName, parent=transformName, skipSelect=True)
        # cmds.createNode("spPreDecoratorNode", name=stapleModIndicatorName)
        cmds.createNode("polySphere", name=stapleModIndicatorName, skipSelect=True)
        cmds.setAttr("%s.radius" % stapleModIndicatorName, 0.25)
        cmds.setAttr("%s.subdivisionsAxis" % stapleModIndicatorName, 4)
        cmds.setAttr("%s.subdivisionsHeight" % stapleModIndicatorName, 4)

        # cmds.connectAttr("%s.outputMesh" % stapleModIndicatorName,
        #                 "%s.inMesh" % meshName)
        cmds.connectAttr("%s.output" % stapleModIndicatorName, "%s.inMesh" % meshName)

        if not cmds.objExists(shaderName):
            # Shader does not exist create one
            cmds.shadingNode("lambert", asShader=True, name=shaderName)
            cmds.sets(n="%sSG" % shaderName, r=True, nss=True, em=True)
            cmds.connectAttr("%s.outColor" % shaderName, "%sSG.surfaceShader" % shaderName)
            cmds.setAttr("%s.color" % shaderName, 0.0, 0.0, 0.0, type="double3")
            cmds.sets(meshName, forceElement="%sSG" % shaderName)
        else:
            # shader exist connect
            cmds.sets(meshName, forceElement="%sSG" % shaderName)
        return (stapleModIndicatorName, transformName, meshName, shaderName)
Beispiel #10
0
def ImportCustomTexture(name):
	
	os.system("cd ~/maya/2014-x64/scripts; python texture.py")
	
	file = '/usr/tmp/texture.jpg'
	
	#create a shader
	shader=cmds.shadingNode( "blinn", asShader=True )

	#a file texture node
	shaderName = file_node=cmds.shadingNode( "file", asTexture=True )
	
	print shaderName
	
	#attach file to node
	cmds.setAttr( '%s.fileTextureName' %file_node, file, type = "string")
 
	# a shading group
	shading_group= cmds.sets(renderable=True,noSurfaceShader=True,empty=True)

	#connect shader to sg surface shader
	cmds.connectAttr('%s.outColor' %shader ,'%s.surfaceShader' %shading_group)

	#connect file texture node to shader's color
	cmds.connectAttr('%s.outColor' %file_node, '%s.color' %shader)

	cmds.sets(name, edit=True, forceElement=shading_group)
 def CreateUVMaterial():
     try:
         cmds.delete("UVShader")
     except:
         pass
     
     try:
         cmds.delete("UVShaderSG")
     except:
         pass
     
     try:
         cmds.delete("CheckerMap")
     except:
         pass
     
     try:
         cmds.delete("TexturePlacer")
     except:
         pass
     
     material = cmds.shadingNode('lambert', asShader=1, name='UVShader')
     SG = cmds.sets(renderable=1, noSurfaceShader=1, empty=1, name = 'UVShaderSG')   
     cmds.connectAttr((material + '.outColor'),(SG + '.surfaceShader'),f=1)
     
     cmds.shadingNode("file", asTexture = True, name = "CheckerMap" )
     cmds.setAttr("CheckerMap.fileTextureName", os.path.expanduser('~/maya/Turbosquid/CheckMate Tools For Maya/CM_Tools/') + "ash_uvgrid.jpg", type = "string")
    
     cmds.connectAttr(  "CheckerMap.outColor", "UVShader.color", force = True)
Beispiel #12
0
 def _VRayWater(self):
     node = cmds.shadingNode("VRayWater", asTexture=True)
     tex = cmds.shadingNode("place2dTexture", asUtility=True)
     cmds.connectAttr(tex + ".outUV", node + ".uvCoord")
     cmds.connectAttr(tex + ".outUvFilterSize", node + ".uvFilterSize")
     cmds.setAttr(tex + ".repeatU", 1)
     cmds.setAttr(tex + ".repeatV", 1)
 def createDistanceCalculations(self, rootLocator, endLocator, containedNodes):
     rootLocatorName = utils.stripAllNamespaces(rootLocator)[1]
     endLocatorName = utils.stripAllNamespaces(endLocator)[1]
     distNode = cmds.shadingNode("distanceBetween", asUtility=True, n=self.blueprintNamespace+":"+self.moduleNamespace+":distanceBetween_" + rootLocatorName + "__" + endLocatorName)
     containedNodes.append(distNode)
     
     rootLocShape = rootLocator+"Shape"
     endLocShape = endLocator+"Shape"
     
     cmds.connectAttr(rootLocShape+".worldPosition[0]", distNode+".point1")
     cmds.connectAttr(endLocShape+".worldPosition[0]", distNode+".point2")
     
     totalOriginalLength = cmds.getAttr(distNode+".distance")
     totalOriginalLength /= cmds.getAttr(self.blueprintNamespace+":module_grp.hierarchicalScale")
     
     scaleFactor = cmds.shadingNode("multiplyDivide", asUtility=True, n=distNode+"_scaleFactor")
     containedNodes.append(scaleFactor)
     
     cmds.setAttr(scaleFactor+".operation", 2) # Divide
     cmds.connectAttr(distNode+".distance", scaleFactor+".input1X")
     cmds.setAttr(scaleFactor+".input2X", totalOriginalLength)
     
     scaleCorrection = cmds.shadingNode("multiplyDivide", asUtility=True, n=scaleFactor+"_correction")
     containedNodes.append(scaleCorrection)
     
     cmds.setAttr(scaleCorrection+".operation", 2) #Divide
     cmds.connectAttr(scaleFactor+".outputX", scaleCorrection+".input1X")
     cmds.connectAttr(self.blueprintNamespace+":module_grp.hierarchicalScale", scaleCorrection+".input2X")
     
     return scaleCorrection+".outputX"
def assignVrayShaders(chromnBall,grayBall,whiteBall):
    #create and assign chromn ball shader
    chromnBallShader = mc.shadingNode('VRayMtl', asShader = True, n = "mat_chromnBall")
    chromnBallSG = mc.sets(n = chromnBallShader + "SG", renderable = True, noSurfaceShader = True, empty = True)
    mc.connectAttr(chromnBallShader+".outColor", chromnBallSG+".surfaceShader", f = True)
    mc.setAttr(chromnBallShader+".color",0,0,0, type = "double3")
    mc.setAttr(chromnBallShader+".diffuseColorAmount",0)
    mc.setAttr(chromnBallShader+".reflectionColor",1,1,1,type = "double3")
    mc.setAttr(chromnBallShader+".refractionIOR",15)
    mc.sets(chromnBall,e = True, forceElement = chromnBallSG)
        
    #create and assign gray ball shader
    grayBallShader = mc.shadingNode('VRayMtl', asShader = True, n = "mat_grayBall")
    grayBallSG = mc.sets(n = grayBallShader + "SG", renderable = True, noSurfaceShader = True, empty = True)
    mc.connectAttr(grayBallShader+".outColor", grayBallSG+".surfaceShader", f = True)
    mc.setAttr(grayBallShader+".color",0.18,0.18,0.18, type = "double3")
    mc.setAttr(grayBallShader+".reflectionColorAmount",0)
    mc.sets(grayBall,e = True, forceElement = grayBallSG)
    
    #create and assign white ball shader
    whiteBallShader = mc.shadingNode('VRayMtl', asShader = True, n = "mat_whiteBall")
    whiteBallSG = mc.sets(n = whiteBallShader + "SG", renderable = True, noSurfaceShader = True, empty = True)
    mc.connectAttr(whiteBallShader+".outColor", whiteBallSG+".surfaceShader", f = True)
    mc.setAttr(whiteBallShader+".color",1,1,1, type = "double3")
    mc.setAttr(whiteBallShader+".reflectionColorAmount",0)
    mc.sets(whiteBall,e = True, forceElement = whiteBallSG)
def linkFileToSpecular(src, dst):
    cmds.shadingNode("remapHsv", n="%s_remapHsc" % dst, au=1)
    cmds.shadingNode("solidFractal", n="%s_solidFractal" % dst, at=1)
    cmds.shadingNode("place3dTexture", n="%s_place3dTexture" % dst, at=1)
    cmds.shadingNode("multiplyDivide", n="%s_multiplyDivide" % dst, au=1)
    cmds.shadingNode("ramp", n="%s_ramp" % dst, at=1)
    cmds.setAttr("%s.saturation[1].saturation_Position" % ("%s_remapHsc" % dst), 1)
    cmds.setAttr("%s.saturation[1].saturation_FloatValue" % ("%s_remapHsc" % dst), 0)
    cmds.setAttr("%s.value[0].value_FloatValue" % ("%s_remapHsc" % dst), 0)
    cmds.setAttr("%s.value[0].value_Position" % ("%s_remapHsc" % dst), 0.025)
    cmds.setAttr("%s.value[1].value_FloatValue" % ("%s_remapHsc" % dst), 1)
    cmds.setAttr("%s.value[1].value_Position" % ("%s_remapHsc" % dst), 0.075)
    cmds.connectAttr(
        "%s.worldInverseMatrix[0]" % ("%s_place3dTexture" % dst), "%s.placementMatrix" % ("%s_solidFractal" % dst), f=1
    )
    cmds.connectAttr("%s.outColor" % src, "%s.color" % ("%s_remapHsc" % dst), f=1)
    cmds.connectAttr("%s.outColor" % ("%s_remapHsc" % dst), "%s.input1" % ("%s_multiplyDivide" % dst), f=1)
    cmds.connectAttr("%s.outColor" % ("%s_solidFractal" % dst), "%s.input2" % ("%s_multiplyDivide" % dst), f=1)
    cmds.connectAttr("%s.output" % ("%s_multiplyDivide" % dst), "%s.colorGain" % ("%s_ramp" % dst), f=1)
    if cmds.nodeType(dst) == "RedshiftArchitectural":
        # cmds.disconnectAttr('%s.outColor'%(src), '%s.diffuse'%dst)
        cmds.connectAttr("%s.outColor" % ("%s_ramp" % dst), "%s.refl_color" % dst, f=1)
    elif cmds.nodeType(dst) == "aiStandard":
        # cmds.disconnectAttr('%s.outColor'%(src), '%s.color'%dst)
        cmds.connectAttr("%s.outColor" % ("%s_ramp" % dst), "%s.KsColor" % dst, f=1)
        # cmds.connectAttr('%s.outColor'%('%s_ramp'%dst), '%s.color'%dst, f = 1)
    else:
        # cmds.disconnectAttr('%s.outColor'%(src), '%s.color'%dst)
        cmds.connectAttr("%s.outColor" % ("%s_ramp" % dst), "%s.reflectedColor" % dst, f=1)
        # cmds.connectAttr('%s.outColor'%('%s_ramp'%dst), '%s.color'%dst, f = 1)
    linkTopRemapNodeToAll("%s_ramp" % dst)
Beispiel #16
0
def addUVsChecker(objects, uRepeats=4, vRepeats=4):
	"""
	Applies UVs checkers onto given geometry objects.

	:param objects: Current objects list.
	:type objects: list
	:param uRepeats: U checker repeats.
	:type uRepeats: float
	:param vRepeats: V checker repeats.
	:type vRepeats: float
	:return: Definition succes.
	:rtype: bool
	"""

	for object in objects:
		for shader in getAttachedShaders(object):
			file = getFirstItem(filter(lambda x: re.search("\.color$", x[1]), getConnections(shader)))
			if file is not None:
				if "UVsChecker" in getFirstItem(file):
					continue

			file = cmds.shadingNode("file", asTexture=True)
			cmds.setAttr("{0}.fileTextureName".format(file), os.path.normpath(os.path.join(RESOURCES_DIRECTORY, CHECKER_IMAGE)), type="string")
			place2dTexture = cmds.shadingNode("place2dTexture", asUtility=True)
			cmds.setAttr("{0}.repeatU".format(place2dTexture), uRepeats)
			cmds.setAttr("{0}.repeatV".format(place2dTexture), vRepeats)
			for uvAttribute in ("coverage", "translateFrame", "rotateFrame", "mirrorU", "mirrorV", "stagger", "wrapU", "wrapV" , "repeatUV" , "vertexUvOne" , "vertexUvTwo" , "vertexUvThree" , "vertexCameraOne", "noiseUV", "offset", "rotateUV"):
				cmds.connectAttr("{0}.{1}".format(place2dTexture, uvAttribute), "{0}.{1}".format(file, uvAttribute), force=True)

			cmds.connectAttr("{0}.outColor".format(file), "{0}.color".format(shader), force=True)
			cmds.rename(file, "UVsChecker_{0}_file".format(shader))
			cmds.rename(place2dTexture, "UVsChecker_{0}_place2dTexture".format(shader))

	return True
def assignMayaShaders(chromnBall,grayBall,whiteBall):
    #create and assign chromn ball shader
    chromnBallShader = mc.shadingNode('blinn', asShader = True, n = "mat_chromnBall")
    chromnBallSG = mc.sets(n = chromnBallShader + "SG", renderable = True, noSurfaceShader = True, empty = True)
    mc.connectAttr(chromnBallShader+".outColor", chromnBallSG+".surfaceShader", f = True)
    mc.setAttr(chromnBallShader+".color",0,0,0, type = "double3")
    mc.setAttr(chromnBallShader+".diffuse",0)
    mc.setAttr(chromnBallShader+".specularColor",1,1,1,type = "double3")
    mc.setAttr(chromnBallShader+".reflectivity",1)
    mc.setAttr(chromnBallShader+".eccentricity",0)
    mc.setAttr(chromnBallShader+".specularRollOff",1)
    mc.sets(chromnBall,e = True, forceElement = chromnBallSG)

    #create and assign gray ball shader
    grayBallShader = mc.shadingNode('lambert', asShader = True, n = "mat_grayBall")
    grayBallSG = mc.sets(n = grayBallShader + "SG", renderable = True, noSurfaceShader = True, empty = True)
    mc.connectAttr(grayBallShader+".outColor", grayBallSG+".surfaceShader", f = True)
    mc.setAttr(grayBallShader+".color",0.18,0.18,0.18, type = "double3")
    mc.setAttr(grayBallShader+".diffuse",1)
    mc.sets(grayBall,e = True, forceElement = grayBallSG)

    #create and assign white ball shader
    whiteBallShader = mc.shadingNode('lambert', asShader = True, n = "mat_whiteBall")
    whiteBallSG = mc.sets(n = whiteBallShader + "SG", renderable = True, noSurfaceShader = True, empty = True)
    mc.connectAttr(whiteBallShader+".outColor", whiteBallSG+".surfaceShader", f = True)
    mc.setAttr(whiteBallShader+".diffuse",1)
    mc.setAttr(whiteBallShader+".color",1,1,1, type = "double3")
    mc.sets(whiteBall,e = True, forceElement = whiteBallSG)
Beispiel #18
0
def pathFollow (curve , control, objectArray, NameConv = None):
	if not NameConv:
		NameConv = RMNameConvention.RMNameConvention()
	controlAttr = cmds.listAttr(control)
	if "Percent" not in controlAttr:
		cmds.addAttr(control,at="float", ln = "Percent", h = 0, k = 1)
	if "Stretch" not in controlAttr:
		cmds.addAttr(control,at="float", ln = "Stretch", hnv = 1, hxv = 0, h = 0, k = 1, smn = 0)

	numberOfElements = len(objectArray)
	sumPath = []
	multiplyDivide = [] 
	index = 0
	for eachObject in objectArray:
		motionPath = cmds.pathAnimation(eachObject, c = curve , follow = True , worldUpType =  "scene", name = "motionpath%s"%index)
		motionPath = NameConv.RMRenameNameInFormat(motionPath)
		multDivFactor = cmds.shadingNode('multiplyDivide', asUtility = True, name = "factor%s"%index)
		multDivFactor = NameConv.RMRenameNameInFormat(multDivFactor)
		cmds.connectAttr("%s.Stretch"%control ,"%s.input1X"%multDivFactor)
		cmds.setAttr("%s.input2X"%multDivFactor, float(index)/float(len(objectArray)))
		cmds.setAttr("%s.operation"%multDivFactor, 1)
		multiplyDivide.append(multDivFactor)
		addition = cmds.shadingNode('plusMinusAverage', asUtility = True, name = "Addition%s"%index)
		addition = NameConv.RMRenameNameInFormat(addition)
		cmds.connectAttr("%s.outputX"%multDivFactor ,"%s.input1D[0]"%addition)
		cmds.connectAttr("%s.Percent"%control ,"%s.input1D[1]"%addition)
		cmds.connectAttr("%s.output1D"%addition,"%s.uValue"%motionPath, force = True)
		index+=1
Beispiel #19
0
def createMayaNetwork(filename):
    lambert = m.shadingNode('lambert', asShader=True)
    sg = m.sets(renderable=True, noSurfaceShader=True, empty=True, name=lambert + 'SG')
    m.connectAttr(lambert + '.outColor', sg + '.surfaceShader', force=True)

    fileNode = m.shadingNode('file', asTexture=True)
    placement = m.shadingNode('place2dTexture', asUtility=True)
    m.connectAttr(placement + '.coverage', fileNode + '.coverage', force=True)
    m.connectAttr(placement + '.translateFrame', fileNode + '.translateFrame', force=True)
    m.connectAttr(placement + '.rotateFrame', fileNode + '.rotateFrame', force=True)
    m.connectAttr(placement + '.mirrorU', fileNode + '.mirrorU', force=True)
    m.connectAttr(placement + '.mirrorV', fileNode + '.mirrorV', force=True)
    m.connectAttr(placement + '.stagger', fileNode + '.stagger', force=True)
    m.connectAttr(placement + '.wrapU', fileNode + '.wrapU', force=True)
    m.connectAttr(placement + '.wrapV', fileNode + '.wrapV', force=True)
    m.connectAttr(placement + '.repeatUV', fileNode + '.repeatUV', force=True)
    m.connectAttr(placement + '.offset', fileNode + '.offset', force=True)
    m.connectAttr(placement + '.rotateUV', fileNode + '.rotateUV', force=True)
    m.connectAttr(placement + '.noiseUV', fileNode + '.noiseUV', force=True)
    m.connectAttr(placement + '.vertexUvOne', fileNode + '.vertexUvOne', force=True)
    m.connectAttr(placement + '.vertexUvTwo', fileNode + '.vertexUvTwo', force=True)
    m.connectAttr(placement + '.vertexUvThree', fileNode + '.vertexUvThree', force=True)
    m.connectAttr(placement + '.vertexCameraOne', fileNode + '.vertexCameraOne', force=True)
    m.connectAttr(placement + '.outUV', fileNode + '.uv', force=True)
    m.connectAttr(placement + '.outUvFilterSize', fileNode + '.uvFilterSize', force=True)

    m.connectAttr(fileNode + '.outColor', lambert + '.color', force=True)

    m.setAttr(fileNode + '.fileTextureName', filename, typ='string')

    return sg
Beispiel #20
0
def createBlossomShader(rgb_blossom):
    """
    It creates a shading network for the blossom material.

    rgb_branch:   RGB values (0-1) for the diffuse colour of the branches.

    On Exit:      Creates a Lambert node connected to a Shading Group which will be applied to the petals. Furthermore, two
                  non-customizable additional shaders will be created and applied to the stamen and pedicel of the blossom. 
    """
    global blossomMat, blossomSG
    import globalVar
    reload(globalVar)

    blossomPetalsMat = cmds.shadingNode( 'lambert', asShader=True, name='blossomPetalsMat'+str(globalVar.plantNumber) )
    cmds.setAttr( blossomPetalsMat + '.color', rgb_blossom[0], rgb_blossom[1], rgb_blossom[2] )
    blossomPetalsSG = cmds.sets( renderable=True, noSurfaceShader=True, empty=True,
        name='blossomPetalsSG'+str(globalVar.plantNumber) )
    cmds.connectAttr( blossomPetalsMat + '.outColor', blossomPetalsSG + '.surfaceShader', f=True )

    blossomStamenMat = cmds.shadingNode( 'lambert', asShader=True, name='blossomStamenMat'+str(globalVar.plantNumber) )
    cmds.setAttr( blossomStamenMat + '.color', 0.848, 0.8484, 0.186 )
    blossomStamenSG = cmds.sets( renderable=True, noSurfaceShader=True, empty=True,
        name='blossomStamenSG'+str(globalVar.plantNumber) )
    cmds.connectAttr( blossomStamenMat + '.outColor', blossomStamenSG + '.surfaceShader', f=True )

    blossomPedicelMat = cmds.shadingNode( 'lambert', asShader=True, name='blossomPedicelMat'+str(globalVar.plantNumber) )
    cmds.setAttr( blossomPedicelMat + '.color', 0, 0.494, 0 )
    blossomPedicelSG = cmds.sets( renderable=True, noSurfaceShader=True, empty=True,
        name='blossomPedicelSG'+str(globalVar.plantNumber) )
    cmds.connectAttr( blossomPedicelMat + '.outColor', blossomPedicelSG + '.surfaceShader', f=True )
Beispiel #21
0
def connectThroughBC(parentsA, parentsB, children, instance, switchattr ):
    constraints = []
    for j in range(len(children)):
        switchPrefix = children[j].partition('_')[2]
        bcNodeT = cmds.shadingNode("blendColors", asUtility=True, n=instance + 'bcNodeT_switch_' + switchPrefix)
        bcNodeR = cmds.shadingNode("blendColors", asUtility=True, n=instance + 'bcNodeR_switch_' + switchPrefix)
        bcNodeS = cmds.shadingNode("blendColors", asUtility=True, n=instance + 'bcNodeS_switch_' + switchPrefix)
        
        constraints.append([bcNodeT, bcNodeR, bcNodeS])
        # connect to switchattr
        if switchattr == 'None':
            cmds.setAttr(bcNodeT  + '.blender', 1)
            cmds.setAttr(bcNodeR  + '.blender', 1)
            cmds.setAttr(bcNodeS  + '.blender', 1)
        else:
            cmds.connectAttr(switchattr, bcNodeT  + '.blender')
            cmds.connectAttr(switchattr, bcNodeR  + '.blender')
            cmds.connectAttr(switchattr, bcNodeS  + '.blender')

        # Input Parents
        cmds.connectAttr(parentsA[j] + '.translate', bcNodeT + '.color1')        
        cmds.connectAttr(parentsA[j] + '.rotate', bcNodeR + '.color1')       
        cmds.connectAttr(parentsA[j] + '.scale', bcNodeS + '.color1')
        if parentsB != 'None':
            cmds.connectAttr(parentsB[j] + '.translate', bcNodeT + '.color2')
            cmds.connectAttr(parentsB[j] + '.rotate', bcNodeR + '.color2')
            cmds.connectAttr(parentsB[j] + '.scale', bcNodeS + '.color2')
        # Output to Children
        cmds.connectAttr(bcNodeT + '.output', children[j] + '.translate')
        cmds.connectAttr(bcNodeR + '.output', children[j] + '.rotate')
        cmds.connectAttr(bcNodeS + '.output', children[j] + '.scale')
    return constraints
def assignArnoldShaders(chromnBall,grayBall,whiteBall):
    #create and assign chromn ball shader
    chromnBallShader = mc.shadingNode('aiStandard', asShader = True, n = "mat_chromnBall")
    chromnBallSG = mc.sets(n = chromnBallShader + "SG", renderable = True, noSurfaceShader = True, empty = True)
    mc.connectAttr(chromnBallShader+".outColor", chromnBallSG+".surfaceShader", f = True)
    mc.setAttr(chromnBallShader+".color",0,0,0, type = "double3")
    mc.setAttr(chromnBallShader+".Kd",0)
    mc.setAttr(chromnBallShader+".Ks",1)
    mc.setAttr(chromnBallShader+".specularRoughness",0)
    mc.sets(chromnBall,e = True, forceElement = chromnBallSG)
        
    #create and assign gray ball shader
    grayBallShader = mc.shadingNode('aiStandard', asShader = True, n = "mat_grayBall")
    grayBallSG = mc.sets(n = grayBallShader + "SG", renderable = True, noSurfaceShader = True, empty = True)
    mc.connectAttr(grayBallShader+".outColor", grayBallSG+".surfaceShader", f = True)
    mc.setAttr(grayBallShader+".color",0.18,0.18,0.18, type = "double3")
    mc.setAttr(grayBallShader+".Kd",1)
    mc.setAttr(grayBallShader+".KsColor",0,0,0, type = "double3")
    mc.setAttr(grayBallShader+".Ks",0)
    mc.setAttr(chromnBallShader+".specularRoughness",0)
    mc.sets(grayBall,e = True, forceElement = grayBallSG)
    
    #create and assign white ball shader
    whiteBallShader = mc.shadingNode('aiStandard', asShader = True, n = "mat_whiteBall")
    whiteBallSG = mc.sets(n = whiteBallShader + "SG", renderable = True, noSurfaceShader = True, empty = True)
    mc.connectAttr(whiteBallShader+".outColor", whiteBallSG+".surfaceShader", f = True)
    mc.setAttr(whiteBallShader+".color",1,1,1, type = "double3")
    mc.setAttr(whiteBallShader+".Kd",1)
    mc.setAttr(whiteBallShader+".KsColor",0,0,0, type = "double3")
    mc.setAttr(whiteBallShader+".Ks",0)
    mc.setAttr(chromnBallShader+".specularRoughness",0)
    mc.sets(whiteBall,e = True, forceElement = whiteBallSG)
Beispiel #23
0
    def RMCreateTwist(self, TwistJoint, LookAtObject,  NumberOfTB = 3, LookAtAxis = "Y"):
        #LookAtObject = cmds.listRelatives( TwistJoint,type = "transform",children=True)[]
    
        positionA = cmds.xform(TwistJoint ,q=True,ws=True,rp=True)
        positionB = cmds.xform(LookAtObject ,q=True,ws=True,rp=True)

        vectorA = om.MVector(positionA)
        vectorB = om.MVector(positionB)

        self.RMCreateBonesBetweenPoints(vectorA,vectorB,NumberOfTB, AlignObject = TwistJoint)

        Distance = RMRigTools.RMPointDistance( TwistJoint, LookAtObject)
        
        cmds.parentConstraint (TwistJoint,self.TwistResetJoints)

        resetPoint , control = RMRigShapeControls.RMCreateBoxCtrl(self.TwistJoints[0], Xratio = .1, Yratio = .1, Zratio = .1, customSize = Distance/5 ,name = "TwistOrigin" + self.NameConv.RMGetAShortName (TwistJoint).title())
        #control = self.NameConv.RMRenameBasedOnBaseName(TwistJoint , control,  NewName = self.NameConv.RMGetAShortName(control))
        #resetPoint = self.NameConv.RMRenameBasedOnBaseName(TwistJoint , resetPoint,  NewName = self.NameConv.RMGetAShortName(resetPoint))
        
        sign = 1
        MoveDistance = Distance/5
        if "-" in LookAtAxis:
            sign = -1
        if "Z" in LookAtAxis or "z" in LookAtAxis:
            MoveList = [0,0, MoveDistance * sign]
            WUV = [0,0,sign]
        elif "Y" in LookAtAxis or "y" in LookAtAxis:
            MoveList = [0,MoveDistance * sign,0 ]
            WUV = [0,sign,0]

        cmds.xform( resetPoint, os = True, relative=True,  t = MoveList)

        cmds.aimConstraint( LookAtObject,self.TwistJoints[0], aim = [1,0,0], worldUpVector = [0,0,1], worldUpType = "object", worldUpObject = control)

        TwistJointDivide = cmds.shadingNode( "multiplyDivide", asUtility = True, name = "TwistJoint" + self.NameConv.RMGetAShortName( TwistJoint).title())
        TwistJointDivide = self.NameConv.RMRenameBasedOnBaseName( TwistJoint , TwistJointDivide,  NewName = self.NameConv.RMGetAShortName( TwistJointDivide))


        TwistAddition = cmds.shadingNode( "plusMinusAverage", asUtility = True, name = "TwistJointAdd" + self.NameConv.RMGetAShortName( TwistJoint).title())
        TwistAddition = self.NameConv.RMRenameBasedOnBaseName( TwistJoint , TwistAddition,  NewName = self.NameConv.RMGetAShortName( TwistAddition))
        NegativeLookAtRotation = cmds.shadingNode( "multiplyDivide", asUtility = True, name = "NegativeLookAtRotation" + self.NameConv.RMGetAShortName( TwistJoint).title())
        NegativeLookAtRotation = self.NameConv.RMRenameBasedOnBaseName( TwistJoint , NegativeLookAtRotation,  NewName = self.NameConv.RMGetAShortName( NegativeLookAtRotation))
        cmds.connectAttr( LookAtObject + ".rotateX", NegativeLookAtRotation + ".input1X")
        cmds.setAttr(NegativeLookAtRotation + ".input2X", -1 )
        cmds.setAttr(NegativeLookAtRotation + ".operation", 1 )
        cmds.connectAttr(self.TwistJoints[0]+".rotateX", TwistAddition + ".input1D[0]")
        cmds.connectAttr( NegativeLookAtRotation + ".outputX", TwistAddition + ".input1D[1]")
        cmds.connectAttr(TwistAddition + ".output1D", TwistJointDivide + ".input1X")


        #cmds.connectAttr(self.TwistJoints[0]+".rotateX", TwistJointDivide + ".input1X") in this case the rotation of the lookatNode was not affecting
        cmds.setAttr(TwistJointDivide + ".input2X", -(len(self.TwistJoints) - 1))
        cmds.setAttr(TwistJointDivide + ".operation", 2 )

        for eachJoint in self.TwistJoints[1:]:
            cmds.connectAttr(TwistJointDivide+".outputX", eachJoint + ".rotateX")


        self.TwistControlResetPoint = resetPoint
        self.TwistControl = control
Beispiel #24
0
def shaderAssigner() :
	# Assigning temporary shader to selected objects
	sels = mc.ls( sl=True )
	name = ''
	side = ''

	nameResult = mc.promptDialog(
					title='Shading Name',
					message='Enter Name:',
					button=['OK', 'Cancel'],
					defaultButton='OK',
					cancelButton='Cancel',
					dismissString='Cancel'
				)
	
	if nameResult == 'OK':
	    name = mc.promptDialog(query=True, text=True)
    
	if name :
		
		shadingName = '%sTmp_lambert' % name
		
		if not mc.objExists( shadingName ) :
			
			mc.shadingNode( 'lambert' , asShader=True , n=shadingName )
		
		mc.select( sels , r=True )
		cmd = 'hyperShade -assign %s;' % shadingName
		mm.eval( cmd )
		
		mc.select( shadingName , r=True )
Beispiel #25
0
    def ConstraintVisibility(self, Objects , ControlObject , SpaceSwitchName = 'spaceSwitch', reverse = False ):
        if (self.AddNumericParameter (ControlObject, Name = SpaceSwitchName)):
            SWMultDiv = cmds.shadingNode("multiplyDivide",asUtility = True ,name = SpaceSwitchName + "SWMultDivide" )
            SWMultDiv = self.NameConv.RMRenameBasedOnBaseName(ControlObject, SWMultDiv, NewName = SWMultDiv)
            cmds.connectAttr(ControlObject+"."+SpaceSwitchName ,SWMultDiv+".input1X")
            cmds.setAttr(SWMultDiv+".input2X",10)
            cmds.setAttr(SWMultDiv+".operation",2)
        else:
            SWMultDiv = cmds.listConnections(ControlObject + "." + SpaceSwitchName, type = "multiplyDivide")[0]

        if reverse == True:
            ConnectionsList = cmds.listConnections (SWMultDiv + ".outputX", type = "reverse")
            reverseSW = ""
            if ConnectionsList and len(ConnectionsList) >= 1:
                reverseSW = ConnectionsList[0]
            else :
                reverseSW = cmds.shadingNode('reverse', asUtility=True, name = SpaceSwitchName + "SWReverse")
                reverseSW = self.NameConv.RMRenameBasedOnBaseName(ControlObject, reverseSW, NewName ="SWReverse")
                cmds.connectAttr( SWMultDiv + ".outputX", reverseSW + ".inputX")

                if self.NameConv.RMIsNameInFormat (ControlObject):
                    reverseSW = self.NameConv.RMRenameBasedOnBaseName(ControlObject,reverseSW, NewName = reverseSW)
                else:
                    reverseSW = self.NameConv.RMRenameNameInFormat(reverseSW)
            for eachObject in Objects:
                cmds.connectAttr(reverseSW + ".outputX", eachObject + ".visibility")
        
        else:
            for eachObject in Objects:
                cmds.connectAttr(SWMultDiv + ".outputX", eachObject + ".visibility")
def creatSphere(*args):
    circleSel = mc.ls(sl=1)[0]
    radiusCircle = mc.circle(circleSel, q=1, r=1)
    radiusSpere = radiusCircle*.75
    particleSphere = mc.polySphere(n='%s_Sphere'%circleSel, r=radiusSpere, sx=float(radiusSpere), sy=float(radiusSpere), ax=[0, 1, 0])[0]
    mc.parentConstraint(circleSel, particleSphere, mo=0, w=1)
    #mc.parent(particleSphere, circleSel)
    mc.setAttr('%s.tx'%particleSphere, 0)
    mc.setAttr('%s.ty'%particleSphere, 0)
    mc.setAttr('%s.tz'%particleSphere, 0)
    mc.setAttr('%s.rx'%particleSphere, 0)
    mc.setAttr('%s.ry'%particleSphere, 0)
    mc.setAttr('%s.rz'%particleSphere, 0)
    mc.setAttr('%s.v'%particleSphere, 0)
    mc.select(particleSphere, r=1) 
    mc.emitter(type='surface', r=4, dx=1, dy=0, dz=0, n='%s_emitter'%circleSel )
    mc.particle( n='%s_Particles'%circleSel )
    mc.connectDynamic( '%s_Particles'%circleSel, em='%s_emitter'%circleSel )
    particlesShape = mc.listRelatives('%s_Particles'%circleSel, s=1)[0]
    mc.setAttr('%s.lifespanMode'%particlesShape, 1)
    mc.setAttr('%s.lifespan'%particlesShape, 0.4)
    mc.setAttr('%s.startFrame'%particlesShape, 1001)
    mc.connectControl( 'numText', '%s.rate'%('%s_emitter'%circleSel) )
    mc.shadingNode('blinn', n='%s_blinn'%circleSel, asShader=1)
    mc.sets( n='%s_blinnSG'%circleSel, renderable=True, noSurfaceShader=True, empty=1)
    mc.connectAttr('%s.outColor'%('%s_blinn'%circleSel), '%s.surfaceShader'%('%s_blinnSG'%circleSel))
    mc.connectControl( 'myColorIndex', '%s.color'%('%s_blinn'%circleSel) )
    mc.connectControl( 'lifeText', '%s.lifespan'%particlesShape )
    mc.sets('%s_Particles'%circleSel, e=1, forceElement='%s'%('%s_blinnSG'%circleSel))
Beispiel #27
0
def createOctaneShader(colorNode):
    # glossy shader
    shader = cmds.shadingNode('octaneGlossyMaterial', asShader=True)
    shadingGroup = cmds.sets(shader, name=shader+'_shadingGroup')

    # get other components
    colorPath = cmds.getAttr(colorNode+'.fileTextureName')
    normalPath = getComponent(colorNode, 'normal')
    specularPath = getComponent(colorNode, 'specular')

    # octane color texture
    colorNode = cmds.shadingNode("octaneImageTexture", asTexture=True)
    cmds.setAttr(colorNode+'.File', colorPath, type='string')
    cmds.connectAttr(colorNode+".outTex", shader+".Diffuse")

    if specularPath:
        # octane specular texture
        specularNode = cmds.shadingNode("octaneImageTexture", asTexture=True)
        cmds.setAttr(specularNode+'.File', specularPath, type='string')
        cmds.connectAttr(specularNode+".outTex", shader+".Specular")

    if normalPath:
        normalNode = cmds.shadingNode("octaneImageTexture", asTexture=True)
        cmds.setAttr(normalNode+'.File', normalPath, type='string')
        cmds.connectAttr(normalNode+".outTex", shader+".Normal")
Beispiel #28
0
def createShader(colorNode):
    # create shader and shadingGroup
    shader = cmds.shadingNode('blinn', asShader=True)
    shadingGroup = cmds.sets(shader)

    # set default shader values
    cmds.setAttr(shader+".diffuse", 1)
    cmds.setAttr(shader+".eccentricity", 0.2)
    cmds.setAttr(shader+".specularRollOff", 0.8)

    # connect base texture where it should be 
    cmds.connectAttr(colorNode+'.outColor', shader+'.color')
    # get normal and specular textures path
    normalTexture = getComponent(colorNode, 'normal')
    specularTexture = getComponent(colorNode, 'specular')

    if normalTexture:
        # create bump/normal node
        bumpNode = cmds.shadingNode('bump2d', asUtility=True)
        cmds.setAttr(bumpNode+'.bumpInterp', 1)
        normalNode = cmds.shadingNode('file', asTexture=True)
        cmds.setAttr(normalNode+'.fileTextureName', normalTexture, type="string")
        # connect normal map to bump node
        cmds.connectAttr(normalNode+'.outAlpha', bumpNode+'.bumpValue')
        # connect bump to shader
        cmds.connectAttr(bumpNode+'.outNormal', shader+'.normalCamera')

    if specularTexture:
        # creating specular node
        specularNode = cmds.shadingNode('file', asTexture=True)
        cmds.setAttr(specularNode+'.fileTextureName', specularTexture, type="string")
        cmds.connectAttr(specularNode+'.outColorR', shader+'.specularColorR')
        cmds.connectAttr(specularNode+'.outColorR', shader+'.specularColorG')
        cmds.connectAttr(specularNode+'.outColorR', shader+'.specularColorB')
Beispiel #29
0
    def create_knee_pin(self):
        """Creates the knee pin setup."""
        u_leg_d, u_leg_s, u_leg_e = self.c.distance_node(self.guides['thigh'], self.guides['shin'])
        u_leg_d = cmds.rename(u_leg_d, '%s_%s_%s' % (self.side, 'thighToKnee', self.nc.distance))
        u_leg_s = cmds.rename(u_leg_s, '%s_%s_%s' % (self.side, 'thighToKneeLengthStart', self.nc.locator))
        u_leg_e = cmds.rename(u_leg_e, '%s_%s_%s' % (self.side, 'thighToKneeLengthEnd', self.nc.locator))
        self.c.snap_a_to_b(u_leg_e, self.controls['knee'])
        f_leg_d, f_leg_s, f_leg_e = self.c.distance_node(self.guides['foot'], self.guides['shin'])
        f_leg_d = cmds.rename(f_leg_d, '%s_%s_%s' % (self.side, 'footToKnee', self.nc.distance))
        f_leg_s = cmds.rename(f_leg_s, '%s_%s_%s' % (self.side, 'footToKneeLengthStart', self.nc.locator))
        f_leg_e = cmds.rename(f_leg_e, '%s_%s_%s' % (self.side, 'footToKneeLengthEnd', self.nc.locator))
        self.c.snap_a_to_b(f_leg_e, self.controls['knee'])
        cmds.parent(u_leg_e, f_leg_e, self.controls['knee'])
        cmds.parent(u_leg_d, f_leg_d, self.top_grp)

        if self.side == 'R':
            mult = cmds.shadingNode('multiplyDivide', asUtility=True)
            u_mult = cmds.rename(mult, '%s_%s_stretch_negative_MDN' % (self.side, 'thigh'))
            cmds.connectAttr('%sShape.distance' % u_leg_d, '%s.input1X' % u_mult, f=True)
            cmds.setAttr('%s.input2X' % u_mult, -1)
            mult = cmds.shadingNode('multiplyDivide', asUtility=True)
            f_mult = cmds.rename(mult, '%s_%s_stretch_negative_MDN' % (self.side, 'foot'))
            cmds.connectAttr('%sShape.distance' % f_leg_d, '%s.input1X' % f_mult, f=True)
            cmds.setAttr('%s.input2X' % f_mult, -1)
        # END if

        # blend nodes
        blend = cmds.shadingNode('blendColors', asUtility=True)
        blend = cmds.rename(blend, '%s_%s_stretch_BLD' % (self.side, 'thigh'))
        cmds.connectAttr('%s.kneeSnap' % self.controls['knee'], '%s.blender' % blend, f=True)

        if self.side == 'L':
            cmds.connectAttr('%sShape.distance' % u_leg_d, '%s.color1R' % blend, f=True)
        elif self.side == 'R':
            cmds.connectAttr('%s.input2X' % u_mult, '%s.color1R' % blend, f=True)
        # END if

        cmds.connectAttr('%s_translateX.output' % self.ik_jnts[1], '%s.color2R' % blend, f=True)
        cmds.connectAttr('%s.outputR' % blend, '%s.translateX' % self.ik_jnts[1], f=True)

        self.stretch_switch(blend, self.ik_jnts[1], self.switch_control, 'translateX')

        blend = cmds.shadingNode('blendColors', asUtility=True)
        blend = cmds.rename(blend, '%s_%s_stretch_BLD' % (self.side, 'foot'))
        cmds.connectAttr('%s.kneeSnap' % self.controls['knee'], '%s.blender' % blend, f=True)

        if self.side == 'L':
            cmds.connectAttr('%sShape.distance' % f_leg_d, '%s.color1R' % blend, f=True)
        elif self.side == 'R':
            cmds.connectAttr('%s.input2X' % f_mult, '%s.color1R' % blend, f=True)
        # END if

        cmds.connectAttr('%s_translateX.output' % self.ik_jnts[2], '%s.color2R' % blend, f=True)
        cmds.connectAttr('%s.outputR' % blend, '%s.translateX' % self.ik_jnts[2], f=True)

        self.stretch_switch(blend, self.ik_jnts[2], self.switch_control, 'translateX')

        cmds.parent(u_leg_s, self.ik_jnts[0])
        cmds.parent(f_leg_s, self.controls['ik'])
Beispiel #30
0
 def createNormalShader(self, nameShader, listColor):
     """ This method creates a normal shader. """
     
     mc.shadingNode( 'lambert', asShader=True, name=nameShader );
     mc.sets( renderable=True, noSurfaceShader=True, empty=True, name= nameShader + 'SG' );
     mc.connectAttr( nameShader + '.outColor', nameShader + 'SG.surfaceShader', force=True );
     mc.setAttr( nameShader + ".color", listColor[0], listColor[1], listColor[2], type='double3' );
     mc.select( clear=True )
Beispiel #31
0
 def _aiMotionVector(self):
     cmds.shadingNode('aiMotionVector', asShader=True)
Beispiel #32
0
def plot(path):
    d = {}
    rad = {
        'I': .4,
        'Kr': .3,
        'O': 0.2,
        'H': 0.1,
        'F': .2,
        'Si': .25,
        'C': .2,
        'N': 0.18
    }
    f = open(path, 'r')
    lines = f.readlines()
    f.close()
    index = 1

    cmds.shadingNode('blinn', asShader=True)
    cmds.sets(renderable=True,
              noSurfaceShader=True,
              empty=True,
              name='blinn1SG')
    cmds.connectAttr('blinn1.outColor', 'blinn1SG.surfaceShader')
    cmds.setAttr('blinn1.color', 0, 0, 0)

    cmds.shadingNode('blinn', asShader=True)
    cmds.sets(renderable=True,
              noSurfaceShader=True,
              empty=True,
              name='blinn2SG')
    cmds.connectAttr('blinn2.outColor', 'blinn2SG.surfaceShader')
    cmds.setAttr('blinn2.color', 255, 0, 0)

    cmds.shadingNode('blinn', asShader=True)
    cmds.sets(renderable=True,
              noSurfaceShader=True,
              empty=True,
              name='blinn3SG')
    cmds.connectAttr('blinn3.outColor', 'blinn3SG.surfaceShader')
    cmds.setAttr('blinn3.color', 0, 0, 255)

    cmds.shadingNode('blinn', asShader=True)
    cmds.sets(renderable=True,
              noSurfaceShader=True,
              empty=True,
              name='blinn4SG')
    cmds.connectAttr('blinn4.outColor', 'blinn4SG.surfaceShader')
    cmds.setAttr('blinn4.color', 0, 255, 0)

    for line in lines:
        if len(line.strip().split()) == 4:
            s, x, y, z = line.strip().split()
            nam = s + str(index)
            d[index] = nam
            cmds.sphere(name=nam, r=rad[s])
            cmds.move(x, y, z)
            if s == 'H':
                cmds.sets(forceElement='blinn4SG')
            elif s == 'C':
                cmds.sets(forceElement='blinn1SG')
            elif s == 'N':
                cmds.sets(forceElement='blinn3SG')
            elif s == 'O':
                cmds.sets(forceElement='blinn2SG')
            index += 1
    return d
  for b in balls:
    ys=cmds.getAttr(b+'.rotateY')
    print ys	
    ys+=(360/12)
    cmds.setAttr(b+'.rotateY',ys)  
    y=cmds.getAttr(b+'.translateY')
    print y	
    y-=1
    cmds.setAttr(b+'.translateY',y)
    z=cmds.getAttr(b+'.translateZ')	
    z+=(random.random()-0.5)	
    print z	
    cmds.setAttr(b+'.translateZ',z)	
    x=cmds.getAttr(b+'.translateX')	
    x+=(random.random()-0.5)	
    print x	
    cmds.setAttr(b+'.translateX',x)		
  cmds.setKeyframe( balls, t=(str(s)+'sec'))

# myShader = cmds.shadingNode('anisotropic', asShader=True)
myShader=cmds.shadingNode('anisotropic',asShader=True)
shadingGroup=cmds.sets(renderable=True, noSurfaceShader=True, empty=True, name=myShader + 'SG' )
cmds.setAttr( myShader+'.color',0.99, 0.543,0.02, type='double3')
cmds.setAttr(myShader+'.translucence',0.55)
cmds.connectAttr(myShader+".outColor", shadingGroup+".surfaceShader")
cmds.select(balls)
cmds.sets(forceElement=shadingGroup,e=True)
  
cmds.play()

Beispiel #34
0
def bdRigLegBones(side):
    legBones = ['leg', 'knee', 'foot', 'toe', 'toe_end']
    for i in range(len(legBones)):
        legBones[i] = side + '_' + legBones[i] + '_ik_jnt'
#START setup foot roll
    legIk = cmds.ikHandle(sol='ikRPsolver',
                          sticky='sticky',
                          startJoint=legBones[0],
                          endEffector=legBones[2],
                          name=side + '_leg_ikHandle')
    footIk = cmds.ikHandle(sol='ikSCsolver',
                           sticky='sticky',
                           startJoint=legBones[2],
                           endEffector=legBones[3],
                           name=side + '_foot_ikHandle')
    toeIk = cmds.ikHandle(sol='ikSCsolver',
                          sticky='sticky',
                          startJoint=legBones[3],
                          endEffector=legBones[4],
                          name=side + '_toe_ikHandle')
    #create the groups that will controll the foot animations ( roll, bend, etc etc)
    bdRigUtils.bdCreateOffsetLoc(legBones[2], side + '_foot_loc')
    bdRigUtils.bdCreateOffsetLoc(legBones[3], side + '_ball_loc')
    bdRigUtils.bdCreateOffsetLoc(legBones[4], side + '_toe_loc')
    bdRigUtils.bdCreateOffsetLoc(legBones[2], side + '_heel_loc')

    cmds.parent([
        side + '_ball_loc_grp', side + '_toe_loc_grp', side + '_heel_loc_grp'
    ], side + '_foot_loc')
    cmds.parent([legIk[0], footIk[0], toeIk[0]], side + '_foot_loc')
    cmds.parent([legIk[0]], side + '_ball_loc')
    cmds.parent([side + '_ball_loc_grp', footIk[0], toeIk[0]],
                side + '_toe_loc')
    cmds.parent([side + '_toe_loc_grp'], side + '_heel_loc')

    #add atributes on the footGrp - will be conected later to an anim controler
    attrList = ['Heel', 'Ball', 'Toe', 'kneeTwist']
    animCtrl = cmds.ls(side + '_foot_ik_anim')[0]
    bdRigUtils.bdAddSeparatorAttr(animCtrl, '______')
    bdRigUtils.bdAddAttribute(animCtrl, attrList, 'float')
    #connect the attributes
    cmds.connectAttr(animCtrl + '.' + attrList[0], side + '_heel_loc' + '.rz')
    cmds.connectAttr(animCtrl + '.' + attrList[1], side + '_ball_loc' + '.rz')
    cmds.connectAttr(animCtrl + '.' + attrList[2], side + '_toe_loc' + '.rz')
    #setup the controller
    bdRigLegCtrl(side)
    #END setup foot roll

    #START no flip knee knee
    reverse = 1
    if side == 'right':
        reverse = -1

    poleVectorLoc = cmds.spaceLocator()
    poleVectorLoc = cmds.rename(poleVectorLoc, side + 'poleVector')
    poleVectorLocGrp = cmds.group(poleVectorLoc, n=poleVectorLoc + '_GRP')

    thighPos = cmds.xform(legBones[0], q=True, ws=True, t=True)

    cmds.move(thighPos[0] + reverse * 5, thighPos[1], thighPos[2],
              poleVectorLocGrp)

    cmds.poleVectorConstraint(poleVectorLoc, legIk[0])

    shadingNodeADL = cmds.shadingNode('addDoubleLinear',
                                      asUtility=True,
                                      name=side + 'adl_twist')
    ikZval = cmds.getAttr(str(legIk[0]) + '.rotateZ')
    cmds.setAttr(shadingNodeADL + '.input2', reverse * 90)
    cmds.connectAttr(animCtrl + '.' + attrList[3], shadingNodeADL + '.input1')
    cmds.connectAttr(shadingNodeADL + '.output', legIk[0] + '.twist')
    thighRot = cmds.xform(legBones[0], q=True, ro=True, ws=True)
    startTwist = reverse * 90
    limit = 0.001
    increment = reverse * 0.01

    while True:
        cmds.select(cl=True)
        thighRot = cmds.xform(legBones[0], q=True, ro=True, os=True)
        print thighRot[0]
        if ((thighRot[0] > limit)):
            startTwist = startTwist - increment
            cmds.setAttr(shadingNodeADL + '.input2', startTwist)
        else:
            break
Beispiel #35
0
    def AttrCassIfication(self, types, dIconPath, num):
        ########打开图片########
        self.allArnolds = []
        if num == 0:
            os.startfile(dIconPath)
            return
        ########创建材质########
        elif num == 1:
            aiSShader = mc.shadingNode('aiStandard', asShader=True, n=types)
            aiSShaderSG = mc.sets(renderable=True,
                                  noSurfaceShader=True,
                                  empty=True,
                                  name='%sSG' % aiSShader)
            self.allArnolds.append(aiSShader)
            if maLibPath not in sys.path:
                sys.path.append(maLibPath)
        ######查找arnold材质######
        elif num == 2:
            if maLibPath not in sys.path:
                sys.path.append(maLibPath)
            self.allArnolds = mc.ls(sl=True, type="aiStandard")
            if not self.allArnolds:
                mc.confirmDialog(message=u'请选择需要设置属性的arnold材质!', button='OK')
                return
        #######################人造材料#######################
        if types == 'stone01' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setStone01Attr()

        elif types == 'stone02' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setStone02Attr()

        elif types == 'bloon' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setBloonAttr()

        elif types == 'mattPlastic' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setMattPlastticAttr()

        elif types == 'toyPlastic' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setToyPlasticAttr()

        elif types == 'shinyPlastic' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setShinyPlasticAttr()

        elif types == 'silkMattPlastic' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setSilkMattPlasticAttr()

        # elif types == 'silkMattPlastic1' and num != 0:
        #     self.setSilkMattPlastic1Attr()

        elif types == 'softPlastic' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setSoftPlasticAttr()

        elif types == 'rubber01' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setRubber01Attr()

        elif types == 'rubber02' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setRubber02Attr()

        elif types == 'gold' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setGoldAttr()

        elif types == 'chrome01' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setChrome01Attr()

        elif types == 'chrome02' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setChrome02Attr()

        elif types == 'wheelRim' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setWheelRimAttr()

        elif types == 'glass01' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setGalss01Attr()

        elif types == 'glass02' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setGlass02Attr()

        elif types == 'glass03' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setGlass03Attr()

        elif types == 'glass04' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setGlass04Attr()

        elif types == 'ceramic01' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setCeramic01Attr()

        # elif types == 'wax' and num != 0:
        #     self.setWaxAttr()

        elif types == 'wood01' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setWood01Attr()

        elif types == 'wood02' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setWood02Attr()

        elif types == 'wood03' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setWood03Attr()

        elif types == 'wood04' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setWood04Attr()

        elif types == 'wood05' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setWood05Attr()

        elif types == 'wood06' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setWood06Attr()

        elif types == 'cloth01' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setCloth01Attr()

        elif types == 'cloth02' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setCloth02Attr()

        elif types == 'cloth03' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setCloth03Attr()

        elif types == 'cloth04' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setCloth04Attr()

        elif types == 'cloth05' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setCloth05Attr()

        elif types == 'cloth07' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setCloth07Attr()

        elif types == 'cloth08' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setCloth08Attr()

        elif types == 'cloth09' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setCloth09Attr()

        elif types == 'cloth10' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setCloth10Attr()

        elif types == 'cloth11' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setCloth11Attr()

        elif types == 'cloth12' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setCloth12Attr()

        elif types == 'cloth13' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setCloth13Attr()

        elif types == 'cloth14' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setCloth14Attr()

        elif types == 'carPaint01' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setCarPaint01Attr()

        elif types == 'metallicCarPaint' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setMetallicCarPaintAttr()

        elif types == 'Chotolate' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setChotolateAttr()

        elif types == 'leather01' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setLeather01Attr()

        elif types == 'leather02' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setLeather02Attr()

        elif types == 'leather03' and num != 0:
            from OCT_ArtificialMateral import OCT_ArtificialMateral as matLib
            matLib(self.allArnolds).setLeather03Attr()

        #######################自然物质#######################
        elif types == 'stone03' and num != 0:
            from OCT_NaturalMatter import OCT_NaturalMatter as matLib
            matLib(self.allArnolds).setStone03Attr()

        elif types == 'clay' and num != 0:
            from OCT_NaturalMatter import OCT_NaturalMatter as matLib
            matLib(self.allArnolds).setClayAttr()

        else:
            mc.delete(self.allArnolds)
            mc.confirmDialog(message=u'目前还没添加属性设置!', button='OK')
            return
Beispiel #36
0
 def _aiLightDecay(self):
     cmds.shadingNode('aiLightDecay', asLight=True)
Beispiel #37
0
 def _aiGobo(self):
     cmds.shadingNode('aiGobo', asLight=True)
Beispiel #38
0
 def _aiWriteFloat(self):
     cmds.shadingNode('aiWriteFloat', asShader=True)
Beispiel #39
0
 def _aiWriteColor(self):
     cmds.shadingNode('aiWriteColor', asShader=True)
Beispiel #40
0
 def _aiVolumeCollector(self):
     cmds.shadingNode('aiVolumeCollector', asShader=True)
Beispiel #41
0
 def create_rig(self, camera, object, dlist, name, rigName):
     """ctx = tools_utils.tool_context(
         use_undo_chunk=True,
         restore_current_frame=True,
         use_dg_evaluation_mode=True,
         disable_viewport=False)
     with ctx:"""
     start_frame, end_frame = time_utils.get_maya_timeline_range_inner()
     # Create main group
     main_grp = cmds.group(empty=True, n=name + rigName)
     # Delete all transform attributes
     attr_list = const.TRANSFORM_ATTR_LIST + ['visibility']
     for attr in attr_list:
         cmds.setAttr(main_grp + '.' + attr, keyable=False,
                         lock=True)
     # Add custom attributes
     cmds.addAttr(main_grp, ln='screenX', nn='Screen X', at='float',
                     k=True)
     cmds.addAttr(main_grp, ln='screenY', nn='Screen Y', at='float',
                     k=True)
     cmds.addAttr(main_grp, ln=const.SCREEN_Z_DEPTH_ATTR_NAME,
                     nn='Screen Z depth', at='float', k=True)
     cmds.addAttr(main_grp, ln=const.ATTRIBUTE_IDENTIFIER_NAME,
                     nn=const.ATTRIBUTE_IDENTIFIER_NICE_NAME, dt='string',
                     k=False)
     cmds.setAttr(main_grp + '.' + const.ATTRIBUTE_IDENTIFIER_NAME,
                     str(object), type='string')
     # Set keyframes on screezdepth attribute
     frames_list = self.get_prebake_frames_list_from_node(object)
     for i, frame in enumerate(frames_list):
         cmds.setKeyframe(main_grp, at=const.SCREEN_Z_DEPTH_ATTR_NAME,
                             t=frame, v=dlist[i])
     # Clear name text
     self.nameLineEdit.clear()
     self.nameLineEdit.clearFocus()
     # Create screez master group
     screenz_master_grp = cmds.group(em=True,
                                     n=name + const.SCREEN_Z_MASTER_NAME)
     cmds.setAttr(screenz_master_grp + '.visibility', 0)
     # Add screen X/Y copy attributes
     cmds.addAttr(screenz_master_grp, ln='copyScreenX',
                     nn='Screen X copy', at='float')
     cmds.addAttr(screenz_master_grp, ln='copyScreenY',
                     nn='Screen Y copy', at='float')
     cmds.setAttr(screenz_master_grp + '.copyScreenX', cb=False)
     cmds.setAttr(screenz_master_grp + '.copyScreenY', cb=False)
     cmds.parent(screenz_master_grp, main_grp)
     con = cmds.parentConstraint(self.get_vp_camera(),
                                 screenz_master_grp)
     fastbake_lib.bake_attributes([screenz_master_grp], [],
                                     start_frame, end_frame, False)
     cmds.delete(con)
     # Create screen Z-depth connections
     cmds.connectAttr(main_grp + '.' + const.SCREEN_Z_DEPTH_ATTR_NAME,
                         screenz_master_grp + '.scaleX', f=True)
     cmds.connectAttr(main_grp + '.' + const.SCREEN_Z_DEPTH_ATTR_NAME,
                         screenz_master_grp + '.scaleY', f=True)
     cmds.connectAttr(main_grp + '.' + const.SCREEN_Z_DEPTH_ATTR_NAME,
                         screenz_master_grp + '.scaleZ', f=True)
     # Create screen X/Y master group
     screen_xy_master_grp = cmds.group(em=True,
                                         n=name + const.SCREEN_XY_MASTER_NAME)
     cmds.setAttr(screen_xy_master_grp + '.visibility', 0)
     attr_list = ['rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'visibility']
     for attr in attr_list:
         cmds.setAttr(screen_xy_master_grp + '.' + attr,
                         keyable=False, lock=True)
     cmds.parent(screen_xy_master_grp, screenz_master_grp, r=True)
     con = cmds.pointConstraint(object, screen_xy_master_grp)
     fastbake_lib.bake_attributes([screen_xy_master_grp], [],
                                     start_frame, end_frame, False)
     cmds.delete(con)
     cmds.setAttr(screen_xy_master_grp + '.translateZ', lock=True)
     # Create screen X/Y connections
     cmds.connectAttr(screen_xy_master_grp + '.translateX',
                         main_grp + '.screenX', f=True)
     cmds.connectAttr(screen_xy_master_grp + '.translateY',
                         main_grp + '.screenY', f=True)
     cmds.connectAttr(screen_xy_master_grp + '.translateX',
                         screenz_master_grp + '.copyScreenX', f=True)
     cmds.connectAttr(screen_xy_master_grp + '.translateY',
                         screenz_master_grp + '.copyScreenY', f=True)
     fastbake_lib.bake_attributes([main_grp], ['screenX', 'screenY'],
                                     start_frame, end_frame, False)
     fastbake_lib.bake_attributes([screenz_master_grp],
                                     ['copyScreenX', 'copyScreenY'],
                                     start_frame, end_frame, False)
     cmds.connectAttr(main_grp + '.screenX',
                         screen_xy_master_grp + '.translateX', f=True)
     cmds.connectAttr(main_grp + '.screenY',
                         screen_xy_master_grp + '.translateY', f=True)
     # Create condition node network
     screenx_condition_node = cmds.shadingNode(
         'condition', au=True, n=name + '_screenX_condition')
     screeny_condition_node = cmds.shadingNode(
         'condition', au=True, n=name + '_screenY_condition')
     cmds.connectAttr(main_grp + '.screenX',
                         screenx_condition_node + '.firstTerm', f=True)
     cmds.connectAttr(screenz_master_grp + '.copyScreenX',
                         screenx_condition_node + '.secondTerm', f=True)
     cmds.connectAttr(main_grp + '.screenY',
                         screeny_condition_node + '.firstTerm', f=True)
     cmds.connectAttr(screenz_master_grp + '.copyScreenY',
                         screeny_condition_node + '.secondTerm', f=True)
     attr_list = const.TRANSFORM_ATTR_LIST + ['visibility']
     for attr in attr_list:
         cmds.setAttr(screenz_master_grp + '.' + attr, lock=True)
     cmds.pointConstraint(screen_xy_master_grp, object)
     # Select the master control.
     cmds.select(main_grp, replace=True)
     self.refresh_rigsList()
Beispiel #42
0
def createLego(x, y, z, name, dimension, victime):

    g = cmds.radioButtonGrp("color", query=True, sl=True)

    #xlego=cmds.intSliderGrp('lLego', query=True, value=True)
    #zlego=cmds.intSliderGrp('loLego', query=True, value=True)

    #lego de base
    #Base
    cmds.polyCube(name="base", w=dimension, d=dimension, h=dimension)
    cmds.polyExtrudeFacet('base.f[3]', lsx=0.9, lsy=0.9, kft=True)
    cmds.polyExtrudeFacet('base.f[3]', ltz=-dimension, kft=True)
    cmds.delete("base.f[3]")

    if cmds.checkBox("bevel", query=True, value=True):
        cmds.polyBevel("base.e[0:11]",
                       "base.e[14]",
                       "base.e[16]",
                       "base.e[18]",
                       "base.e[19]",
                       offset=0.02 * dimension)

    #Cylindre
    cmds.polyCylinder(n="cercle0",
                      r=0.3 * dimension,
                      h=1.15 * dimension,
                      sx=20)
    cmds.move(0, 0.1 * dimension, 0, relative=True)
    cmds.polyExtrudeFacet('cercle0.f[20]', lsx=0.9, lsy=0.9, kft=True)
    cmds.polyExtrudeFacet('cercle0.f[20]', ltz=-dimension, kft=True)
    cmds.delete("cercle0.f[20]")

    if cmds.checkBox("bevel", query=True, value=True):
        cmds.polyBevel("cercle0.e[20:39]",
                       "cercle0.e[0:19]",
                       "cercle0.e[62:99]",
                       offset=0.02 * dimension)

    #Longueur, xLego
    '''for i in range (xlego-1):
        cmds.duplicate("cercle"+`i`, n="cercle"+`i+1`)
        cmds.select("cercle"+`i+1`)
        cmds.move(-2,0,0, relative=True)

    cmds.group("cercle*", name="cerclesx")'''

    # Largeur, zlego
    '''if zlego > 1 :
        for i in range (0, zlego):
            cmds.duplicate("cerclesx", n="cerclesz" +` i+1`)
            cmds.select("cerclesz"+`i+1`)
            cmds.move(0,0,2*i, relative=True)

        cmds.group("cerclesx", "cerclesz*", n="cercles")
        cmds.select("cercles")
        cmds.move(0,0,-zlego+1, relative=True)

    else :
        cmds.rename("cerclesx", "cercles")'''

    # Fin de creation du LEGO
    cmds.polyUnite("cercle0", "base", n="lego" + ` name `, ch=False)
    cmds.move(x, y, z)

    #Dynamique sur Lego
    if cmds.checkBox("physics", query=True, value=True) and cmds.checkBox(
            "animation", query=True, value=True) == False:
        cmds.rigidBody(n='RigidBodyLego', active=True, b=0.5, sf=0.4)

    #Shader
    cmds.shadingNode('blinn', name='legoBlinn' + ` name `, asShader=True)
    cmds.select("lego" + ` name `)
    cmds.hyperShade(assign="legoBlinn" + ` name `)
    cmds.textScrollList('colorblinn', query=True)

    #Selectionne la victime
    cmds.select(victime)

    #Couleur
    cmds.radioButtonGrp("color", query=True, sl=True)
    #Random
    if cmds.radioButtonGrp("color", query=True, sl=True) == 1:
        randIndClr = random.sample(indiceColor, 1)
        cmds.setAttr("legoBlinn" + ` name ` + ".color", randIndClr[0][0],
                     randIndClr[0][1], randIndClr[0][2])

    #Choice
    if cmds.radioButtonGrp("color", query=True, sl=True) == 3:
        colorChoice = cmds.textScrollList("colorblinn", query=True, sii=True)
        random.shuffle(colorChoice)
        cmds.setAttr("legoBlinn" + ` name ` + ".color",
                     indiceColor[colorChoice[0] - 1][0],
                     indiceColor[colorChoice[0] - 1][1],
                     indiceColor[colorChoice[0] - 1][2])

    if cmds.radioButtonGrp("color", query=True, sl=True) == 2:
        colorOther = cmds.colorSliderGrp("othrColor", query=True, rgb=True)
        cmds.setAttr("legoBlinn" + ` name ` + ".color", colorOther[0],
                     colorOther[1], colorOther[2])

    #Object
    if cmds.radioButtonGrp("color", query=True, sl=True) == 4:
        colorObject = colorClosestVertex(x, y, z)
        cmds.setAttr("legoBlinn" + ` name ` + ".color", colorObject[0],
                     colorObject[1], colorObject[2])
Beispiel #43
0
 def _aiUserDataPnt2(self):
     cmds.shadingNode('aiUserDataPnt2', asShader=True)
Beispiel #44
0
 def _aiSkyDomeLight(self):
     cmds.shadingNode('aiSkyDomeLight', asLight=True)
Beispiel #45
0
 def _aiBarndoor(self):
     cmds.shadingNode('aiBarndoor', asLight=True)
Beispiel #46
0
 def _aiFog(self):
     cmds.shadingNode('aiFog', asShader=True)
Beispiel #47
0
 def _aiLightBlocker(self):
     cmds.shadingNode('aiLightBlocker', asLight=True)
Beispiel #48
0
 def _aiVolumeScattering(self):
     cmds.shadingNode('aiVolumeScattering', asShader=True)
Beispiel #49
0
def createLensShaders(centerCam, leftCam, rightCam):
    import maya.mel as mel
    import maya.cmds as cmds
    print "Center: " + centerCam + "Left: " + leftCam + "Right: " + rightCam
    # ---------------------------------------------------------------------
    #Set up the base folder path for the Domemaster3D control maps
    # ---------------------------------------------------------------------

    #Variables
    separationMapFileTexture = getSourceImagesPath(
        "latlong_separation_map.png")
    # turnMapFileTexture = getSourceImagesPath("latlong_turn_map.png")
    # tiltMapFileTexture = getSourceImagesPath("latlong_head_tilt_map.png")

    # ---------------------------------------------------------------------
    # Create the fulldome nodes for the rig
    # ---------------------------------------------------------------------
    centerCamLens = cmds.shadingNode('LatLong_Stereo',
                                     n='center_LatLong_Stereo',
                                     asUtility=True)
    cmds.setAttr(centerCamLens + '.Camera', 0)  #Set the view to center

    leftCamLens = cmds.shadingNode('LatLong_Stereo',
                                   n='left_LatLong_Stereo',
                                   asUtility=True)
    cmds.setAttr(leftCamLens + '.Camera', 1)  #Set the view to left

    rightCamLens = cmds.shadingNode('LatLong_Stereo',
                                    n='right_LatLong_Stereo',
                                    asUtility=True)
    cmds.setAttr(rightCamLens + '.Camera', 2)  #Set the view to right

    # ---------------------------------------------------------------------
    #Connect the lens shaders
    # ---------------------------------------------------------------------
    cmds.connectAttr(centerCamLens + '.message',
                     centerCam + '.miLensShader',
                     force=True)
    cmds.connectAttr(leftCamLens + '.message',
                     leftCam + '.miLensShader',
                     force=True)
    cmds.connectAttr(rightCamLens + '.message',
                     rightCam + '.miLensShader',
                     force=True)

    # ---------------------------------------------------------------------
    # Link the common left and right camera attributes to the center camera
    # ---------------------------------------------------------------------
    # Link the right camera attributes
    cmds.connectAttr(centerCamLens + '.FOV_Vert_Angle',
                     rightCamLens + '.FOV_Vert_Angle',
                     force=True)
    cmds.connectAttr(centerCamLens + '.FOV_Horiz_Angle',
                     rightCamLens + '.FOV_Horiz_Angle',
                     force=True)
    cmds.connectAttr(centerCamLens + '.Parallax_Distance',
                     rightCamLens + '.Parallax_Distance',
                     force=True)
    cmds.connectAttr(centerCamLens + '.Cameras_Separation',
                     rightCamLens + '.Cameras_Separation',
                     force=True)
    cmds.connectAttr(centerCamLens + '.Cameras_Separation_Map',
                     rightCamLens + '.Cameras_Separation_Map',
                     force=True)
    cmds.connectAttr(centerCamLens + '.Head_Tilt_Map',
                     rightCamLens + '.Head_Tilt_Map',
                     force=True)
    cmds.connectAttr(centerCamLens + '.Zenith_Mode',
                     rightCamLens + '.Zenith_Mode',
                     force=True)
    cmds.connectAttr(centerCamLens + '.Flip_Ray_X',
                     rightCamLens + '.Flip_Ray_X',
                     force=True)
    cmds.connectAttr(centerCamLens + '.Flip_Ray_Y',
                     rightCamLens + '.Flip_Ray_Y',
                     force=True)

    # Link the left camera attributes
    cmds.connectAttr(centerCamLens + '.FOV_Vert_Angle',
                     leftCamLens + '.FOV_Vert_Angle',
                     force=True)
    cmds.connectAttr(centerCamLens + '.FOV_Horiz_Angle',
                     leftCamLens + '.FOV_Horiz_Angle',
                     force=True)
    cmds.connectAttr(centerCamLens + '.Parallax_Distance',
                     leftCamLens + '.Parallax_Distance',
                     force=True)
    cmds.connectAttr(centerCamLens + '.Cameras_Separation',
                     leftCamLens + '.Cameras_Separation',
                     force=True)
    cmds.connectAttr(centerCamLens + '.Cameras_Separation_Map',
                     leftCamLens + '.Cameras_Separation_Map',
                     force=True)
    cmds.connectAttr(centerCamLens + '.Head_Tilt_Map',
                     leftCamLens + '.Head_Tilt_Map',
                     force=True)
    cmds.connectAttr(centerCamLens + '.Zenith_Mode',
                     leftCamLens + '.Zenith_Mode',
                     force=True)
    cmds.connectAttr(centerCamLens + '.Flip_Ray_X',
                     leftCamLens + '.Flip_Ray_X',
                     force=True)
    cmds.connectAttr(centerCamLens + '.Flip_Ray_Y',
                     leftCamLens + '.Flip_Ray_Y',
                     force=True)

    # ---------------------------------------------------------------------
    #Set the default camera separation based upon the scene size
    # ---------------------------------------------------------------------
    #centerCamLens = "center_LatLong_Stereo"

    # Check the current Maya scene units
    # Possible Values: [mm | millimeter | cm | centimeter | m | meter | km | kilometer | in | inch | ft | foot | yd | yard | mi | mile]
    sceneScale = cmds.currentUnit(query=True, linear=True)
    print("Scene scale in: " + sceneScale)

    baseSeparationValue = 6.5
    baseDomeRadiusInCm = 360 / baseSeparationValue

    if sceneScale == "cm":
        defaultSeparation = 6.5
        defaultDomeRadius = baseDomeRadiusInCm * defaultSeparation
    elif sceneScale == "centimeter":
        defaultSeparation = 6.5
        defaultDomeRadius = baseDomeRadiusInCm * defaultSeparation
    elif sceneScale == "m":
        defaultSeparation = .065
        defaultDomeRadius = baseDomeRadiusInCm * defaultSeparation
    elif sceneScale == "meter":
        defaultSeparation = .065
        defaultDomeRadius = baseDomeRadiusInCm * defaultSeparation
    elif sceneScale == "km":
        defaultSeparation = 0.000065
        defaultDomeRadius = baseDomeRadiusInCm * defaultSeparation
    elif sceneScale == "kilometer":
        defaultSeparation = 0.000065
        defaultDomeRadius = baseDomeRadiusInCm * defaultSeparation
    elif sceneScale == "in":
        defaultSeparation = 2.362204724409449
        defaultDomeRadius = baseDomeRadiusInCm * defaultSeparation
    elif sceneScale == "inch":
        defaultSeparation = 2.362204724409449
        defaultDomeRadius = baseDomeRadiusInCm * defaultSeparation
    elif sceneScale == "ft":
        defaultSeparation = 0.1968503937007874
        defaultDomeRadius = baseDomeRadiusInCm * defaultSeparation
    elif sceneScale == "foot":
        defaultSeparation = 0.1968503937007874
        defaultDomeRadius = baseDomeRadiusInCm * defaultSeparation
    elif sceneScale == "yd":
        defaultSeparation = 0.065616797900262
        defaultDomeRadius = baseDomeRadiusInCm * defaultSeparation
    elif sceneScale == "yard":
        defaultSeparation = 0.065616797900262
        defaultDomeRadius = baseDomeRadiusInCm * defaultSeparation
    elif sceneScale == "mi":
        defaultSeparation = 3.728227153424004e-5
        defaultDomeRadius = baseDomeRadiusInCm * defaultSeparation
    elif sceneScale == "mile":
        defaultSeparation = 3.728227153424004e-5
        defaultDomeRadius = baseDomeRadiusInCm * defaultSeparation

    #Set the camera separation
    cmds.setAttr(centerCamLens + '.Cameras_Separation', defaultSeparation)
    print("Camera Separation: " + str(defaultSeparation))

    #Set the dome radius
    cmds.setAttr(centerCamLens + '.Parallax_Distance', defaultDomeRadius)
    print("Parallax_Distance: " + str(defaultDomeRadius))

    # ---------------------------------------------------------------------
    # Create the custom Domemaster3D shading networks
    # ---------------------------------------------------------------------

    # Create the nodes
    separation_map_tex_filter = cmds.shadingNode(
        'mib_texture_filter_lookup',
        n='separation_map_mib_texture_filter_lookup1',
        asTexture=True)
    # turn_map_tex_filter =cmds.shadingNode( 'mib_texture_filter_lookup', n='turn_map_mib_texture_filter_lookup1', asTexture=True )
    # tilt_map_tex_filter =cmds.shadingNode( 'mib_texture_filter_lookup', n='tilt_map_mib_texture_filter_lookup1', asTexture=True )

    latlong_tex_vector = cmds.shadingNode('mib_texture_vector',
                                          n='latlong_mib_texture_vector1',
                                          asUtility=True)
    latlong_tex_remap = cmds.shadingNode('mib_texture_remap',
                                         n='latlong_mib_texture_remap1',
                                         asUtility=True)

    separation_map_mr_tex = cmds.shadingNode(
        'mentalrayTexture',
        n='separation_map_mentalrayTexture1',
        asTexture=True)
    # turn_map_mr_tex = cmds.shadingNode( 'mentalrayTexture', n='turn_map_mentalrayTexture1', asTexture=True )
    # tilt_map_mr_tex = cmds.shadingNode( 'mentalrayTexture', n='tilt_map_mentalrayTexture1', asTexture=True )

    # Set the node to use mode (4) which is screen space
    cmds.setAttr(latlong_tex_vector + '.selspace', 4)

    # Connect the nodes
    cmds.connectAttr(separation_map_tex_filter + '.outValueR',
                     centerCamLens + '.Cameras_Separation_Map',
                     force=True)
    cmds.connectAttr(separation_map_mr_tex + '.message',
                     separation_map_tex_filter + '.tex',
                     force=True)

    # cmds.connectAttr( turn_map_tex_filter+'.outValueR', centerCamLens+'.Head_Turn_Map', force=True )
    # cmds.connectAttr( turn_map_mr_tex+'.message', turn_map_tex_filter+'.tex', force=True )

    # cmds.connectAttr( tilt_map_tex_filter+'.outValueR', centerCamLens+'.Head_Tilt_Map', force=True )
    # cmds.connectAttr( tilt_map_mr_tex+'.message', tilt_map_tex_filter+'.tex', force=True )

    cmds.connectAttr(latlong_tex_vector + '.outValue',
                     latlong_tex_remap + '.input',
                     force=True)

    cmds.connectAttr(latlong_tex_remap + '.outValue',
                     separation_map_tex_filter + '.coord',
                     force=True)
    # cmds.connectAttr( latlong_tex_remap+'.outValue', turn_map_tex_filter+'.coord', force=True )
    # cmds.connectAttr( latlong_tex_remap+'.outValue', tilt_map_tex_filter+'.coord', force=True )

    cmds.setAttr(separation_map_mr_tex + '.fileTextureName',
                 separationMapFileTexture,
                 type="string")
    # cmds.setAttr( turn_map_mr_tex+'.fileTextureName', turnMapFileTexture, type="string")
    # cmds.setAttr( tilt_map_mr_tex+'.fileTextureName', tiltMapFileTexture, type="string")

    # ---------------------------------------------------------------------
    #Set up the stereo camera rig's preview shape settings
    # ---------------------------------------------------------------------
    # import maya.mel as mel

    # Select the center camera LatLong_Stereo node
    # cmds.select(centerCamLens, replace=True)

    # Select the center camera LatLong_Stereo node in the attribute editor
    # centerCamLens = "center_LatLong_Stereo"
    # mel.eval ( ' showEditorExact(" ' + centerCamLens + ' ") ' )
    # mel.eval ( ' showEditorExact(" ' + leftCamLens + ' ") ' )
    # mel.eval ( ' showEditorExact(" ' + rightCamLens + ' ") ' )

    # mel.eval ( ' showEditorExact(" ' + centerCamLens + ' ") ' )

    # ---------------------------------------------------------------------
    # Link the center camera lens shader to the Maya camera rig stereo3d settings
    # This enables real-time 3D previews in the viewport
    # ---------------------------------------------------------------------
    cmds.connectAttr(centerCamLens + '.Parallax_Distance',
                     centerCam + '.zeroParallax',
                     force=True)
    cmds.connectAttr(centerCamLens + '.Cameras_Separation',
                     centerCam + '.interaxialSeparation',
                     force=True)

    #Turn on Stereo 3D support for the Domemaster3D Maya camera rig
    cmds.setAttr(centerCam + '.stereo', 1)
Beispiel #50
0
 def _aiImage(self):
     cmds.shadingNode('aiImage', asTexture=True)
Beispiel #51
0
def ConnectMaps_UDIM(selection=False):

    materials = mc.ls(mat=True)

    if selection == False:  ### APPLY TO ALL AI_STANDARDSURFACE SHADERS ###

        shaders = [
            i for i in materials if mc.objectType(i) == "aiStandardSurface"
            and mc.referenceQuery(i, isNodeReferenced=True) == False
        ]

    else:  ### FROM A SELECTION OF SHADERS ###

        selection = mc.ls(sl=True)
        shaders = list(set(set(materials) & set(selection)))

    scene_name = os.path.basename(mc.file(
        q=True, sn=True)).split(".")[0]  # Get scene_name name

    if len(shaders) == 1:
        shader = shaders[0]
    elif len(shaders) == 0:
        raise Exception("You must select a shader")
    else:
        pass

    for shader in shaders:

        shading_group = shading_group = mc.rename(
            mc.listConnections(shader, t='shadingEngine'), shader + "SG")
        shader_name = shader_name = shader.split('_')[1]

        if mc.objExists(scene_name + "_BaseColor"
                        ):  # Check input BaseColor if empty connect file node
            file_BaseColor = scene_name + "_BaseColor"
            upstream_BaseColor = mc.listConnections(shader + ".baseColor",
                                                    d=False,
                                                    s=True)
            if upstream_BaseColor == None:
                mc.connectAttr(file_BaseColor + ".outColor",
                               shader + ".baseColor")
            else:
                pass
        else:
            upstream_BaseColor = mc.listConnections(shader + ".baseColor",
                                                    d=False,
                                                    s=True)
            if upstream_BaseColor == None:
                file_BaseColor = mc.shadingNode("file",
                                                asTexture=True,
                                                isColorManaged=True,
                                                name=scene_name + "_BaseColor")
                mc.connectAttr(file_BaseColor + ".outColor",
                               shader + ".baseColor")
            else:
                pass

        if mc.objExists(
                scene_name +
                "_Height"):  # Check input Height if empty connect file node
            file_Height = scene_name + "_Height"
            if not mc.objExists(scene_name + "_D_" + shader_name):
                disp_node = mc.shadingNode("displacementShader",
                                           asShader=True,
                                           name=scene_name + "_D_" +
                                           shader_name)
                mc.setAttr(disp_node + ".scale", 0)
                mc.setAttr(disp_node + '.aiDisplacementZeroValue', 0.5)
            upstream_Height = mc.listConnections(shading_group +
                                                 ".displacementShader",
                                                 d=False,
                                                 s=True)
            if upstream_Height == None:
                mc.connectAttr(file_Height + ".outAlpha",
                               disp_node + ".displacement")
                mc.connectAttr(disp_node + ".displacement",
                               shading_group + ".displacementShader")
            else:
                pass
        else:
            upstream_Height = mc.listConnections(shading_group +
                                                 ".displacementShader",
                                                 d=False,
                                                 s=True)
            if upstream_Height == None:
                file_Height = mc.shadingNode("file",
                                             asTexture=True,
                                             isColorManaged=True,
                                             name=scene_name + "_Height")
                mc.setAttr(file_Height + ".alphaIsLuminance", 1)
                disp_node = mc.shadingNode("displacementShader",
                                           asShader=True,
                                           name=scene_name + "_D_" +
                                           shader_name)
                mc.connectAttr(file_Height + ".outAlpha",
                               disp_node + ".displacement")
                mc.connectAttr(disp_node + ".displacement",
                               shading_group + ".displacementShader")
                mc.setAttr(disp_node + ".scale", 0)
                mc.setAttr(disp_node + '.aiDisplacementZeroValue', 0.5)
            else:
                pass

        if mc.objExists(scene_name + "_Metalness"
                        ):  # Check input Metalness if empty connect file node
            file_Metalness = scene_name + "_Metalness"
            upstream_Metalness = mc.listConnections(shader + ".metalness",
                                                    d=False,
                                                    s=True)
            if upstream_Metalness == None:
                mc.connectAttr(file_Metalness + ".outAlpha",
                               shader + ".metalness")
            else:
                pass
        else:
            upstream_Metalness = mc.listConnections(shader + ".metalness",
                                                    d=False,
                                                    s=True)
            if upstream_Metalness == None:
                file_Metalness = mc.shadingNode("file",
                                                asTexture=True,
                                                isColorManaged=True,
                                                name=scene_name + "_Metalness")
                mc.setAttr(file_Metalness + ".alphaIsLuminance", 1)
                mc.connectAttr(file_Metalness + ".outAlpha",
                               shader + ".metalness")
            else:
                pass

        if mc.objExists(scene_name + "_Roughness"
                        ):  # Check input Roughness if empty connect file node
            file_Roughness = scene_name + "_Roughness"
            upstream_Roughness = mc.listConnections(shader +
                                                    ".specularRoughness",
                                                    d=False,
                                                    s=True)
            if upstream_Roughness == None:
                mc.connectAttr(file_Roughness + ".outAlpha",
                               shader + ".specularRoughness")
            else:
                pass
        else:
            upstream_Roughness = mc.listConnections(shader +
                                                    ".specularRoughness",
                                                    d=False,
                                                    s=True)
            if upstream_Roughness == None:
                file_Roughness = mc.shadingNode("file",
                                                asTexture=True,
                                                isColorManaged=True,
                                                name=scene_name + "_Roughness")
                mc.setAttr(file_Roughness + ".alphaIsLuminance", 1)
                mc.connectAttr(file_Roughness + ".outAlpha",
                               shader + ".specularRoughness")
            else:
                pass

        if mc.objExists(
                scene_name +
                "_Normal"):  # Check input Normal if empty connect file node
            file_Normal = scene_name + "_Normal"
            if not mc.objExists(scene_name + "_aiNormal_" + shader_name):
                normal_node = core.createArnoldNode("aiNormalMap",
                                                    name=scene_name +
                                                    "_aiNormal_" + shader_name)

            upstream_Normal = mc.listConnections(shader + ".normalCamera",
                                                 d=False,
                                                 s=True)
            if upstream_Normal == None:
                mc.connectAttr(file_Normal + ".outColor",
                               normal_node + ".input")
                mc.connectAttr(normal_node + ".outValue",
                               shader + ".normalCamera")
            else:
                pass

        else:
            upstream_Normal = mc.listConnections(shader + ".normalCamera",
                                                 d=False,
                                                 s=True)
            if upstream_Normal == None:
                file_Normal = mc.shadingNode("file",
                                             asTexture=True,
                                             isColorManaged=True,
                                             name=scene_name + "_Normal")
                normal_node = core.createArnoldNode("aiNormalMap",
                                                    name=scene_name +
                                                    "_aiNormal_" + shader_name)
                mc.connectAttr(file_Normal + ".outColor",
                               normal_node + ".input")
                mc.connectAttr(normal_node + ".outValue",
                               shader + ".normalCamera")
            else:
                pass
Beispiel #52
0
 def _aiNoise(self):
     cmds.shadingNode('aiNoise', asTexture=True)
Beispiel #53
0
from maya import cmds, mel

driver = cmds.ls(sl=1)[0]
driven = cmds.ls(sl=1)[1]

cmds.connectAttr(driver + '.rotateY', driven + '.rotateY')
cmds.connectAttr(driver + '.rotateZ', driven + '.rotateZ')

cmds.connectAttr(driver + '.scaleX', driven + '.scaleX')
cmds.connectAttr(driver + '.scaleY', driven + '.scaleY')
cmds.connectAttr(driver + '.scaleZ', driven + '.scaleZ')

multDiv = cmds.shadingNode('multiplyDivide', au=1)
if cmds.isConnected(driver + '.rotateX', driven + '.rotateX'):
    print("they're connected")
    cmds.disconnectAttr(driver + '.rotateX', driven + '.rotateX')
cmds.connectAttr(driver + '.rotateX', multDiv + '.input1X')
cmds.connectAttr(multDiv + '.outputX', driven + '.rotateX')
cmds.setAttr(multDiv + '.input2X', 3)

cmds.rename(multDiv, driver.replace(driver[-3:], 'multDiv'))
Beispiel #54
0
 def _aiSky(self):
     cmds.shadingNode('aiSky', asTexture=True)
Beispiel #55
0
 def _aiAreaLight(self):
     cmds.shadingNode('aiAreaLight', asLight=True)
Beispiel #56
0
 def _aiPhotometricLight(self):
     cmds.shadingNode('aiPhotometricLight', asLight=True)
Beispiel #57
0
 def _aiUserDataString(self):
     cmds.shadingNode('aiUserDataString', asShader=True)
Beispiel #58
0
 def _aiUserDataBool(self):
     cmds.shadingNode('aiUserDataBool', asShader=True)
Beispiel #59
0
 def _aiUserDataInt(self):
     cmds.shadingNode('aiUserDataInt', asShader=True)
Beispiel #60
0
 def _aiUserDataVector(self):
     cmds.shadingNode('aiUserDataVector', asShader=True)