1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import pymel.core as pm; from math import * pm.newFile( force=True ); fps = 30; animationLengthInSeconds = 10; totalFrames = fps * animationLengthInSeconds; numberOfBounces = 3.0; startingAmplitude = 5.0; PI = 3.14159; groundY = 1.0; obj = pm.polySphere(name="MySphere"); pm.autoKeyframe( state = True ); for currentFrame in range(1, totalFrames+1): pm.currentTime(currentFrame, edit=True ); pm.setKeyframe(); t = float(currentFrame) / totalFrames; currentAmplitude = (1.0-t)*startingAmplitude; y = groundY + abs( sin( (t * PI) * numberOfBounces ) * currentAmplitude ); pm.move( 0,y,0, obj ); |
Video: