MopathInterval inherits from LerpFunctionInterval to take advantage of blendType

This commit is contained in:
David Rose 2003-11-09 06:52:37 +00:00
parent 484fec162c
commit 59d8e8ebcb
1 changed files with 16 additions and 14 deletions

View File

@ -1,36 +1,38 @@
"""MopathInterval module: contains the MopathInterval class"""
import Interval
import LerpInterval
from PandaModules import *
from DirectNotifyGlobal import *
# import Mopath
class MopathInterval(Interval.Interval):
class MopathInterval(LerpInterval.LerpFunctionInterval):
# Name counter
mopathNum = 1
# create MopathInterval DirectNotify category
notify = directNotify.newCategory('MopathInterval')
# 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
if (name == None):
name = 'Mopath-%d' % MopathInterval.mopathNum
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)
Go to time t
"""
self.mopath.goTo(self.node, t)
self.state = CInterval.SStarted
self.currT = t