Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # colorSphere.py
- # Script for rainbow colored sphere patterns.
- # Developed 10/19/17 by Dylan Gallup
- import maya.cmds as mc
- import math
- numCircles = 20
- for i in range (numCircles):
- # create spheres in a diagonal line
- mc.polySphere( ax = [0, i, i], r = 1, n = 'sphere_' + str(i), sx = 1, sy = 1)
- mc.move( i, (i+1)*3, i )
- # assign color values
- r = math.sin( math.radians(i*5) )
- g = math.sin( math.radians(i*5 + 90) )
- b = math.sin( math.radians(i*5 + 180) )
- # get the number of vertices
- vertCount = mc.polyEvaluate( v = True )
- # get the start and end times of the animation
- startTime = mc.playbackOptions( query = True, minTime = True )
- endTime = mc.playbackOptions( query = True, maxTime = True )
- # walk through vertices and color them
- for j in range( vertCount + 1 ):
- mc.select( 'sphere_' + str(i) + '.vtx[' + str(j) + ']')
- mc.polyColorPerVertex( rgb = (r,g,b), cdo = True )
- timeOffset = 100
- # set keyframes for animation
- mc.setKeyframe( 'sphere_' + str(i), time = startTime+i*timeOffset, attribute = 'translateX', value = 5*math.sin(math.radians(i*18)) )
- mc.setKeyframe( 'sphere_' + str(i), time = startTime+i*timeOffset, attribute = 'translateY', value = 5*math.cos(math.radians(i*18)) )
- mc.setKeyframe( 'sphere_' + str(i), time = (1000)+i*timeOffset, attribute = 'translateX', value = 15*math.sin(math.radians(i*18)) )
- mc.setKeyframe( 'sphere_' + str(i), time = (1000)+i*timeOffset, attribute = 'translateY', value = 15*math.cos(math.radians(i*18)) )
- mc.setKeyframe( 'sphere_' + str(i), time = 3000, attribute = 'translateX', value = -5*math.sin(math.radians(i*18)) )
- mc.setKeyframe( 'sphere_' + str(i), time = 3000, attribute = 'translateY', value = -5*math.cos(math.radians(i*18)) )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement