Răsfoiți Sursa

define IndirectInterval

David Rose 22 ani în urmă
părinte
comite
6ffeaf8170

+ 48 - 0
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)
+        

+ 1 - 0
direct/src/interval/IntervalGlobal.py

@@ -5,6 +5,7 @@ from Interval import *
 from ActorInterval import *
 from ActorInterval import *
 from FunctionInterval import *
 from FunctionInterval import *
 from LerpInterval import *
 from LerpInterval import *
+from IndirectInterval import *
 from MopathInterval import *
 from MopathInterval import *
 from ParticleInterval import *
 from ParticleInterval import *
 from SoundInterval import *
 from SoundInterval import *