Exemple #1
0
def changePointLight():
    selectObj = mc.ls(sl=True, l=True)
    for lightName in selectObj:
        mc.select(lightName)
        pos_t = mc.xform(q=True, ws=True, t=True)
        mc.delete(lightName)
        mc.pointLight(pos=pos_t, d=2)
def createScene(res):
    #deleteSun()
    cmds.pointLight(n='Sun')
    cmds.select('Sun')
    cmds.xform(ws=True, t=(0.0, 20.0, -500.0))
           
    #deleteGrid(res)
    tileGrid(res)
def createLight(*args) :
  posLen=cmds.getAttr('fabricVegetation.lightPos', size=True)
  intLen=cmds.getAttr('fabricVegetation.lightInt', size=True)
  light='light'+str(posLen)+'_LGT'
  cmds.pointLight(name=light)
  cmds.connectAttr(light+'.translate', 'fabricVegetation.lightPos['+str(posLen)+']')
  cmds.connectAttr(light+'.intensity', 'fabricVegetation.lightInt['+str(intLen)+']')

  print 'FVegetation: Created and connected '+light+'.'
def createLight(*args):
    posLen = cmds.getAttr('fabricVegetation.lightPos', size=True)
    intLen = cmds.getAttr('fabricVegetation.lightInt', size=True)
    light = 'light' + str(posLen) + '_LGT'
    cmds.pointLight(name=light)
    cmds.connectAttr(light + '.translate',
                     'fabricVegetation.lightPos[' + str(posLen) + ']')
    cmds.connectAttr(light + '.intensity',
                     'fabricVegetation.lightInt[' + str(intLen) + ']')

    print 'FVegetation: Created and connected ' + light + '.'
Exemple #5
0
def create_sun():
    """
    this creates the sun
    """
    cmds.sphere(radius=sun_radius * 0.025, name='sun', axis=[0, 1.0, 0])
    cmds.setAttr('sunShape.castsShadows', 0)
    cmds.setAttr('sunShape.receiveShadows', 0)
    create_texture('sun')

    # this part adds the lignting of the sun
    cmds.pointLight()
    cmds.setAttr("sun_lambert.ambientColor", 1, 1, 1, type="double3")
    animate_rotation('sun', 400)
Exemple #6
0
    def testMetallicF0(self):
        """Tests that the specular F0 of a metallic surface is equal to its base color
        See Pixar USD commit https://github.com/PixarAnimationStudios/USD/commit/f11ab360"""
        cmds.file(force=True, new=True)
        mayaUtils.loadPlugin("mayaUsdPlugin")

        cmds.xform("persp", t=(24, 16, 0), ws=True)
        cmds.xform("persp", ro=[-35, 90, 0], ws=True)

        testFile = testUtils.getTestScene("UsdPreviewSurface",
                                          "F0_is_base.usda")
        mayaUtils.createProxyFromFile(testFile)

        # Need a point light at (0.36, 7.625, 8.111)
        white_light = cmds.pointLight(rgb=(1, 1, 1))
        white_transform = cmds.listRelatives(white_light, parent=True)[0]
        cmds.xform(white_transform, t=(0.36, 7.625, 8.111), ws=True)

        panel = mayaUtils.activeModelPanel()
        cmds.modelEditor(panel, edit=True, lights=False, displayLights="all")

        if int(os.getenv("MAYA_LIGHTAPI_VERSION")) == 2:
            light_api = "V2"
        else:
            light_api = "V1"

        self.assertSnapshotClose('F0_is_base_{}.png'.format(light_api))
Exemple #7
0
def pointLight(*args, **kwargs):
    """
    Maya Bug Fix:
      - name flag was ignored
    """
    if kwargs.get('query', kwargs.get('q', False)) or kwargs.get(
            'edit', kwargs.get('e', False)):
        return cmds.pointLight(*args, **kwargs)

    else:
        name = kwargs.pop('name', kwargs.pop('n', False))
        if name:
            tmp = cmds.pointLight(*args, **kwargs)
            tmp = cmds.rename(cmds.listRelatives(tmp, parent=1)[0], name)
            return _general.PyNode(cmds.listRelatives(tmp, shapes=1)[0])

    return _general.PyNode(cmds.pointLight(*args, **kwargs))
def ReadLightMap(fileName, GroupName):
	
	# create a group for the lights
	mc.group( em=True, name=GroupName);	
	# LightNum used to append to GroupName for the Light
	LightNum=0
	# so we open the file for reading
	lightFile=open(fileName,'r')
	# read in all the data
	try :
		data=lightFile.readlines()
		#now read through the file and grab data
		for line in data :
			# tokenise the data into tuple light
			light=line.split()
			# File Line Format is x,y,z r,g,b, Shadowed[1,0], Intensity
			# we need to use the constructors for float to ensure we get floats not strings
			x=float(light[0])
			y=float(light[1])
			z=float(light[2])
			r=float(light[3])
			g=float(light[4])
			b=float(light[5])
			# we convert shad to a boolean
			shad=bool(light[6])
			intensity=float(light[7])
			# create a name for the light
			LightName=GroupName+"%d" %(LightNum)
			
			# now run maya commands to create the light dome from map
			# create a point light
			#print LightName,x,y,z,r,g,b
			mc.pointLight(name=LightName,position=[x,y,z], rgb=[r,g,b] ,i=intensity ,rs=shad)
			# select it
			mc.select(LightName,r=True)
			# parent it to the group
			mc.parent(LightName,GroupName ,relative=True)
			LightNum+=1;
	finally :
		# finished with the file so close
		lightFile.close()
def create_light(*args):

    light_name = args[0]
    if not(cmds.objExists(light_name)):
        # Create a directional light
        if args[1] == "dir":
            light = cmds.directionalLight( n=args[0],rotation=(-60, 5, 30))

            # Change the light intensity
            cmds.directionalLight( light, e=True, intensity=1 ,sc = (1,1,1), rs = 0)
            mel.eval( "setAttr " + light+".useDepthMapShadows 1;")
            mel.eval( "setAttr " + light+".dmapBias 10;")
            l_t = cmds.listRelatives(light, p=True)
            
        if args[1] == "pt":
            light = cmds.pointLight( n=args[0])
            cmds.pointLight (light, e=True, intensity = 1, rs=1)
            l_t = cmds.listRelatives(light, p=True)
            cmds.setAttr(l_t[0]+".ty", 20)
            
    return light_name
Exemple #10
0
    def createLight(self, lightObj, name):
        if lightObj.lightType == "Directional":
            light = mc.directionalLight(name=name, rgb=lightObj.color, intensity=lightObj.intensity,
                                 rs=lightObj.castShadows)
        elif lightObj.lightType == "Point":
            light = mc.pointLight(name=name, rgb=lightObj.color, intensity=lightObj.intensity,
                                 rs=lightObj.castShadows)
        else:
            light = mc.spotLight(name=name, coneAngle=45, rgb=lightObj.color, intensity=lightObj.intensity,
                                 rs=lightObj.castShadows)

        return light
    def testMinimalAdaptation(self):
        """Test that we can adapt ShadowAPI to an existing light shape. This exercises the most
        basic callbacks exposed by a SchemaAPI adaptor:"""

        mayaUsdLib.SchemaApiAdaptor.Register(shadowApiAdaptorShape, "light",
                                             "ShadowAPI")

        lightShape1 = cmds.pointLight()
        cmds.setAttr(lightShape1 + ".shadowColor", 0.5, 0.25, 0)
        lightShape2 = cmds.pointLight()
        cubeXform, cubeShape = cmds.polyCube()

        # Wrong type: not adapted
        adaptor = mayaUsdLib.Adaptor(cubeShape)
        self.assertEqual(adaptor.GetAppliedSchemas(), [])

        # Wrong name: not adapted
        adaptor = mayaUsdLib.Adaptor(lightShape2)
        self.assertEqual(adaptor.GetAppliedSchemas(), [])

        # Adapted:
        adaptor = mayaUsdLib.Adaptor(lightShape1)
        self.assertEqual(adaptor.GetAppliedSchemas(), ["ShadowAPI"])

        schema = adaptor.GetSchemaByName("ShadowAPI")
        self.assertTrue(schema)

        self.assertEqual(set(schema.GetAuthoredAttributeNames()),
                         set(["inputs:shadow:color", "inputs:shadow:enable"]))
        colorAttr = schema.GetAttribute("inputs:shadow:color")
        self.assertTrue(colorAttr)
        linearizedValue = (0.21763764, 0.047366142, 0)
        colorAttrValue = colorAttr.Get()
        self.assertAlmostEqual(linearizedValue[0], colorAttrValue[0])
        self.assertAlmostEqual(linearizedValue[1], colorAttrValue[1])
        self.assertEqual(linearizedValue[2], colorAttrValue[2])

        colorAttr.Set((1, 0, 1))
        self.assertEqual(cmds.getAttr(lightShape1 + ".shadowColor"),
                         [(1.0, 0.0, 1.0)])
Exemple #12
0
    def createLight(self, lightNodeType, lightName, *args, **kwargs):
        preCreationSelection = mc.ls(sl=True, long=True)
        if len(preCreationSelection) < 1:
            preCreationSelection = None
        else:
            preCreationSelection = preCreationSelection[0]

        if lightNodeType == 'spotLight':
            shapeNode = mc.spotLight(name=lightName)
        elif lightNodeType == 'directionalLight':
            shapeNode = mc.directionalLight(name=lightName)
        elif lightNodeType == 'pointLight':
            shapeNode = mc.pointLight(name=lightName)
        elif lightNodeType == 'ambientLight':
            shapeNode = mc.ambientLight(name=lightName)
        elif lightNodeType == 'volumeLight':
            initNode = mc.createNode('volumeLight')
            transform = mc.listRelatives(initNode, parent=True,
                                         fullPath=True)[0]
            result = mc.rename(transform, lightName)
            shapeNode = mc.listRelatives(result,
                                         shapes=True,
                                         noIntermediate=True,
                                         type='light')[0]
        elif lightNodeType == 'areaLight':
            initNode = mc.createNode('areaLight')
            transform = mc.listRelatives(initNode, parent=True,
                                         fullPath=True)[0]
            result = mc.rename(transform, lightName)
            shapeNode = mc.listRelatives(result,
                                         shapes=True,
                                         noIntermediate=True,
                                         type='light')[0]
        else:
            return None
        if shapeNode:
            transformNode = mc.listRelatives(shapeNode, parent=True)[0]
            self.alignLight(transformNode, preCreationSelection)
            tools.setDefaultAttrs(shapeNode)

            try:
                self.post_fn.postLightCreation(transformNode, shapeNode, *args,
                                               **kwargs)
            except:
                tools.logger.exception(
                    "Post light creation function not executed due to exceptions"
                )
            finally:
                return transformNode, shapeNode
        else:
            return None
Exemple #13
0
def createLight(position, ampList, audioLength):
    """create a light at the position given, which changes colour based on the list of amplitudes given.
	
	position    : position to place the light
	ampList     : list of values to influence colour of light
	audioLength : length of the audio, in frames
	"""
    # create point light at position
    light = cmds.pointLight(position=(position[0] - 1.5, position[1], position[2]))
    # change the decay rate to quadratic
    cmds.setAttr(light + ".decayRate", 2)
    # increase the intensity of the light
    cmds.setAttr(light + ".intensity", 1500)
    return light
Exemple #14
0
def createLight(position, ampList, audioLength):
	'''create a light at the position given, which changes colour based on the list of amplitudes given.
	
	position    : position to place the light
	ampList     : list of values to influence colour of light
	audioLength : length of the audio, in frames
	'''
	#create point light at position
	light = cmds.pointLight(position = (position[0]- 1.5, position[1], position[2]))
	#change the decay rate to quadratic
	cmds.setAttr(light+".decayRate", 2)
	#increase the intensity of the light
	cmds.setAttr(light+".intensity", 1500)
	return light
 def setLights(self):
     if self.furniture is None:
         dbg("%s non ha furniture ", self)
         return False
     for f in self.furniture:
         if f.type == "light":
             light = cmd.pointLight(rs=True,
                                    ss=True,
                                    i=len(f) / Room.scale,
                                    n=f.mayaObj + "_light")
             translation = list(cmd.getAttr(f.mayaObj + '.translate')[0])
             lmax = f.getLMax()
             translation[lmax] -= f.__len__(lmax)
             cmd.move(translation[0], translation[1], translation[2], light)
Exemple #16
0
 def setUp(self):
     OpenMaya.MFileIO.newFile(True)
     master = cmds.group(name='master', empty=True)
     for i in (1, 2):
         root = cmds.group(name='root_%d' % i, parent=master, empty=True)
         child = cmds.group(name='child_%d' % i, parent=root, empty=True)
         node = cmds.group(name='node', parent=child, empty=True)
     
     cmds.group('|master|root_2|child_2|node', name='grandchild', parent='|master|root_2|child_2')
     cmds.group(name='node', parent='|master', empty=True)
     cmds.group(name='awesome_node', parent='|master', empty=True)
     cmds.group(name='node_awesome', parent='|master', empty=True)
     cmds.group(name='n0de', parent='|master', empty=True)
     cmds.polyCube(name='cube')
     cmds.parent('cube', '|master')
     cmds.sphere(name='sphere')
     cmds.parent('sphere', '|master')
     cmds.circle(name='circle')
     cmds.parent('|circle', '|master')
     cmds.projectCurve('|master|circle', '|master|sphere')
     cmds.namespace(add='awesome')
     cmds.pointLight(name='awesome:light')
     cmds.parent('|awesome:light', '|master')
Exemple #17
0
def addLight(kind, *args):
	if(not cmds.ls('lights')):
		cmds.group(name='lights', em=True, w=True)
	if kind == 'spot':
		newLight = cmds.spotLight()
	elif kind == 'dir':
		newLight = cmds.directionalLight()
	elif kind == 'point':
		newLight = cmds.pointLight()
	elif kind == 'amb':
		newLight = cmds.ambientLight()
	elif kind == 'area':
		newLight = cmds.shadingNode ('areaLight', asLight=True)
	cmds.parent(newLight, 'lights')
	refresh()
Exemple #18
0
def add_light(kind, *args):
    """adds a new light, organizes it, and refreshes the UI"""
    if(not cmds.ls('lights')):
        cmds.group(name='lights', em=True, w=True)
    if kind == 'spot':
        new_light = cmds.spotLight()
    elif kind == 'dir':
        new_light = cmds.directionalLight()
    elif kind == 'point':
        new_light = cmds.pointLight()
    elif kind == 'amb':
        new_light = cmds.ambientLight()
    elif kind == 'area':
        new_light = cmds.shadingNode ('areaLight', asLight=True)
    cmds.parent(new_light, 'lights')
    refresh()
Exemple #19
0
def add_light(kind, *args):
    """adds a new light, organizes it, and refreshes the UI"""
    if (not cmds.ls('lights')):
        cmds.group(name='lights', em=True, w=True)
    if kind == 'spot':
        new_light = cmds.spotLight()
    elif kind == 'dir':
        new_light = cmds.directionalLight()
    elif kind == 'point':
        new_light = cmds.pointLight()
    elif kind == 'amb':
        new_light = cmds.ambientLight()
    elif kind == 'area':
        new_light = cmds.shadingNode('areaLight', asLight=True)
    cmds.parent(new_light, 'lights')
    refresh()
Exemple #20
0
def addPointLight(pos):
    pointLight = mc.pointLight(name='pointLight')
    mc.move(pos[0], pos[1], pos[2], pointLight)
    def Light_Import_Fn(self):
        File_Path = QFileDialog.getOpenFileName(self,
                                                caption=u"保存文件到",
                                                directory=".",
                                                filter="json (*.json)")
        # 空数组处理
        try:
            if type(File_Path) is tuple:
                File_Path = File_Path[0]
            if type(File_Path) is list:
                File_Path = File_Path[0]
        except:
            traceback.print_exc()
            return

        if os.path.exists(File_Path):
            Light_Json = {}
            with open(File_Path, 'r') as f:
                Light_Json = json.load(f)

            for lightName in Light_Json['LightData']:
                lightName = Light_Json['LightData'][lightName]

                if lightName['Type'] == "pointLight":
                    light = cmds.pointLight(n=lightName['Name'])
                elif lightName['Type'] == "spotLight":
                    light = cmds.spotLight(n=lightName['Name'])
                    cmds.setAttr(light + ".coneAngle", lightName['coneAngle'])
                    cmds.setAttr(light + ".penumbraAngle",
                                 lightName['penumbraAngle'])
                    cmds.setAttr(light + ".dropoff", lightName['dropoff'])
                elif lightName['Type'] == "areaLight":
                    light = cmds.spotLight(n=lightName['Name'])
                elif lightName['Type'] == "directionalLight":
                    light = cmds.spotLight(n=lightName['Name'])
                elif lightName['Type'] == "aiSkyDomeLight":
                    mtoa.utils.createLocatorWithName("aiSkyDomeLight",
                                                     lightName['Name'],
                                                     asLight=True)
                elif lightName['Type'] == "aiAreaLight1":
                    mtoa.utils.createLocatorWithName("aiAreaLight",
                                                     lightName['Name'],
                                                     asLight=True)

                R = lightName['color']['R']
                G = lightName['color']['G']
                B = lightName['color']['B']
                cmds.setAttr(light + ".color", type="double3", R, G, B)

                cmds.setAttr(light + ".intensity", lightName['Intensity'])
                cmds.setAttr(light + ".aiExposure", lightName['Exposure'])

                tx = lightName['Translate']['tx']
                ty = lightName['Translate']['ty']
                tz = lightName['Translate']['tz']
                cmds.setAttr(lightName['Name'] + ".tx", tx)
                cmds.setAttr(lightName['Name'] + ".ty", ty)
                cmds.setAttr(lightName['Name'] + ".tz", tz)

                rx = lightName['Rotate']['rx']
                ry = lightName['Rotate']['ry']
                rz = lightName['Rotate']['rz']
                cmds.setAttr(lightName['Name'] + ".rx", rx)
                cmds.setAttr(lightName['Name'] + ".ry", ry)
                cmds.setAttr(lightName['Name'] + ".rz", rz)

                sx = lightName['Scale']['sx']
                sy = lightName['Scale']['sy']
                sz = lightName['Scale']['sz']
                cmds.setAttr(lightName['Name'] + ".sx", sx)
                cmds.setAttr(lightName['Name'] + ".sy", sy)
                cmds.setAttr(lightName['Name'] + ".sz", sz)

                cmds.setAttr(light + ".coneAngle", lightName['coneAngle'])
                cmds.setAttr(light + ".coneAngle", lightName['coneAngle'])
                cmds.setAttr(light + ".coneAngle", lightName['coneAngle'])
                cmds.setAttr(light + ".coneAngle", lightName['coneAngle'])

        else:
            return
Exemple #22
0
    def Light_Import_Fn(self):
        File_Path = QFileDialog.getOpenFileName(self,
                                                caption=u"保存文件到",
                                                directory=".",
                                                filter="json (*.json)")
        # Note 空数组处理
        try:
            if type(File_Path) is tuple:
                File_Path = File_Path[0]
            if type(File_Path) is list:
                File_Path = File_Path[0]
        except:
            traceback.print_exc()
            return

        if not os.path.exists(File_Path):
            return

        Light_Json = {}
        with open(File_Path, 'r') as f:
            Light_Json = json.load(f)

        for lightName in Light_Json['LightData']:

            if cmds.objExists(lightName):
                continue

            lightNameData = Light_Json['LightData'][lightName]

            # Note 检查灯光的类型
            if lightNameData['Type'] == "pointLight":
                light = cmds.pointLight(n=lightName)
            elif lightNameData['Type'] == "spotLight":
                light = cmds.spotLight(n=lightName)
                cmds.setAttr(light + ".coneAngle", lightNameData['coneAngle'])
                cmds.setAttr(light + ".penumbraAngle",
                             lightNameData['penumbraAngle'])
                cmds.setAttr(light + ".dropoff", lightNameData['dropoff'])
            elif lightNameData['Type'] == "areaLight":
                light = cmds.shadingNode('areaLight',
                                         asLight=1,
                                         n=lightNameData['Name'])
            elif lightNameData['Type'] == "directionalLight":
                light = cmds.directionalLight(n=lightName)
            elif lightNameData['Type'] == "aiSkyDomeLight":
                try:
                    aiLight = mtoa.utils.createLocatorWithName(
                        "aiSkyDomeLight", lightName, asLight=True)
                except:
                    print "fail to build the aiSkyDomeLight - skip this light"
                    continue
                cmds.rename(aiLight[0], lightNameData['Name'])
            elif lightNameData['Type'] == "aiAreaLight":
                try:
                    aiLight = mtoa.utils.createLocatorWithName("aiAreaLight",
                                                               lightName,
                                                               asLight=True)
                except:
                    print "fail to build the aiAreaLight - skip this light"
                    continue
                cmds.rename(aiLight[0], lightNameData['Name'])

            R = lightNameData['color']['R']
            G = lightNameData['color']['G']
            B = lightNameData['color']['B']
            cmds.setAttr(lightNameData['Name'] + ".color",
                         R,
                         G,
                         B,
                         type="double3")

            cmds.setAttr(lightNameData['Name'] + ".intensity",
                         lightNameData['Intensity'])
            cmds.setAttr(lightNameData['Name'] + ".aiExposure",
                         lightNameData['Exposure'])

            tx = lightNameData['Translate']['tx']
            ty = lightNameData['Translate']['ty']
            tz = lightNameData['Translate']['tz']
            cmds.setAttr(lightName + ".tx", tx)
            cmds.setAttr(lightName + ".ty", ty)
            cmds.setAttr(lightName + ".tz", tz)

            rx = lightNameData['Rotate']['rx']
            ry = lightNameData['Rotate']['ry']
            rz = lightNameData['Rotate']['rz']
            cmds.setAttr(lightName + ".rx", rx)
            cmds.setAttr(lightName + ".ry", ry)
            cmds.setAttr(lightName + ".rz", rz)

            sx = lightNameData['Scale']['sx']
            sy = lightNameData['Scale']['sy']
            sz = lightNameData['Scale']['sz']
            cmds.setAttr(lightName + ".sx", sx)
            cmds.setAttr(lightName + ".sy", sy)
            cmds.setAttr(lightName + ".sz", sz)

        QMessageBox.warning(self, u"Success", u"Json Import Success!")
Exemple #23
0
def create_point_light():
    mc.pointLight()
def game():
    cmds.file(force=True, new=True)
    #length of playback for game
    cmds.playbackOptions(maxTime='20sec')
    #lights
    cmds.directionalLight()
    cmds.scale(4.910268, 4.910268, 4.910268, r=True)
    cmds.move(17.938379, 12.193473, 0, r=True)
    cmds.rotate(0, 98.271943, 0, r=True, os=True, fo=True)
    cmds.rotate(-23.925408, 0, 0, r=True, os=True, fo=True)
    cmds.move(0, 0, -0.622877, r=True)
    cmds.move(0, 0, -3.289271, r=True)
    cmds.duplicate()
    #// Result: directionalLight2 //
    cmds.move(-20.838684, 0, 0, r=True)
    cmds.rotate(0, 24.509822, 0, r=True, os=True, fo=True)
    cmds.rotate(0, 103.346384, 0, r=True, os=True, fo=True)
    cmds.rotate(-44.285251, 0, 0, r=True, os=True, fo=True)
    cmds.move(-14.586563, 0, 0, r=True)
    cmds.move(0, 0, -5.104265, r=True)
    cmds.move(0, 0, -4.284069, r=True)
    cmds.pointLight()
    cmds.move(0, 0, 5.003762, r=True)
    cmds.move(0, 0, 11.322471, r=True)
    cmds.move(0, 0, 3.520321, r=True)
    cmds.duplicate()
    #// Result: pointLight2 //
    cmds.move(0, 0, -62.281584, r=True)
    cmds.move(0, 0, 20.779332, r=True)
    cmds.setAttr("pointLightShape1.intensity", 0.2)
    #prefix for parts
    pfx = "jenga_"
    #the jenga brick
    cmds.polyCube(d=3, h=0.5, n=pfx + "brick")
    myBlinn = cmds.shadingNode('blinn', asShader=True)
    cmds.select(pfx + "brick")
    cmds.hyperShade(assign=myBlinn)
    cmds.select(cl=True)
    cmds.hyperShade(objects=myBlinn)
    cmds.setAttr("blinn1.color", 0.243, 0.155, 0.101, type="double3")
    cmds.setAttr("blinn1.ambientColor", 1, 1, 1, type="double3")
    # create a new MASH network with grid distribution
    mashNetwork = mapi.Network()
    mashNetwork.createNetwork(name=pfx + "tower",
                              distributionStyle=6,
                              geometry="Repro")
    #adjust the distribution
    cmds.setAttr(mashNetwork.distribute + ".gridz", 1)
    cmds.setAttr(mashNetwork.distribute + ".gridx", 3)
    cmds.setAttr(mashNetwork.distribute + ".gridy", 1)
    cmds.setAttr(mashNetwork.distribute + ".gridAmplitudeZ", 0)
    cmds.setAttr(mashNetwork.distribute + ".gridAmplitudeY", 0)
    cmds.setAttr(mashNetwork.distribute + ".gridAmplitudeX", 2.05)
    # add a Replicator node
    rep = mashNetwork.addNode("MASH_Replicator")
    # add a Dyanmics node
    dyn = mashNetwork.addNode("MASH_Dynamics")
    # add a Python node
    py = mashNetwork.addNode("MASH_Python")
    #adjust the Replicator settings to make a tower
    cmds.setAttr(pfx + "tower_Replicator.replicants", 17)
    cmds.setAttr(pfx + "tower_Replicator.offsetPositionY", 0.5)
    cmds.setAttr(pfx + "tower_Replicator.offsetPositionX", 0)
    cmds.setAttr(pfx + "tower_Replicator.offsetPositionZ", 0)
    cmds.setAttr(pfx + "tower_Replicator.rotatePointsY", 1530)
    #ajust the bullet solver ground plane
    cmds.setAttr(pfx + "tower_BulletSolverShape.groundPlanePositionY", -0.25)
    #ajust the Dynamics settings
    cmds.setAttr(pfx + "tower_Dynamics.friction", 1)
    #add the python code
    cmds.polyCube(n=pfx + "test")
Exemple #25
0
import maya.cmds as cmds
cmds.pointLight(name='red_light',rgb=[1,0,0],position=[0,2.5,0]) 
cmds.polyPlane(width=10,height=10)