diff --git a/direct/src/interval/IndirectInterval.py b/direct/src/interval/IndirectInterval.py new file mode 100644 index 0000000000..e1321263fa --- /dev/null +++ b/direct/src/interval/IndirectInterval.py @@ -0,0 +1,48 @@ +"""IndirectInterval module: contains the IndirectInterval class""" + +from PandaModules import * +from DirectNotifyGlobal import * +import LerpInterval + +class IndirectInterval(LerpInterval.LerpFunctionInterval): + """ + This class can be used to play samples of another interval, so + that only a subset of the interval is played, or the time is + compressed, or some such nonsense. + + It keeps a reference to the interval itself and repeatedly calls + setT() on it, rather than actually starting the interval or + copying its members like Sequence() or Parallel(). This means two + IndirectIntervals that operate on the same nested interval may + have some interaction that you should be aware of. + """ + + # Interval counter + indirectIntervalNum = 1 + + notify = directNotify.newCategory('IndirectInterval') + + # Class methods + def __init__(self, interval, + startT = 0, endT = None, playRate = 1, + duration = None, blendType = 'noBlend', name = None): + self.interval = interval + + if endT == None: + endT = interval.getDuration() + + if duration == None: + duration = abs(endT - startT) / playRate + + if (name == None): + name = ('IndirectInterval-%d' % + IndirectInterval.indirectIntervalNum) + IndirectInterval.indirectIntervalNum += 1 + + LerpInterval.LerpFunctionInterval.__init__( + self, self.__step, fromData = startT, toData = endT, + duration = duration, blendType = blendType, name = name) + + def __step(self, t): + self.interval.setT(t) + diff --git a/direct/src/interval/IntervalGlobal.py b/direct/src/interval/IntervalGlobal.py index 7bc0c0bf83..0497a314ed 100644 --- a/direct/src/interval/IntervalGlobal.py +++ b/direct/src/interval/IntervalGlobal.py @@ -5,6 +5,7 @@ from Interval import * from ActorInterval import * from FunctionInterval import * from LerpInterval import * +from IndirectInterval import * from MopathInterval import * from ParticleInterval import * from SoundInterval import *