From dddf4f40e68f6969cab19628b814396cb751dbc8 Mon Sep 17 00:00:00 2001 From: Mark Mine Date: Fri, 13 Apr 2001 20:47:47 +0000 Subject: [PATCH] *** empty log message *** --- direct/src/interval/FunctionInterval.py | 6 ++++-- direct/src/interval/IntervalTest.py | 19 +++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/direct/src/interval/FunctionInterval.py b/direct/src/interval/FunctionInterval.py index 4cc137efc1..a4934e2444 100644 --- a/direct/src/interval/FunctionInterval.py +++ b/direct/src/interval/FunctionInterval.py @@ -8,7 +8,7 @@ class FunctionInterval(Interval): # Name counter functionIntervalNum = 1 # Class methods - def __init__(self, function, name = None, openEnded = 1): + def __init__(self, function, name = None, openEnded = 1, extraArgs = []): """__init__(function, name = None) """ # Record instance variables @@ -17,6 +17,8 @@ class FunctionInterval(Interval): if (name == None): name = 'FunctionInterval-%d' % FunctionInterval.functionIntervalNum FunctionInterval.functionIntervalNum += 1 + # Record any arguments + self.extraArgs = extraArgs # Initialize superclass # Set openEnded true if IVAL_INIT calls after end time cause interval # function to be called. If false, IVAL_INIT calls have no effect @@ -30,7 +32,7 @@ class FunctionInterval(Interval): """ if event != IVAL_STOP: # Evaluate the function - self.function() + apply(self.function, self.extraArgs) ### FunctionInterval subclass for throwing events ### class EventInterval(FunctionInterval): diff --git a/direct/src/interval/IntervalTest.py b/direct/src/interval/IntervalTest.py index 2e1164f509..2ea85957b4 100644 --- a/direct/src/interval/IntervalTest.py +++ b/direct/src/interval/IntervalTest.py @@ -143,6 +143,9 @@ def printTrackStart(): currTime = globalClock.getFrameTime() print 'TRACK_START %0.2f' % (currTime - startTime) +def printArguments(a,b,c): + print 'My args were %d, %d, %d' % (a,b,c) + i1 = FunctionInterval(printStart) # Just to take time i2 = LerpPosInterval(camera, 2.0, Point3(0,10,5)) @@ -154,15 +157,19 @@ i4 = LerpPosInterval(camera, 2.0, Point3(0,0,5)) i5 = FunctionInterval(printPreviousStart) # This will be relative to track start i6 = FunctionInterval(printTrackStart) +# This will print some arguments +# This will be relative to track start +i7 = FunctionInterval(printArguments, extraArgs = [1,10,100]) # Create the track, if you don't specify offset type in tuple it defaults to # relative to TRACK_START (first entry below) 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') + (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 + (12.0, i7)], # i7 start at t = 12, duration = 0.0 + name = 'startTimeDemo') print(t2)