Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. # colorSphere.py
  2. # Script for rainbow colored sphere patterns.
  3. # Developed 10/19/17 by Dylan Gallup
  4.  
  5. import maya.cmds as mc
  6. import math
  7.  
  8. numCircles = 20
  9.  
  10. for i in range (numCircles):
  11. # create spheres in a diagonal line
  12. mc.polySphere( ax = [0, i, i], r = 1, n = 'sphere_' + str(i), sx = 1, sy = 1)
  13. mc.move( i, (i+1)*3, i )
  14.  
  15. # assign color values
  16. r = math.sin( math.radians(i*5) )
  17. g = math.sin( math.radians(i*5 + 90) )
  18. b = math.sin( math.radians(i*5 + 180) )
  19.  
  20. # get the number of vertices
  21. vertCount = mc.polyEvaluate( v = True )
  22.  
  23. # get the start and end times of the animation
  24. startTime = mc.playbackOptions( query = True, minTime = True )
  25. endTime = mc.playbackOptions( query = True, maxTime = True )
  26.  
  27. # walk through vertices and color them
  28. for j in range( vertCount + 1 ):
  29. mc.select( 'sphere_' + str(i) + '.vtx[' + str(j) + ']')
  30. mc.polyColorPerVertex( rgb = (r,g,b), cdo = True )
  31.  
  32. timeOffset = 100
  33.  
  34. # set keyframes for animation
  35. mc.setKeyframe( 'sphere_' + str(i), time = startTime+i*timeOffset, attribute = 'translateX', value = 5*math.sin(math.radians(i*18)) )
  36. mc.setKeyframe( 'sphere_' + str(i), time = startTime+i*timeOffset, attribute = 'translateY', value = 5*math.cos(math.radians(i*18)) )
  37.  
  38. mc.setKeyframe( 'sphere_' + str(i), time = (1000)+i*timeOffset, attribute = 'translateX', value = 15*math.sin(math.radians(i*18)) )
  39. mc.setKeyframe( 'sphere_' + str(i), time = (1000)+i*timeOffset, attribute = 'translateY', value = 15*math.cos(math.radians(i*18)) )
  40.  
  41. mc.setKeyframe( 'sphere_' + str(i), time = 3000, attribute = 'translateX', value = -5*math.sin(math.radians(i*18)) )
  42. 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