From c0fd62dfe86b2f8bb155462ff2017427737f81d5 Mon Sep 17 00:00:00 2001 From: Mark Mine Date: Fri, 30 Mar 2001 02:11:06 +0000 Subject: [PATCH] *** empty log message *** --- direct/src/interval/FunctionInterval.py | 14 ++++++++------ direct/src/interval/Interval.py | 6 +++--- direct/src/interval/IntervalTest.py | 3 ++- direct/src/interval/MultiTrack.py | 12 ++++++++---- direct/src/interval/Track.py | 12 ++++++++---- 5 files changed, 29 insertions(+), 18 deletions(-) diff --git a/direct/src/interval/FunctionInterval.py b/direct/src/interval/FunctionInterval.py index 1f79db081c..76b895f870 100644 --- a/direct/src/interval/FunctionInterval.py +++ b/direct/src/interval/FunctionInterval.py @@ -213,6 +213,7 @@ class PosHprScaleInterval(FunctionInterval): """ SAMPLE CODE +from IntervalGlobal import * ### Using lambdas and functions ### # Using a lambda @@ -224,9 +225,9 @@ def printHello(): i3 = FunctionInterval(printHello) # Create track -t = Track([(0.0, i1), (2.0, i2), (4.0, i3)], name = 'demo') +t1 = Track([(0.0, i1), (2.0, i2), (4.0, i3)], name = 'demo') # Play track -t.play() +t1.play() ### Specifying interval start times during track construction ### # Interval start time can be specified relative to three different points: @@ -257,24 +258,25 @@ def printTrackStart(): i1 = FunctionInterval(printStart) # Just to take time -i2 = LerpPosInterval(camera, 2.0, Point3(0,10,0)) +i2 = LerpPosInterval(camera, 2.0, Point3(0,10,5)) # This will be relative to end of camera move i3 = FunctionInterval(printPreviousEnd) # Just to take time -i4 = LerpPosInterval(camera, 2.0, Point3(0,0,0)) +i4 = LerpPosInterval(camera, 2.0, Point3(0,0,5)) # This will be relative to the start of the camera move i5 = FunctionInterval(printPreviousStart) # This will be relative to track start i6 = FunctionInterval(printTrackStart) # Create the track, if you don't specify offset type in tuple it defaults to # relative to TRACK_START (first entry below) -t = Track([(0.0, i1), # i1 start at t = 0, duration = 0.0 +t2 = Track([(0.0, i1), # i1 start at t = 0, duration = 0.0 (1.0, i2, TRACK_START), # i2 start at t = 1, duration = 2.0 (2.0, i3, PREVIOUS_END), # i3 start at t = 5, duration = 0.0 (1.0, i4, PREVIOUS_END), # i4 start at t = 6, duration = 2.0 (3.0, i5, PREVIOUS_START), # i5 start at t = 9, duration = 0.0 (10.0, i6, TRACK_START)], # i6 start at t = 10, duration = 0.0 name = 'startTimeDemo') -t.play() + +t2.play() """ diff --git a/direct/src/interval/Interval.py b/direct/src/interval/Interval.py index a7304907a4..8ca4b0ac14 100644 --- a/direct/src/interval/Interval.py +++ b/direct/src/interval/Interval.py @@ -80,13 +80,13 @@ class Interval(DirectObject): self.setT(self.playDuration) return Task.done - def printParams(self, indent=0): - """ printParams(indent) + def __repr__(self, indent=0): + """ __repr__(indent) """ space = '' for l in range(indent): space = space + ' ' - print (space + self.name + ' dur: %.2f' % self.duration) + return (space + self.name + ' dur: %.2f\n' % self.duration) def popupControls(self): # I moved this here because Toontown does not ship Tk diff --git a/direct/src/interval/IntervalTest.py b/direct/src/interval/IntervalTest.py index 814054f272..8955095648 100644 --- a/direct/src/interval/IntervalTest.py +++ b/direct/src/interval/IntervalTest.py @@ -49,7 +49,8 @@ waterEventTrack = Track([waterDone]) waterEventTrack.setIntervalStartTime('water-is-done', eventTime) mtrack = MultiTrack([boatTrack, dockTrack, soundTrack, waterEventTrack]) -mtrack.printParams() +# Print out MultiTrack parameters +mtrack def handleWaterDone(): print 'water is done' diff --git a/direct/src/interval/MultiTrack.py b/direct/src/interval/MultiTrack.py index 6c46f1197a..8e0b3ea656 100644 --- a/direct/src/interval/MultiTrack.py +++ b/direct/src/interval/MultiTrack.py @@ -21,6 +21,9 @@ class MultiTrack(Interval): duration = self.__computeDuration() Interval.__init__(self, n, duration) + def __getitem__(self, item): + return self.tlist[item] + def __computeDuration(self): """ __computeDuration() Returns the duration of the longest Track @@ -41,9 +44,10 @@ class MultiTrack(Interval): for track in self.tlist: track.setT(t, entry) - def printParams(self, indent=0): - """ printParams(indent) + def __repr__(self, indent=0): + """ __repr__(indent) """ - Interval.printParams(self, indent) + str = Interval.__repr__(self, indent) for t in self.tlist: - t.printParams(indent+1) + str = str + t.__repr__(indent+1) + return str diff --git a/direct/src/interval/Track.py b/direct/src/interval/Track.py index 3154553aab..48d7b640c1 100644 --- a/direct/src/interval/Track.py +++ b/direct/src/interval/Track.py @@ -27,6 +27,9 @@ class Track(Interval): self.currentInterval = None Interval.__init__(self, n, duration) + def __getitem__(self, item): + return self.ilist[item][0] + def __buildIlist(self, intervalList): self.ilist = [] for i in intervalList: @@ -154,9 +157,10 @@ class Track(Interval): else: ival.setT(tc) - def printParams(self, indent=0): - """ printParams(indent) + def __repr__(self, indent=0): + """ __repr__(indent) """ - Interval.printParams(self, indent) + str = Interval.__repr__(self, indent) for i in self.ilist: - i[0].printParams(indent+1) + str = str + i[0].__repr__(indent+1) + return str