2 Demonstrates simple animation.
7 print "Hello World Animation"
12 class PlaybackSpeed(object):
13 '''Enumerates the allowed values that can be passed to the
14 method Interface::SetPlaybackSpeed(int).'''
28 def PrintInterval(interval):
29 '''This function prints an Interval instance nicely with identifiable values. i.e. 'Interval [0,100]'
30 It prints the values in terms of frames, instead of ticks.
31 Each frame contains 160 ticks. In the SDK, when Intervals are passed around, they
32 are not passed as the number of frames, but instead the frames multiplied by ticks (i.e. 160)'''
33 start = interval.Start() / 160
34 end = interval.End() / 160
35 print "Current Animation Range: [%d,%d]" % (start, end)
38 def SetAnimationRanges():
39 '''Changes the animation range from the default of 100 frames to 200 frames'''
41 PrintInterval(anim.GetAnimRange())
45 anim.SetRange(newRange)
47 PrintInterval(anim.GetAnimRange())
50 def AnimateTransform(sphere):
51 '''Moves the sphere around to demonstrate animation'''
56 anim.SetAnimateButtonState(
True)
60 anim.SetTime(30 * ticks, doRedraw)
64 anim.SetTime(60 * ticks, doRedraw)
67 anim.SetTime(90 * ticks, doRedraw)
70 anim.SetTime(120 * ticks, doRedraw)
73 anim.SetTime(150 * ticks, doRedraw)
76 anim.SetTime(180 * ticks, doRedraw)
80 anim.SetAnimateButtonState(
False)
83 def PlaybackAnimation(sphere):
84 '''There are two StartPlayback methods. One takes a boolean value,
85 and the other takes an integer.
86 The function that takes a boolean value immediately returns.
87 Thus execution is delayed until after the python script is completed.
88 The function that takes an integer (1 for TRUE) does not return
89 until all playback is completed.
90 Attempting to call anim.StartPlayback with the boolean overload
91 will produce confusing results and is best avoided.'''
96 print "Playing back Animation first time"
97 anim.SetPlaybackLoop(
False)
100 anim.StartPlayback(OldStyle)
102 print "Playing back Animation second time"
104 anim.SetTime(0 * ticks, doRedraw)
106 anim.StartPlayback(OldStyle)
109 print "Playing back Animation third time"
110 anim.SetTime(0 * ticks, doRedraw)
111 anim.SetPlaybackSpeed(PlaybackSpeed.X4)
112 anim.StartPlayback(OldStyle)
117 sphere = CreateSphere()
119 AnimateTransform(sphere)
120 PlaybackAnimation(sphere)