mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
define IndirectInterval
This commit is contained in:
parent
9df92afa20
commit
6ffeaf8170
48
direct/src/interval/IndirectInterval.py
Normal file
48
direct/src/interval/IndirectInterval.py
Normal file
@ -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)
|
||||
|
@ -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 *
|
||||
|
Loading…
x
Reference in New Issue
Block a user