*** empty log message ***

This commit is contained in:
Mark Mine 2001-04-13 20:47:47 +00:00
parent 11cbc3ebf8
commit dddf4f40e6
2 changed files with 17 additions and 8 deletions

View File

@ -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):

View File

@ -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)