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