def shadowRig(): controls = [ "translateX", "translateY", "translateZ", \ "rotateX", "rotateY", "rotateZ", \ "scaleX", "scaleY", "scaleZ", "v" ] negLightAttr = [ "decayRate", "emitSpecular", "useDepthMapShadows", \ "dmapResolution", "dmapFilterSize", "color", \ "shadowColor", "useRayTraceShadows", "lightRadius", \ "shadowRays"] # Create group shadowSpot = cmds.group(em=True, name='shadowSpot#') # Grab index index = None if re.search('[0-9]+$', shadowSpot): index = re.search('[0-9]+$', shadowSpot).group()[0] # Save spotlight names shadowLightName = ('shadowLight' + index) shadowNegLightName = ('shadowNegLight' + index) # Create spotlights shadowLight = cmds.spotLight( name=shadowLightName ) shadowNegLight = cmds.spotLight( name=shadowNegLightName ) # Add spotlights to group cmds.group( shadowLightName, shadowNegLightName, useAsGroup=shadowSpot ) # Create constraints cmds.pointConstraint( shadowLightName, shadowNegLightName ) cmds.orientConstraint( shadowLightName, shadowNegLightName ) # Connect shape attributes cmds.connectAttr( (shadowLight + '.coneAngle'), (shadowNegLight + '.coneAngle'), force=True ) cmds.connectAttr( (shadowLight + '.dropoff'), (shadowNegLight + '.dropoff'), force=True ) cmds.connectAttr( (shadowLight + '.penumbraAngle'), (shadowNegLight + '.penumbraAngle'), force=True ) # Create utility node shadowSpotIntensity = cmds.shadingNode( 'multiplyDivide', asUtility=True, name=(shadowSpot + 'mdIntensity') ) cmds.connectAttr( (shadowLight + '.intensity'), (shadowSpotIntensity + '.input1X') ) cmds.setAttr ( (shadowSpotIntensity + '.input2X'), -1 ) cmds.connectAttr ( (shadowSpotIntensity + '.outputX'), (shadowNegLight + '.intensity') ) # Zero out shadow light attributes cmds.setAttr ( (shadowNegLightName + ".useDepthMapShadows"), 0 ) cmds.setAttr ( (shadowNegLightName + ".useRayTraceShadows"), 0 ) # Lock attributes for attr in negLightAttr: cmds.setAttr ( (shadowNegLightName + "." + attr), lock=True, keyable=False ) # Lock and hide spotlight controls for control in controls: cmds.setAttr ( (shadowSpot + "." + control), lock=True, keyable=False ) cmds.setAttr ( (shadowNegLightName + "." + control), lock=True, keyable=False ) # Activate displayHandle cmds.setAttr ( (shadowLightName + ".displayHandle"), 1 )
def psd_driver_display(psd_driver, mode=1): if psd_driver.find("_psd_driver_gr") == -1: # not found cmds.warning('PSD Driver is not selected, aborting...') return prefix = psd_driver.replace('_psd_driver_gr', '') goal_pos = prefix + '_goal_pos' target_pos = prefix + '_goal_pos' display_object = prefix + "psd_driver_display" angle_mult = prefix + "_angle_mult" annotation = prefix + '_annotation' num_to_str = prefix + "_num_to_str" if mode == 0 : #delete try: cmds.delete(display_object, angle_mult) except: pass return if mode == 1 : #create if not cmds.objExists(display_object): cmds.spotLight(intensity=0, name = display_object) display_object_shape = cmds.listRelatives(display_object)[0] cmds.setAttr(display_object_shape + '.overrideEnabled', 1) cmds.setAttr(display_object_shape + '.overrideDisplayType', 2) cmds.parent(display_object, psd_driver, relative=True) cmds.aimConstraint(goal_pos, display_object, aimVector=[0,0,-1]) angle_mult = cmds.createNode('multDoubleLinear', name = angle_mult) cmds.connectAttr(psd_driver + ".startAngle", angle_mult + ".input1") cmds.setAttr(angle_mult + ".input2", 2) cmds.connectAttr(angle_mult + ".output", display_object + ".coneAngle") annotation_shape = cmds.annotate(display_object, text='temp', p=[0,0,0]) print annotation_shape cmds.setAttr(annotation_shape + '.displayArrow', 0) annotationNode = cmds.listRelatives(annotation_shape, p=True)[0] cmds.parent(annotationNode, display_object, r=True) cmds.setAttr(annotationNode + ".translateZ", -1.0) cmds.createNode('numToStr', name=num_to_str) cmds.connectAttr(psd_driver + ".psdBlend", num_to_str + ".input") cmds.connectAttr(num_to_str + ".output", annotation_shape + ".text") #cmds.rename (annotationNode, annotation) return display_object
def demo(): cmds.file(f=1, new=1) cmds.polyPlane(w=50, h=50) cmds.rotate(1.555, -6.203, 6.393, r=1, os=1, fo=1) cmds.spotLight() cmds.move(14.142, 26.414, 18.0) cmds.rotate(-54, 36.4, 0, r=1, os=1, fo=1) if cmds.objExists('arrows'): cmds.delete('arrows') cmds.select(['pPlane1', 'spotLight1']) intersect()
def test_createLight_existing(self): factory = LightsFactory() mc.spotLight(name='dramatic_bounce_chars_016_LGT') mc.spotLight(name='dramatic_bounce_chars_017_LGT') lightName = factory.buildName('chars', 16, category='dramatic', function='bounce') lightCreated = factory.createLight('spotLight', lightName) name = 'dramatic_bounce_chars_018_LGT' self.assertEqual(lightCreated[0], name)
def spotLight(*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.spotLight(*args, **kwargs) else: name = kwargs.pop('name', kwargs.pop('n', False)) if name: tmp = cmds.spotLight(*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.spotLight(*args, **kwargs))
def caustic_light(e): # Creation Spot Light # cmds.spotLight(ca=120) cmds.setAttr("spotLightShape1.aiExposure", e) cmds.rotate(-90, 0, 0) cmds.move(0, 15, 0) cmds.scale(5, 5) #Noise Texture# cmds.shadingNode("noise", n="LightOcean", asTexture=True) cmds.setAttr("LightOcean.threshold", 0) cmds.setAttr("LightOcean.amplitude", 1) cmds.setAttr("LightOcean.ratio", 0.18) cmds.setAttr("LightOcean.frequency", 20) cmds.setAttr("LightOcean.inflection", 1) cmds.setAttr("LightOcean.noiseType", 4) # Node Reverse texture, Changer les parties noire blanche " cmds.shadingNode("reverse", asUtility=True) cmds.connectAttr("LightOcean.outColor", "reverse1.input") # Node color Correct # cmds.shadingNode("colorCorrect", asUtility=True) cmds.setAttr("colorCorrect1.colGammaX", 0.5) cmds.setAttr("colorCorrect1.colGammaY", 0.5) cmds.setAttr("colorCorrect1.colGammaZ", 0.5) cmds.connectAttr("reverse1.output", "colorCorrect1.inColor") # Node Light Filter aiGobo pour prendre l'alpha de la texture Noise # cmds.shadingNode("aiGobo", asUtility=True) cmds.connectAttr("colorCorrect1.outColor", "aiGobo1.slidemap") # Connection filter Gobo Transparency a la spotLight # cmds.connectAttr("aiGobo1.outTransparency", "spotLightShape1.aiFilters[0]") # Animation light # cmds.expression(o="LightOcean", ae=True, uc=all, s="LightOcean.time=time/2") SetupLighting()
def createBtnCmd(self, *args): """Function to execute when Create button is pressed""" # create 3 lights and place them in the right location self.lights.append(cmds.spotLight(n='keyLight')) cmds.setAttr('keyLight.translate', -2, 3, 10, type="double3") self.lights.append(cmds.spotLight(n='fillLight')) cmds.setAttr('fillLight.translate', 6, 0, 2, type="double3") self.lights.append(cmds.spotLight(n='backLight')) cmds.setAttr('backLight.translate', -1, 8, -10, type="double3") self.findLightAngle('keyLight') self.findLightAngle('fillLight') self.findLightAngle('backLight') #flip backlight back towards the origin cmds.select('backLight') cmds.rotate(180, y=1, r=1, os=1) cmds.group('keyLight', 'fillLight', 'backLight', n='Three_Point_Lights')
def setIntensityCmd(self, *args): """Function called when Global intensity slider is changed, and updates intensity""" intensity = None # obtain input as a float try: ctrlPath = '|'.join( [self.window, 'centralwidget', self.intensitySlider] ) intensity = .02 * float( cmds.intSlider(ctrlPath, q=True, value=True) ) except: raise for l in self.lights: if (l == 'fillLightShape'): adjIntensity = intensity * .6 elif (l == 'keyLightShape'): adjIntensity = intensity else: adjIntensity = intensity * .9 cmds.spotLight(l, e=1, i=adjIntensity)
def setUp(self): light1 = mc.spotLight() light2 = mc.spotLight() light3 = mc.spotLight() light4 = mc.spotLight() light5 = mc.spotLight() self.light1Trans = mc.listRelatives(light1, parent=True, fullPath=True)[0] self.light2Trans = mc.listRelatives(light2, parent=True, fullPath=True)[0] self.light3Trans = mc.listRelatives(light3, parent=True, fullPath=True)[0] self.light4Trans = mc.listRelatives(light4, parent=True, fullPath=True)[0] self.light5Trans = mc.listRelatives(light5, parent=True, fullPath=True)[0] mc.setAttr(self.light4Trans + '.visibility', 0) mc.setAttr(self.light5Trans + '.visibility', 0) tools.lightsVisibilitySnapshot()
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 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
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()
def createLightRig(): offsetAmount = 20 lightRotation = 30 newLight = cmds.spotLight(rgb=(1, 1, 1), name="KeyLight") lightTransform = cmds.listRelatives(newLight, parent=True) keyLight = lightTransform[0] newLight = cmds.spotLight(rgb=(0.8, 0.8, 0.8), name="FillLight") lightTransform = cmds.listRelatives(newLight, parent=True) fillLight = lightTransform[0] newLight = cmds.directionalLight(rgb=(0.2, 0.2, 0.2), name="BackLight") lightTransform = cmds.listRelatives(newLight, parent=True) backLight = lightTransform[0] cmds.move(0, 0, offsetAmount, keyLight) cmds.move(0, 0, 0, keyLight + ".rotatePivot") cmds.rotate(-lightRotation, lightRotation, 0, keyLight) cmds.move(0, 0, offsetAmount, fillLight) cmds.move(0, 0, 0, fillLight + ".rotatePivot") cmds.rotate(-lightRotation, -lightRotation, 0, fillLight) cmds.move(0, 0, offsetAmount, backLight) cmds.move(0, 0, 0, backLight + ".rotatePivot") cmds.rotate(180 + lightRotation, 0, 0, backLight) rigNode = cmds.group(empty=True, name="LightRig") cmds.parent(keyLight, rigNode) cmds.parent(fillLight, rigNode) cmds.parent(backLight, rigNode) cmds.select(rigNode, replace=True)
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()
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()
def placeLight(light, xz, daytime): ''' Places a street light and if it is night creates and parents a spotlight to it. light: object that is to be placed. xz: Tuple containing the x- and z-coordinates the object will be placed at. daytime: Boolean variable which is true if it is day and false if it is night. On exit: The object has been placed in the right position and if daytime is false, a spotlight has been positioned and parented to the object. ''' cmds.xform(light, translation = (xz[0], 0, xz[1])) if daytime == False: spotLight = cmds.spotLight(intensity = 0.672, coneAngle = 125, penumbra = 10, dropOff = 4.286) cmds.move(xz[0], 2.6, xz[1]) cmds.rotate(-90, x = True) cmds.parent("spotLight" + spotLight[14:], light)
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
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!")
def create_spot_light(): mc.spotLight()
def playblastTurntableGenerator(): model = cmds.ls(sl=True, l=True) if len(model) < 1: cmds.warning('Nothing is selected. Select at least 1 object/group.') else: scaleFactor = getSceneBBoxScale(model) modelCenter = getSceneBBoxCenter(model) ''' Create lightRig ''' namespaces = cmds.namespaceInfo(':', listOnlyNamespaces=True, r=True) if 'turntableSet' in namespaces: cmds.namespace(setNamespace=':') cmds.namespace(deleteNamespaceContent=True, removeNamespace='turntableSet') turntableSetNamespace = 'turntableSet' cmds.namespace(add=turntableSetNamespace) turntableSetGroupName = turntableSetNamespace + ':' + turntableSetNamespace + '_GRP' cmds.group(em=True, name=turntableSetGroupName) lightGroupName = (turntableSetNamespace + ':lights_GRP') cmds.group(em=True, name=lightGroupName) cmds.parent(lightGroupName, turntableSetGroupName) spotLight01 = 'turntableSpotLight01' cmds.spotLight(n=turntableSetNamespace + ':' + spotLight01, coneAngle=70, intensity=1.065, penumbra=7.5, dropOff=15) cmds.setAttr( turntableSetNamespace + ':' + spotLight01 + '.useDepthMapShadows', 1) cmds.setAttr( turntableSetNamespace + ':' + spotLight01 + '.dmapResolution', 4096) cmds.setAttr( turntableSetNamespace + ':' + spotLight01 + '.dmapFilterSize', 10) cmds.setAttr(turntableSetNamespace + ':' + spotLight01 + '.shadowColor', 0.213, 0.213, 0.213, type='double3') cmds.xform(turntableSetNamespace + ':' + spotLight01, t=(10.68561, 10.28704, 13.95764), ro=(-27.66044, 32.98632, 0), ws=True) cmds.parent(turntableSetNamespace + ':' + spotLight01, lightGroupName) spotLight02 = 'turntableSpotLight02' cmds.spotLight(n=turntableSetNamespace + ':' + spotLight02, coneAngle=45, intensity=0.4, penumbra=7.5, dropOff=5) cmds.setAttr(turntableSetNamespace + ':' + spotLight02 + '.shadowColor', 1, 1, 1, type='double3') cmds.xform(turntableSetNamespace + ':' + spotLight02, t=(-10.43612, 8.78771, -5.27289), ro=(-217.39926, -65.2236, -180), ws=True) cmds.parent(turntableSetNamespace + ':' + spotLight02, lightGroupName) directionalLight01 = 'turntableDirect01' cmds.directionalLight(n=turntableSetNamespace + ':' + directionalLight01, intensity=0.3, rotation=[-47.78754, 0, 0]) cmds.setAttr(turntableSetNamespace + ':' + directionalLight01 + '.shadowColor', 1, 1, 1, type='double3') cmds.parent(turntableSetNamespace + ':' + directionalLight01, lightGroupName) cycloGeoCreation('turntableSet', 'defaultGrey_C_cycloA_GES') cmds.parent(turntableSetNamespace + ':defaultGrey_C_cycloA_GES', turntableSetGroupName) ''' Adjust Rig Scale and Pos ''' cmds.xform(turntableSetGroupName, absolute=True, translation=[ modelCenter[0], cmds.exactWorldBoundingBox(model, ignoreInvisible=True)[1], modelCenter[2] ], ws=True) cmds.scale(scaleFactor, scaleFactor, scaleFactor, turntableSetGroupName, absolute=True) ''' Create and Assign shaders ''' createAndAssignShaders(turntableSetNamespace, model) ''' Create Camera ''' cameraName = turntableSetNamespace + ':' + 'turntableCameraA_CAM' cam = cmds.camera() cmds.rename(cam[0], cameraName) cmds.setAttr(cameraName + '.focalLength', 50) cmds.setAttr(cameraName + '.displayGateMaskColor', 0, 0, 0, type='double3') cmds.setAttr(cameraName + '.displayGateMaskOpacity', 1) cmds.xform(cameraName, absolute=True, translation=[0, modelCenter[1] * 1.5, scaleFactor * 12], ws=True) cameraAimLocatorName = turntableSetNamespace + ':cameraAim_CTRL' cmds.spaceLocator(n=cameraAimLocatorName) cmds.aimConstraint(cameraAimLocatorName, cameraName, n=turntableSetNamespace + ':cameraAimConstraint') cmds.setAttr(turntableSetNamespace + ':cameraAimConstraint.offsetY', -90) cmds.xform(cameraAimLocatorName, absolute=True, translation=modelCenter, ws=True) mel.eval('setNamedPanelLayout("Single Perspective View")') cmds.lookThru(cameraName) cmds.parent(cameraName, turntableSetGroupName) cmds.parent(cameraAimLocatorName, turntableSetGroupName) ''' Create Turntable Locator ''' locName = turntableSetNamespace + ':turntableLocatorA_LOC' cmds.spaceLocator(n=locName) cmds.xform(locName, absolute=True, translation=[modelCenter[0], 0, modelCenter[2]], ws=True) cmds.parent(locName, turntableSetGroupName) cmds.parentConstraint(locName, model, maintainOffset=True, n=turntableSetNamespace + ':parentConstraint_CTR') ''' Turntable Animation ''' setSpinAnim(locName, 1, 101) #setSpinAnim(lightGroupName, 101, 201) #setSpinAnim(lightGroupName, 101, 201) #setSpinAnim(lightGroupName, 101, 201) ''' Time Settings ''' startFrame = 1 endFrame = 100 cmds.playbackOptions(ast=startFrame, e=True) cmds.playbackOptions(aet=endFrame, e=True) cmds.playbackOptions(min=startFrame, e=True) cmds.playbackOptions(max=endFrame, e=True) ''' Viewport Settings ''' panel = getPanelFromCamera(turntableSetNamespace + ':turntableCameraA_CAMShape')[0] cmds.modelEditor(panel, e=True, displayAppearance='smoothShaded') cmds.modelEditor(panel, e=True, dl='all') cmds.modelEditor(panel, e=True, shadows=1) cmds.modelEditor(panel, e=True, allObjects=0) cmds.modelEditor(panel, e=True, polymeshes=1) cmds.modelEditor(panel, e=True, grid=0) cmds.setAttr("hardwareRenderingGlobals.ssaoEnable", 1) cmds.setAttr("hardwareRenderingGlobals.multiSampleEnable", 1) activateSmoothPreview(model) ''' Render Settings ''' cmds.setAttr("defaultResolution.width", 1920) cmds.setAttr("defaultResolution.height", 1080)
## create light set for viewport2 import maya.cmds as mc sel = mc.ls('groupLightA') if not sel: mc.ambientLight(n='ambiantLightA', intensity=0.6) mc.spotLight(n='spotLightA', intensity=0.6, coneAngle=80) mc.setAttr('spotLightA.rotateX', -90) mc.setAttr('spotLightA.translateY', 300) mc.setAttr('spotLightA.scale', 200, 200, 200, type="double3") mc.group('ambiantLightA', 'spotLightA', n='groupLightA') allModelPanel = mc.getPanel(type='modelPanel') if allModelPanel: for modelPanelName in allModelPanel: mc.modelEditor(modelPanelName, e=True, displayLights="all", shadows=True) else: mc.delete(sel) allModelPanel = mc.getPanel(type='modelPanel') if allModelPanel: for modelPanelName in allModelPanel: mc.modelEditor(modelPanelName, e=True, displayLights="default", shadows=False) mc.ls("|root_*", type="transform")[0] ## integration matte import maya.cmds as mc
"""Creates a locator to parent the lights to""" cmds.spaceLocator() cmds.rename('locator1', 'lightLoc') cmds.circle(nr=(0,1,0), c=(0, 0, 0)) cmds.select('nurbsCircleShape1', 'lightLoc', add = True) cmds.parent(r = True, s = True) cmds.select('nurbsCircle1') cmds.delete() """Creates the key light and sets light attributes""" cmds.spotLight(n='keyLight', d=2, i=400, rs=True) cmds.move(-10,5,0) cmds.rotate(0,-90,0) cmds.setAttr('keyLightShape.shadowRays', 16) cmds.parent('keyLight', 'lightLoc') """Creates the fill light and sets light attributes""" cmds.spotLight(n='fillLight', d=2, i=300, rs=True) cmds.move(10,0,0) cmds.rotate(25,90,0) cmds.setAttr('fillLightShape.shadowRays', 16) cmds.parent('fillLight', 'lightLoc')
def create(self): print self.lightRigType print self.timeOfDay #Create locator at origin self.lightRigLoc = mc.spaceLocator( name = "lightRig_loc" ) mc.scale(6,6,6) #If the user selected indoor... if (self.lightRigType == 1 ): print "Indoor Lights" #Create Key light self.lightRigKey = mc.spotLight( name = "lightRig_keyLight", rgb = [1.0,1.0,0.916], dropOff = 0.250, intensity = 1.5, penumbra = 25, coneAngle = 21 ) mc.setAttr( "lightRig_keyLightShape.useDepthMapShadows", 1) mc.setAttr( "lightRig_keyLightShape.dmapResolution", 1024) mc.setAttr( "lightRig_keyLightShape.dmapFilterSize", 8) mc.move( 13,27,21 ) mc.rotate( -41, 31.5, 0 ) #Create fill light self.lightRigFill = mc.spotLight( name = "lightRig_fillLight", rgb = [0.354,0.360,0.624], intensity = 1.25, coneAngle = 30, penumbra = 70, dropOff = 1.25, rs = False) mc.setAttr( "lightRig_fillLightShape.emitSpecular", 0) mc.move( -19, 17, 20 ) mc.rotate( -22.8, -44, 0 ) #Create back light self.lightRigFill = mc.spotLight( name = "lightRig_backLight", rgb = [1.0,1.0,0.657], intensity = 1.8, coneAngle = 30, rs = False) mc.move(-4,14,-25) mc.rotate( -17.4, 189.2, 0 ) #If User selected outdoor and morning elif (self.lightRigType == 2 and self.timeOfDay == 1): print "Outdoor Lights: Morning" #Create Key light self.lightRigKey = mc.spotLight( name = "lightRig_keyLight", rgb = [1.0,0.863,0.408], dropOff = 0.250, intensity = 1.5, penumbra = 25, coneAngle = 21 ) mc.setAttr( "lightRig_keyLightShape.useDepthMapShadows", 1) mc.setAttr( "lightRig_keyLightShape.dmapResolution", 1024) mc.setAttr( "lightRig_keyLightShape.dmapFilterSize", 8) mc.move( 13,27,21 ) mc.rotate( -41, 31.5, 0 ) #Create fill light self.lightRigFill = mc.spotLight( name = "lightRig_fillLight", rgb = [0.354,0.416,0.624], intensity = 1.25, coneAngle = 30, penumbra = 70, dropOff = 1.25, rs = False) mc.setAttr( "lightRig_fillLightShape.emitSpecular", 0) mc.move( -19, 17, 20 ) mc.rotate( -22.8, -44, 0 ) #Create back light self.lightRigFill = mc.spotLight( name = "lightRig_backLight", rgb = [1.0,0.863,0.148], intensity = 1.8, coneAngle = 30, rs = False) mc.move(-4,14,-25) mc.rotate( -17.4, 189.2, 0 ) #If User selected outdoor and noon elif (self.lightRigType == 2 and self.timeOfDay == 2): print "Outdoor Lights: Noon" #Create key light self.lightRigKey = mc.spotLight( name = "lightRig_keyLight", rgb = [0.882,0.963,1.0], dropOff = 0.250, intensity = 1.5, penumbra = 25, coneAngle = 21 ) mc.setAttr( "lightRig_keyLightShape.useDepthMapShadows", 1) mc.setAttr( "lightRig_keyLightShape.dmapResolution", 1024) mc.setAttr( "lightRig_keyLightShape.dmapFilterSize", 8) mc.move( 13,27,21 ) mc.rotate( -41, 31.5, 0 ) #Create fill light self.lightRigFill = mc.spotLight( name = "lightRig_fillLight", rgb = [1.0,0.949,0.882], intensity = 1.25, coneAngle = 30, penumbra = 70, dropOff = 1.25, rs = False) mc.setAttr( "lightRig_fillLightShape.emitSpecular", 0) mc.move( -19, 17, 20 ) mc.rotate( -22.8, -44, 0 ) #Create back light self.lightRigFill = mc.spotLight( name = "lightRig_backLight", rgb = [0.882,0.963,0.740], intensity = 1.8, coneAngle = 30, rs = False) mc.move(-4,14,-25) mc.rotate( -17.4, 189.2, 0 ) #If User selected outdoor and night elif (self.lightRigType == 2 and self.timeOfDay == 3): print "Outdoor Lights: Midnight" #Create key light self.lightRigKey = mc.spotLight( name = "lightRig_keyLight", rgb = [0.118,0.133,0.247], dropOff = 0.250, intensity = 1.5, penumbra = 25, coneAngle = 21 ) mc.setAttr( "lightRig_keyLightShape.useDepthMapShadows", 1) mc.setAttr( "lightRig_keyLightShape.dmapResolution", 1024) mc.setAttr( "lightRig_keyLightShape.dmapFilterSize", 8) mc.move( 13,27,21 ) mc.rotate( -41, 31.5, 0 ) #Create fill light self.lightRigFill = mc.spotLight( name = "lightRig_fillLight", rgb = [0.247,0.241,0.118], intensity = 1.25, coneAngle = 30, penumbra = 70, dropOff = 1.25, rs = False) mc.setAttr( "lightRig_fillLightShape.emitSpecular", 0) mc.move( -19, 17, 20 ) mc.rotate( -22.8, -44, 0 ) #Create back light self.lightRigFill = mc.spotLight( name = "lightRig_backLight", rgb = [0.118,0.133,0.163], intensity = 1.8, coneAngle = 30, rs = False) mc.move(-4,14,-25) mc.rotate( -17.4, 189.2, 0 ) #Constrain the lights to the locator mc.parentConstraint( "lightRig_loc", "lightRig_keyLight", mo = True ) mc.parentConstraint( "lightRig_loc", "lightRig_fillLight", mo = True ) mc.parentConstraint( "lightRig_loc", "lightRig_backLight", mo = True ) #Group lights and locator under a named group mc.group( "lightRig_loc", "lightRig_keyLight", "lightRig_fillLight", "lightRig_backLight", n = "lightRig_grp" )
def _createLights( domeRig, isSpot, numLights, numArcs, radius ): lights = [] # Calculate light angle in arc if numLights < 5: a = 90.0 / (numLights + 1) start = 1 end = numLights + 1 else: a = 90.0 / (numLights - 1) start = 0 end = numLights # Create and position lights in a single arc for t in range(start,end): if numLights < 5: n = t else: n = t + 1 # Create Light domeLightName = (domeRig + '_light' + str(n)) if isSpot: domeLight = cmds.spotLight( name=domeLightName ) else: domeLight = cmds.directionalLight( name=domeLightName ) # Calculate position tx = radius * math.cos(math.radians(a*t)) ty = radius * math.sin(math.radians(a*t)) # Set position cmds.setAttr((domeLightName + '.translateX'), tx) cmds.setAttr((domeLightName + '.translateY'), ty) lights.append(domeLight) a = 360.0 / numArcs # Add lights to group cmds.group( lights, useAsGroup=domeRig ) lightArcs = OrderedDict() for i in range(1,numArcs): # Duplicate Light Arc arcLights = cmds.duplicate( domeRig, renameChildren=True ) # Set rig pivot to origin _centerPivot( arcLights[0] ) # Rotate the group cmds.setAttr((arcLights[0] + '.rotateY'), a*i) # Remove the group from the duplicated arc grp = arcLights.pop(0) # Add lights to light arc dictionary lightArcs.update({grp:arcLights}) for grp in lightArcs: for l in lightArcs[grp]: # Parent all the lights into the original group cmds.parent( l, domeRig ) chld = cmds.listRelatives(l, children=True) lights.append( chld[0] ) # Delete duplicated group cmds.delete(grp) # Set rig pivot to origin _centerPivot( domeRig ) return lights
def process(): eye = cmds.polySphere() light = cmds.spotLight() locator = cmds.spaceLocator() cmds.geometryConstraint( eye, locator )
import maya.cmds as cmds """Creates a locator to parent the lights to""" cmds.spaceLocator() cmds.rename('locator1', 'lightLoc') cmds.circle(nr=(0, 1, 0), c=(0, 0, 0)) cmds.select('nurbsCircleShape1', 'lightLoc', add=True) cmds.parent(r=True, s=True) cmds.select('nurbsCircle1') cmds.delete() """Creates the key light and sets light attributes""" cmds.spotLight(n='keyLight', d=2, i=400, rs=True) cmds.move(-10, 5, 0) cmds.rotate(0, -90, 0) cmds.setAttr('keyLightShape.shadowRays', 16) cmds.parent('keyLight', 'lightLoc') """Creates the fill light and sets light attributes""" cmds.spotLight(n='fillLight', d=2, i=300, rs=True) cmds.move(10, 0, 0) cmds.rotate(25, 90, 0) cmds.setAttr('fillLightShape.shadowRays', 16) cmds.parent('fillLight', 'lightLoc') """Creates the back light and sets light attributes"""
def shadowsBtnCmd(self, *args): """Function turns on ray trace shadows for lights""" for l in self.lights: cmds.spotLight(l, e=1, rs=1);