Light Rigs Script
#light_rigs.py
import maya.cmds as cmds
import maya.mel as mel
import os
import math
import mtoa.utils as mutils
#-----------------------------------------------------------------------------------------------
def studioLights(lightName1, lightName2):
lightNames = []
#Create Key Light
mutils.createLocator("aiAreaLight", asLight=True)
cmds.select("aiAreaLight1")
newName1=cmds.rename("aiAreaLight1", lightName1)
lightNames.append(newName1)
cmds.setAttr(newName1 + ".translateX",1.044)
cmds.setAttr(newName1 + ".translateY",13.273)
cmds.setAttr(newName1 + ".translateZ",9.480)
cmds.setAttr(newName1 + ".rotateX",-37.200)
cmds.setAttr(newName1 + ".rotateY",14.000)
cmds.move(0,0,0, newName1 + '.scalePivot', newName1 + '.rotatePivot', absolute=True)
cmds.setAttr(newName1 + ".aiSamples",5)
cmds.setAttr(newName1 + ".exposure",8.500)
#Create Fill Light
mutils.createLocator("aiAreaLight", asLight=True)
cmds.select("aiAreaLight1")
newName2=cmds.rename("aiAreaLight1", lightName2)
lightNames.append(newName2)
cmds.setAttr(newName2 + ".translateX",8.745)
cmds.setAttr(newName2 + ".translateY",11.930)
cmds.setAttr(newName2 + ".translateZ",-5.368)
cmds.setAttr(newName2 + ".rotateX",-34.800)
cmds.setAttr(newName2 + ".rotateY",113.200)
cmds.move(0,0,0, newName2 + '.scalePivot', newName2 + '.rotatePivot', absolute=True)
cmds.setAttr(newName2 + ".aiSamples",5)
cmds.setAttr(newName2 + ".exposure",4.500)
cmds.setAttr(newName2 + ".aiShadowDensity", 0.463)
#Group Lights
groupName = cmds.group( newName1, newName2, n='Studio_Rig' )
cmds.move(0,0,0, groupName + '.scalePivot', groupName + '.rotatePivot', absolute=True)
return groupName
#-----------------------------------------------------------------------------------------------
def middayLights(lightName1, lightName2):
lightNames = []
#Create Key Light
mutils.createLocator("aiAreaLight", asLight=True)
cmds.select("aiAreaLight1")
newName1=cmds.rename("aiAreaLight1", lightName1)
lightNames.append(newName1)
cmds.setAttr(newName1 + ".translateX",1.044)
cmds.setAttr(newName1 + ".translateY",13.273)
cmds.setAttr(newName1 + ".translateZ",9.480)
cmds.setAttr(newName1 + ".rotateX",-37.200)
cmds.setAttr(newName1 + ".rotateY",14.000)
cmds.move(0,0,0, newName1 + '.scalePivot', newName1 + '.rotatePivot', absolute=True)
cmds.setAttr(newName1 + ".aiSamples",5)
cmds.setAttr(newName1 + ".exposure",9.000)
cmds.setAttr(newName1 + ".aiUseColorTemperature",1)
cmds.setAttr(newName1 + "Shape.aiColorTemperature", 5600)
#Create Fill Light
mutils.createLocator("aiAreaLight", asLight=True)
cmds.select("aiAreaLight1")
newName2=cmds.rename("aiAreaLight1", lightName2)
lightNames.append(newName2)
cmds.setAttr(newName2 + ".translateX",8.745)
cmds.setAttr(newName2 + ".translateY",11.930)
cmds.setAttr(newName2 + ".translateZ",-5.368)
cmds.setAttr(newName2 + ".rotateX",-34.800)
cmds.setAttr(newName2 + ".rotateY",113.200)
cmds.move(0,0,0, newName2 + '.scalePivot', newName2 + '.rotatePivot', absolute=True)
cmds.setAttr(newName2 + ".aiSamples",5)
cmds.setAttr(newName2 + ".exposure",4.500)
cmds.setAttr(newName2 + ".aiShadowDensity", 0.463)
cmds.setAttr(newName2 + ".aiUseColorTemperature",1)
cmds.setAttr(newName2 + "Shape.aiColorTemperature", 9500)
#Group Lights
groupName = cmds.group( newName1, newName2, n='Sunny_Rig' )
cmds.move(0,0,0, groupName + '.scalePivot', groupName + '.rotatePivot', absolute=True)
return groupName
#-----------------------------------------------------------------------------------------------
def cloudyLights(lightName1, lightName2):
lightNames = []
#Create Key Light
mutils.createLocator("aiAreaLight", asLight=True)
cmds.select("aiAreaLight1")
newName1=cmds.rename("aiAreaLight1", lightName1)
lightNames.append(newName1)
cmds.setAttr(newName1 + ".translateX",1.044)
cmds.setAttr(newName1 + ".translateY",13.273)
cmds.setAttr(newName1 + ".translateZ",9.480)
cmds.setAttr(newName1 + ".rotateX",-37.200)
cmds.setAttr(newName1 + ".rotateY",14.000)
cmds.move(0,0,0, newName1 + '.scalePivot', newName1 + '.rotatePivot', absolute=True)
cmds.setAttr(newName1 + ".aiSamples",5)
cmds.setAttr(newName1 + ".exposure",8.500)
cmds.setAttr(newName1 + ".aiShadowDensity", 0.858)
cmds.setAttr(newName1 + ".aiUseColorTemperature",1)
cmds.setAttr(newName1 + "Shape.aiColorTemperature", 7500)
#Create Fill Light
mutils.createLocator("aiAreaLight", asLight=True)
cmds.select("aiAreaLight1")
newName2=cmds.rename("aiAreaLight1", lightName2)
lightNames.append(newName2)
cmds.setAttr(newName2 + ".translateX",8.745)
cmds.setAttr(newName2 + ".translateY",11.930)
cmds.setAttr(newName2 + ".translateZ",-5.368)
cmds.setAttr(newName2 + ".rotateX",-34.800)
cmds.setAttr(newName2 + ".rotateY",113.200)
cmds.move(0,0,0, newName2 + '.scalePivot', newName2 + '.rotatePivot', absolute=True)
cmds.setAttr(newName2 + ".aiSamples",5)
cmds.setAttr(newName2 + ".exposure",6.500)
cmds.setAttr(newName2 + ".aiShadowDensity", 0.246)
#Group Lights
groupName = cmds.group( newName1, newName2, n='Cloudy_Rig' )
cmds.move(0,0,0, groupName + '.scalePivot', groupName + '.rotatePivot', absolute=True)
return groupName
#-----------------------------------------------------------------------------------------------
def sunsetLights(lightName1, lightName2):
lightNames = []
#Create Key Light
mutils.createLocator("aiAreaLight", asLight=True)
cmds.select("aiAreaLight1")
newName1=cmds.rename("aiAreaLight1", lightName1)
lightNames.append(newName1)
cmds.setAttr(newName1 + ".translateX",1.577)
cmds.setAttr(newName1 + ".translateY",9.490)
cmds.setAttr(newName1 + ".translateZ",13.829)
cmds.setAttr(newName1 + ".rotateX",-18.600)
cmds.setAttr(newName1 + ".rotateY",28.000)
cmds.move(0,0,0, newName1 + '.scalePivot', newName1 + '.rotatePivot', absolute=True)
cmds.setAttr(newName1 + ".aiSamples",5)
cmds.setAttr(newName1 + ".exposure",9.000)
cmds.setAttr(newName1 + "Shape.aiSpread", 0.656716)
cmds.setAttr(newName1 + ".aiUseColorTemperature",1)
cmds.setAttr(newName1 + "Shape.aiColorTemperature", 3500)
#Create Fill Light
mutils.createLocator("aiAreaLight", asLight=True)
cmds.select("aiAreaLight1")
newName2=cmds.rename("aiAreaLight1", lightName2)
lightNames.append(newName2)
cmds.setAttr(newName2 + ".translateX",10.529)
cmds.setAttr(newName2 + ".translateY",10.162)
cmds.setAttr(newName2 + ".translateZ",-5.579)
cmds.setAttr(newName2 + ".rotateX",157.800)
cmds.setAttr(newName2 + ".rotateY",80.400)
cmds.setAttr(newName2 + ".rotateZ",-180.000)
cmds.move(0,0,0, newName2 + '.scalePivot', newName2 + '.rotatePivot', absolute=True)
cmds.setAttr(newName2 + ".aiSamples",5)
cmds.setAttr(newName2 + ".exposure",6.000)
cmds.setAttr(newName2 + ".aiShadowDensity", 0.463)
cmds.setAttr(newName2 + ".aiUseColorTemperature",1)
cmds.setAttr(newName2 + "Shape.aiColorTemperature", 7522)
cmds.setAttr(newName2 + "Shape.aiSpecular", 0)
#Group Lights
groupName = cmds.group( newName1, newName2, n='Sunset_Rig' )
cmds.move(0,0,0, groupName + '.scalePivot', groupName + '.rotatePivot', absolute=True)
return groupName
#-----------------------------------------------------------------------------------------------
def Skydome(filePath):
mutils.createLocator("aiSkyDomeLight", asLight=True)
cmds.select("aiSkyDomeLight1")
newName = cmds.rename("aiSkyDomeLight1", "Sky_Dome")
cmds.defaultNavigation(defaultTraversal = True, destination = newName + ".color")
fileName = cmds.shadingNode("file", asTexture=True, isColorManaged=True )
cmds.connectAttr(fileName + ".outColor", newName + ".color")
cmds.setAttr(fileName + '.fileTextureName', filePath, type='string')
cmds.setAttr(newName + ".camera", 0)
cmds.setAttr(newName + "Shape.exposure", -5)
#-----------------------------------------------------------------------------------------------
def DeleteSkydome():
cmds.select("Sky_Dome*")
cmds.delete("Sky_Dome*")
#-----------------------------------------------------------------------------------------------