Browse Source

MopathInterval inherits from LerpFunctionInterval to take advantage of blendType

David Rose 22 years ago
parent
commit
59d8e8ebcb
1 changed files with 16 additions and 14 deletions
  1. 16 14
      direct/src/interval/MopathInterval.py

+ 16 - 14
direct/src/interval/MopathInterval.py

@@ -1,36 +1,38 @@
 """MopathInterval module: contains the MopathInterval class"""
 """MopathInterval module: contains the MopathInterval class"""
 
 
-import Interval
+import LerpInterval
 from PandaModules import *
 from PandaModules import *
 from DirectNotifyGlobal import *
 from DirectNotifyGlobal import *
 
 
 # import Mopath
 # import Mopath
 
 
-class MopathInterval(Interval.Interval):
+class MopathInterval(LerpInterval.LerpFunctionInterval):
     # Name counter
     # Name counter
     mopathNum = 1
     mopathNum = 1
     # create MopathInterval DirectNotify category
     # create MopathInterval DirectNotify category
     notify = directNotify.newCategory('MopathInterval')
     notify = directNotify.newCategory('MopathInterval')
     # Class methods
     # Class methods
-    def __init__(self, mopath, node, name=None):
-        """__init__(mopath, node, name)
-        """
-        self.mopath = mopath 
-        self.node = node
+    def __init__(self, mopath, node, fromT = 0, toT = None,
+                 blendType = 'noBlend', name = None):
+        if toT == None:
+            toT = mopath.getMaxT()
+        
         # Generate unique name if necessary
         # Generate unique name if necessary
         if (name == None):
         if (name == None):
             name = 'Mopath-%d' % MopathInterval.mopathNum
             name = 'Mopath-%d' % MopathInterval.mopathNum
             MopathInterval.mopathNum += 1
             MopathInterval.mopathNum += 1
-        # Compute duration
-        duration = self.mopath.getMaxT()
-        # Initialize superclass
-        Interval.Interval.__init__(self, name, duration)
 
 
-    def privStep(self, t):
+        LerpInterval.LerpFunctionInterval.__init__(
+            self, self.__doMopath, fromData = fromT, toData = toT,
+            duration = abs(toT - fromT), blendType = blendType,
+            name = name)
+        
+        self.mopath = mopath 
+        self.node = node
+
+    def __doMopath(self, t):
         """ updateFunc(t, event)
         """ updateFunc(t, event)
             Go to time t
             Go to time t
         """
         """
         self.mopath.goTo(self.node, t)
         self.mopath.goTo(self.node, t)
-        self.state = CInterval.SStarted
-        self.currT = t