예제 #1
0
파일: shader.py 프로젝트: esernaalonso/dev
def applyUseBackgroundShader(objectsList):
	# open node editor to avoid a bug that makes new nodes not update the image sequence
	nodeEditor.nodeEditorRun()

	# create the nodes
	useBackgroundShader = "projectionManagerUseBackground"
	exists = len(cmds.ls(useBackgroundShader)) > 0
	if not exists:
		useBackgroundShader = cmds.shadingNode("useBackground", asShader=True, name="projectionManagerUseBackground")
	
	# apply the shader
	cmds.select(objectsList)
	cmds.hyperShade(a=useBackgroundShader)

	# close the node editor
	nodeEditor.nodeEditorClose()
예제 #2
0
파일: shader.py 프로젝트: esernaalonso/dev
def applyLambertBackgroundShader(objectsList, imagePlane):
	# open node editor to avoid a bug that makes new nodes not update the image sequence
	nodeEditor.nodeEditorRun()

	lambertShader = "projectionManagerBackgroundLambert_" + (imagePlane.replace("->", "_"))

	# create the nodes
	exists = len(cmds.ls(lambertShader)) > 0
	if not exists:
		lambertShader = cmds.shadingNode("lambert", asShader=True, name=lambertShader)
		projectionNode = cmds.shadingNode("projection", asUtility=True, name="projectionManagerProjection")
		fileNode = cmds.shadingNode("file", asTexture=True, isColorManaged=True, name="projectionManagerFile")
		# timeToUnit = cmds.shadingNode("timeToUnitConversion", asUtility=True, name="projectionManagerUnitConversion")
		
		# connect the nodes and config attributes
		cmds.connectAttr((projectionNode + ".outColor"), (lambertShader + ".color"))

		# cmds.setAttr((projectionNode + ".projType"), 0)
		cmds.setAttr((projectionNode + ".projType"), 8)

		cameraName = imagePlane.split("->")[0]
		cmds.connectAttr((cameraName + ".message"), (projectionNode + ".linkedCamera"))	  
		cmds.connectAttr((fileNode + ".outColor"), (projectionNode + ".image"))

		platePath = getImagePlaneFilePath(imagePlane)
		cmds.setAttr((fileNode + ".fileTextureName"), platePath, type="string")
		# cmds.setAttr((fileNode + ".useFrameExtension"), 0)
		cmds.setAttr((fileNode + ".useFrameExtension"), 1)
		
		# cmds.connectAttr(("time1.outTime"), (timeToUnit + ".input"))
		# cmds.setAttr((timeToUnit + ".conversionFactor"), 0.004)
		# cmds.connectAttr((timeToUnit + ".output"), (fileNode + ".frameExtension"))

		cmds.expression(string=(fileNode + ".frameExtension=frame"), name="projectionExpression")

	# apply the shader
	cmds.select(objectsList)
	cmds.hyperShade(a=lambertShader)

	# close the node editor
	nodeEditor.nodeEditorClose()