Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """___________________
- colorRandomizer
- version_0.2
- cwisbg
- Brandon Gillespie
- 1/25/2012
- ______________________
- """
- from pymel.core import*
- import maya.cmds as mc
- import random as r
- def shading(a): # a = selection
- shadingNode('lambert',asShader=1, n = 'colorShift_{0}'.format(a))
- shadingNode('singleShadingSwitch', au=1, n = 'colorSwitch_{0}'.format(a))
- shadingNode('ramp', at=1, n = 'ramp_{0}'.format(a))
- connectAttr('colorSwitch_{0}.output'.format(a), 'ramp_{0}.vCoord'.format(a), f=1)
- connectAttr('ramp_{0}.outColor'.format(a), 'colorShift_{0}.color'.format(a))
- connectAttr('colorSwitch_{0}.output'.format(a), 'ramp_{0}.vCoord'.format(a))
- def cuber(a): # a = range/ how manny cubes
- shadingNode('singleShadingSwitch', au=1, n = 'colorSwitch_TEST')
- connectAttr('colorSwitch_TEST.output', 'ramp2.vCoord', f=1)
- z = 0
- moveX = 0
- cubeRange = int(a)
- normlizedList = []
- dummy = [polyCube(n = 'Im_a_dummy', h=.5, w=.5, d=.5)[0]]
- for i in range(1,cubeRange):
- normlizedList.append(i)
- refresh(cw=1)
- randoC = r.random()
- cuby = [polyCube(n = 'cube_{0}'.format(i), ch=0)][0]
- addAttr('cube_{0}'.format(i), ln = 'color', at='double', min=0, max=1)
- setAttr('cube_{0}.color'.format(i), randoC)
- setAttr('cube_{0}.color'.format(i),e=1, keyable=1)
- move(cuby[0], 0,0,moveX, ws=1)
- parent(cuby[0], dummy[z])
- dummy.append(cuby[0])
- hyperShade('cube_{0}'.format(i), a='color')
- moveX += 2
- z += 1
- return dummy, normlizedList
- def connecter(a):
- z = 1
- connectFlip = a
- zz = connectFlip
- #while connectFlip > 0:
- for i in range(1,a):
- #print connectFlip, connectFlip,z
- connectAttr(dummy[z]+".color","colorSwitch_TEST.input[{0}].inSingle".format(connectFlip-2),f=1)
- connectFlip -= 1
- z +=1
- def normList(L, normalizeTo=1):
- '''normalize values of a list to make its max = normalizeTo'''
- vMax = max(L)
- return [ x/(vMax*1.0)*normalizeTo for x in L]
- def selector(a):
- x = 0
- slRange = int(a)
- for i in range (1,slRange):
- sl = select(dummy[x],add=1)
- print x
- x -= 1
- def norSl(a,b):# a = dummy list, b = nor numbers
- x = 0
- z = 0
- for cube in a:
- if x == 0:
- x += 1
- pass
- else:
- setAttr(cube+'.color', b[z])
- z += 1
- sl = selected()
- #range = int(11)
- #shading(sl[0])
- #dummy,normlizedList = cuber(100)
- #selector(100)
- connecter(100)
- #xx= normList(normlizedList, normalizeTo=1)
- #norSl(dummy, xx)
Advertisement
Add Comment
Please, Sign In to add comment