Advertisement
Guest User

Untitled

a guest
Jan 24th, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. """
  2. import pymel.core as pm
  3. #define radius of the bouncing ball
  4. ballRadius = 2
  5. #create the ball
  6. ball = pm.polySphere(radius = ballRadius)[0]
  7. #rename the ball
  8. pm.rename('pSphere1', 'Ball')
  9. #translate the ball transform up so the bottom of the geometry is at 0, 0, 0 at frame 0
  10. pm.setKeyframe(ball.tx)
  11. ball.translateY.set(ballRadius)
  12. def bouncingBall():
  13. #Set tangents to slow in/slow out the ball
  14. pm.keyTangent(ball.ty, t=[1], outAngle='70')
  15. pm.keyTangent(ball.ty, t=[24], inAngle='-70')
  16. pm.keyTangent(ball.ty, t=[12], itt='spline', ott='spline')
  17.  
  18. #Squishes the ball for the first frame
  19. pm.currentTime(1)
  20. ball.scale.set(1,-.2,1)
  21. ball.translate.set(0,0,0)
  22. ball.translateY.setKey()
  23. ball.scale.setKey()
  24. #Pops the ball up
  25. pm.currentTime(3)
  26. ball.scale.set(1,0.820,1)
  27. ball.translate.set(0,6,0)
  28. ball.translateY.setKey()
  29. ball.scale.setKey()
  30. #Slows in before middle frame
  31. pm.currentTime(9)
  32. ball.scale.set(1,1,1)
  33. ball.translateY.set(19)
  34. ball.translateY.setKey()
  35. ball.scale.setKey()
  36. #Returns ball to its normal shape for frame 12
  37. pm.currentTime(12)
  38. ball.scale.set(1,1,1)
  39. ball.translateY.set(21)
  40. ball.translateY.setKey()
  41. ball.scale.setKey()
  42. #Slow out
  43. pm.currentTime(16)
  44. ball.translateY.set(17)
  45. ball.translateY.setKey()
  46. ball.scale.set(1,1.17,1)
  47. ball.scale.setKey()
  48. #Stretches ball before last frame
  49. pm.currentTime(20)
  50. ball.translateY.set(4)
  51. ball.translateY.setKey()
  52. ball.scale.set(1,1.7,1)
  53. ball.scale.setKey()
  54. #Repeats first frame
  55. pm.currentTime(24)
  56. ball.scale.set(1,.2,1)
  57. ball.translateY.set(0)
  58. ball.translate.setKey()
  59. ball.scale.setKey()
  60.  
  61.  
  62. bouncingBall()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement