Esempio n. 1
0
def tripleShaderRandom(args):
	aw_shaderAss.doChecks(args)
	trip=str(createNode("tripleShadingSwitch",
		n="tripleColorizer2"))
	blinn=str(shadingNode(asShader='blinn',n="char_SH"))
	connectAttr((trip + ".output"),(blinn + ".color"))
	select(r=args)
	hyperShade(assign=blinn)
	#Update the triple shading switch with all the new connections
	mel.AEswitchAddButtonCB(trip, 'input', 'inShape', 'inTriple')
	mel.refreshAE()
	listConnections((trip + ".output"),
		source=True,destination=False)
	listConnections((trip + ".input"),
		source=True,destination=False)
	i=1
	for arg in args:
		ramp=str(shadingNode(asTexture='ramp',n=("colorSwatch_" + str(mel.pad(i, 3)) + "_RAMP")))
		removeMultiInstance((ramp + ".colorEntryList[1]"),
			b=True)
		removeMultiInstance((ramp + ".colorEntryList[0]"),
			b=True)
		randR=float(mel.rand(0, 1))
		randG=float(mel.rand(0, 1))
		randB=float(mel.rand(0, 1))
		setAttr((ramp + ".colorEntryList[2].color"),
			randR,randG,randB,
			type='double3')
		#Connect the ramp swatch to the input
		connectAttr((trip + ".input[" + str((i - 1)) + "].inTriple"),
			force=(ramp + ".outColor"))
		#update connections in the triple shading switch
		listConnections((trip + ".input[" + str((i - 1)) + "]"),
			source=True,destination=False)
		listConnections((trip + ".input[" + str((i - 1)) + "].inShape"),
			source=True,destination=False)
		i+=1
Esempio n. 2
0
def uniqueShaderColor(debug):
	args=ls()
	aw_shaderAss.doChecks(args)
	buffer=[]
	shaders=[]
	shadersConsolidate=[]
	shaders=mel.getShaders(args, "lambert")
	shadersConsolidate=mel.uniqueArray(shaders, [])
	print "Shaders are:\n"
	print shadersConsolidate
	print "\n"
	i=0
	for shader in shadersConsolidate:
		select()
		hyperShade(objects=shader)
		assigned=ls()
		assignments=""
		j=0
		for assign in assigned:
			if len(assigned) == j + 1:
				assignments=assignments + str(assign)
				
			
			else:
				assignments=assignments + str(assign) + "."
				
			j+=1
			
		buffer[i]=assignments
		i+=1
		
	if debug:
		print "Assignments Lists: \n"
		
	if debug:
		print buffer
		
	if debug:
		print "\n"
		#Shaders consolidate are the shaders to assign and buffer holds the objects to assign to
		
	k=0
	trip=str(createNode("tripleShadingSwitch",
		n="tripleColorizer"))
	blinn=str(shadingNode(asShader='blinn',n="char_SH"))
	connectAttr((trip + ".output"),(blinn + ".color"))
	select(r=args)
	hyperShade(assign=blinn)
	#Update the triple shading switch with all the new connections
	mel.AEswitchAddButtonCB(trip, 'input', 'inShape', 'inTriple')
	mel.refreshAE()
	listConnections((trip + ".output"),
		source=True,destination=False)
	listConnections((trip + ".input"),
		source=True,destination=False)
	placement=1
	for shader in shadersConsolidate:
		if debug:
			print "Shader Assignment is : " + str(shader) + "\n"
			
		if debug:
			print "Placement index is : " + str(placement) + "\n"
			
		print mel.parser(buffer[k])
		print "\n"
		mel.tripleShader(shader, buffer[k], blinn, trip, placement, 1)
		placement+=len(mel.parser(buffer[k]))
		k+=1