mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 19:08:55 -04:00
*** empty log message ***
This commit is contained in:
parent
caf5e1eb06
commit
6c22ca83d0
@ -2,10 +2,6 @@
|
|||||||
|
|
||||||
from DirectObject import *
|
from DirectObject import *
|
||||||
|
|
||||||
PREVIOUS_END = 1
|
|
||||||
PREVIOUS_START = 2
|
|
||||||
TRACK_START = 3
|
|
||||||
|
|
||||||
class Interval(DirectObject):
|
class Interval(DirectObject):
|
||||||
"""Interval class: Base class for timeline functionality"""
|
"""Interval class: Base class for timeline functionality"""
|
||||||
|
|
||||||
@ -13,20 +9,13 @@ class Interval(DirectObject):
|
|||||||
notify = directNotify.newCategory("Interval")
|
notify = directNotify.newCategory("Interval")
|
||||||
#notify.setDebug(1)
|
#notify.setDebug(1)
|
||||||
|
|
||||||
PrevEndRelative = 1
|
|
||||||
PrevStartRelative = 2
|
|
||||||
TrackStartRelative = 3
|
|
||||||
|
|
||||||
# special methods
|
# special methods
|
||||||
|
|
||||||
def __init__(self, name, duration, t0=0.0, type=PREVIOUS_END):
|
def __init__(self, name, duration):
|
||||||
"""__init__(name, duration, t0, type)
|
"""__init__(name, duration)
|
||||||
"""
|
"""
|
||||||
self.name = name
|
self.name = name
|
||||||
self.duration = duration
|
self.duration = duration
|
||||||
assert(t >= 0.0)
|
|
||||||
self.startTime = t0
|
|
||||||
self.type = type
|
|
||||||
|
|
||||||
def getName(self):
|
def getName(self):
|
||||||
""" getName()
|
""" getName()
|
||||||
@ -38,24 +27,7 @@ class Interval(DirectObject):
|
|||||||
"""
|
"""
|
||||||
return self.duration
|
return self.duration
|
||||||
|
|
||||||
def getStartTime(self):
|
def setT(self, t, entry=0):
|
||||||
""" getStartTime()
|
|
||||||
"""
|
|
||||||
return self.startTime
|
|
||||||
|
|
||||||
def setStartTime(self, t, rel=PREVIOUS_END):
|
|
||||||
""" setStartTime()
|
|
||||||
"""
|
|
||||||
assert(t >= 0.0)
|
|
||||||
self.startTime = t
|
|
||||||
self.type = rel
|
|
||||||
|
|
||||||
def getType(self):
|
|
||||||
""" getType()
|
|
||||||
"""
|
|
||||||
return self.type
|
|
||||||
|
|
||||||
def setT(self, t):
|
|
||||||
""" setT(t)
|
""" setT(t)
|
||||||
Go to time t
|
Go to time t
|
||||||
"""
|
"""
|
||||||
@ -67,12 +39,4 @@ class Interval(DirectObject):
|
|||||||
space = ''
|
space = ''
|
||||||
for l in range(indent):
|
for l in range(indent):
|
||||||
space = space + ' '
|
space = space + ' '
|
||||||
t = 'UNKNOWN'
|
print (space + self.name + ' dur: %.2f' % self.duration)
|
||||||
if (self.type == PREVIOUS_END):
|
|
||||||
t = 'PREVIOUS_END'
|
|
||||||
elif (self.type == PREVIOUS_START):
|
|
||||||
t = 'PREVIOUS_START'
|
|
||||||
elif (self.type == TRACK_START):
|
|
||||||
t = 'TRACK_START'
|
|
||||||
print (space + self.name + ' t0: %.2f dur: %.2f %s' % (
|
|
||||||
self.startTime, self.duration, t))
|
|
||||||
|
@ -29,17 +29,17 @@ dockLerp = LerpPosHprInterval('lerp', dock, pos, hpr, 5.0)
|
|||||||
# We need the dock's state to be defined before the lerp
|
# We need the dock's state to be defined before the lerp
|
||||||
dockPos = PosHprInterval('dockpos', dock, dock.getPos(), dock.getHpr(), 1.0)
|
dockPos = PosHprInterval('dockpos', dock, dock.getPos(), dock.getHpr(), 1.0)
|
||||||
dockUpTime = BOAT_END - dockLerp.getDuration()
|
dockUpTime = BOAT_END - dockLerp.getDuration()
|
||||||
dockLerp.setStartTime(dockUpTime, TRACK_START)
|
|
||||||
hpr2 = Vec3(90.0, 90.0, 90.0)
|
hpr2 = Vec3(90.0, 90.0, 90.0)
|
||||||
dockLerp2 = LerpHprInterval('hpr-lerp', dock, hpr2, 3.0)
|
dockLerp2 = LerpHprInterval('hpr-lerp', dock, hpr2, 3.0)
|
||||||
dockLerp2.setStartTime(BOAT_START, TRACK_START)
|
|
||||||
dockTrack = Track.Track([dockLerp2, dockPos, dockLerp], 'docktrack')
|
dockTrack = Track.Track([dockLerp2, dockPos, dockLerp], 'docktrack')
|
||||||
|
dockTrack.setIntervalStartTime('lerp', dockUpTime)
|
||||||
|
dockTrack.setIntervalStartTime('hpr-lerp', BOAT_START)
|
||||||
|
|
||||||
# Start the water sound 5 seconds after the boat starts moving
|
# Start the water sound 5 seconds after the boat starts moving
|
||||||
waterStartTime = BOAT_START + 5.0
|
waterStartTime = BOAT_START + 5.0
|
||||||
waterSound = SoundInterval('watersound', sound, loop=1)
|
waterSound = SoundInterval('watersound', sound)
|
||||||
waterSound.setStartTime(waterStartTime, TRACK_START)
|
|
||||||
soundTrack = Track.Track([waterSound], 'soundtrack')
|
soundTrack = Track.Track([waterSound], 'soundtrack')
|
||||||
|
soundTrack.setIntervalStartTime('watersound', waterStartTime)
|
||||||
|
|
||||||
mtrack = MultiTrack.MultiTrack([boatTrack, dockTrack, soundTrack])
|
mtrack = MultiTrack.MultiTrack([boatTrack, dockTrack, soundTrack])
|
||||||
mtrack.printParams()
|
mtrack.printParams()
|
||||||
|
@ -7,21 +7,18 @@ class LerpInterval(Interval.Interval):
|
|||||||
|
|
||||||
# special methods
|
# special methods
|
||||||
|
|
||||||
def __init__(self, name, duration, functor, t0=0.0,
|
def __init__(self, name, duration, functor, blendType='noBlend'):
|
||||||
type=Interval.PREVIOUS_END, blendType='noBlend'):
|
"""__init__(name, duration, functor, blendType)
|
||||||
"""__init__(name, duration, functor, t0, type, blendType)
|
|
||||||
"""
|
"""
|
||||||
self.name = name
|
self.name = name
|
||||||
self.duration = duration
|
self.duration = duration
|
||||||
self.startTime = t0
|
|
||||||
self.type = type
|
|
||||||
self.lerp = Lerp.Lerp(functor, duration, self.__getBlend(blendType))
|
self.lerp = Lerp.Lerp(functor, duration, self.__getBlend(blendType))
|
||||||
|
|
||||||
def setT(self, t):
|
def setT(self, t, entry=0):
|
||||||
""" setT(t)
|
""" setT(t)
|
||||||
"""
|
"""
|
||||||
assert(t >= 0.0)
|
assert(t >= 0.0)
|
||||||
if (t > self.duration):
|
if (entry == 1) and (t > self.duration):
|
||||||
self.lerp.setT(self.duration)
|
self.lerp.setT(self.duration)
|
||||||
else:
|
else:
|
||||||
self.lerp.setT(t)
|
self.lerp.setT(t)
|
||||||
@ -46,72 +43,78 @@ class LerpInterval(Interval.Interval):
|
|||||||
|
|
||||||
class LerpPosHprInterval(LerpInterval):
|
class LerpPosHprInterval(LerpInterval):
|
||||||
|
|
||||||
def __init__(self, name, node, pos, hpr, duration, t0=0.0,
|
def __init__(self, name, node, pos, hpr, duration, startPos=None,
|
||||||
type=Interval.PREVIOUS_END, other=None, blendType='noBlend'):
|
startHpr=None, other=None, blendType='noBlend'):
|
||||||
""" __init__(name, node, pos, hpr, duration, t0, type, other,
|
""" __init__(name, node, pos, hpr, duration, other, blendType)
|
||||||
blendType)
|
|
||||||
"""
|
"""
|
||||||
import PosHprLerpFunctor
|
import PosHprLerpFunctor
|
||||||
|
|
||||||
assert(not node.isEmpty())
|
assert(not node.isEmpty())
|
||||||
if (other != None):
|
if (other != None):
|
||||||
# lerp wrt other
|
# lerp wrt other
|
||||||
|
if (startPos == None):
|
||||||
startPos = node.getPos(other)
|
startPos = node.getPos(other)
|
||||||
|
if (startHpr == None):
|
||||||
startHpr = node.getHpr(other)
|
startHpr = node.getHpr(other)
|
||||||
functor = PosHprLerpFunctor.PosHprLerpFunctor(
|
functor = PosHprLerpFunctor.PosHprLerpFunctor(
|
||||||
node, startPos, pos,
|
node, startPos, pos,
|
||||||
startHpr, hpr, other)
|
startHpr, hpr, other)
|
||||||
else:
|
else:
|
||||||
|
if (startPos == None):
|
||||||
startPos = node.getPos()
|
startPos = node.getPos()
|
||||||
|
if (startHpr == None):
|
||||||
startHpr = node.getHpr()
|
startHpr = node.getHpr()
|
||||||
functor = PosHprLerpFunctor.PosHprLerpFunctor(
|
functor = PosHprLerpFunctor.PosHprLerpFunctor(
|
||||||
node, startPos, pos,
|
node, startPos, pos,
|
||||||
startHpr, hpr)
|
startHpr, hpr)
|
||||||
|
|
||||||
LerpInterval.__init__(self, name, duration, functor, t0,
|
LerpInterval.__init__(self, name, duration, functor, blendType)
|
||||||
type, blendType)
|
|
||||||
|
|
||||||
|
|
||||||
class LerpPosInterval(LerpInterval):
|
class LerpPosInterval(LerpInterval):
|
||||||
|
|
||||||
def __init__(self, name, node, pos, duration, t0=0.0,
|
def __init__(self, name, node, pos, duration, startPos=None,
|
||||||
type=Interval.PREVIOUS_END, other=None, blendType='noBlend'):
|
other=None, blendType='noBlend'):
|
||||||
""" __init__(name, node, pos, duration, t0, type, other, blendType)
|
""" __init__(name, node, pos, duration, other, blendType)
|
||||||
"""
|
"""
|
||||||
import PosLerpFunctor
|
import PosLerpFunctor
|
||||||
|
|
||||||
assert(not node.isEmpty())
|
assert(not node.isEmpty())
|
||||||
if (other != None):
|
if (other != None):
|
||||||
# lerp wrt other
|
# lerp wrt other
|
||||||
|
if (startPos == None):
|
||||||
startPos = node.getPos(other)
|
startPos = node.getPos(other)
|
||||||
functor = PosLerpFunctor.PosLerpFunctor(
|
functor = PosLerpFunctor.PosLerpFunctor(
|
||||||
node, startPos, pos, other)
|
node, startPos, pos, other)
|
||||||
else:
|
else:
|
||||||
|
if (startPos == None):
|
||||||
startPos = node.getPos()
|
startPos = node.getPos()
|
||||||
functor = PosLerpFunctor.PosLerpFunctor(
|
functor = PosLerpFunctor.PosLerpFunctor(
|
||||||
node, startPos, pos)
|
node, startPos, pos)
|
||||||
|
|
||||||
LerpInterval.__init__(self, name, duration, functor, t0,
|
LerpInterval.__init__(self, name, duration, functor, blendType)
|
||||||
type, blendType)
|
|
||||||
|
|
||||||
class LerpHprInterval(LerpInterval):
|
class LerpHprInterval(LerpInterval):
|
||||||
|
|
||||||
def __init__(self, name, node, hpr, duration, t0=0.0,
|
def __init__(self, name, node, hpr, duration, startHpr=None,
|
||||||
type=Interval.PREVIOUS_END, other=None, blendType='noBlend'):
|
other=None, blendType='noBlend'):
|
||||||
""" __init__(name, node, hpr, duration, t0, type, other, blendType)
|
""" __init__(name, node, hpr, duration, other, blendType)
|
||||||
"""
|
"""
|
||||||
import HprLerpFunctor
|
import HprLerpFunctor
|
||||||
|
|
||||||
assert(not node.isEmpty())
|
assert(not node.isEmpty())
|
||||||
if (other != None):
|
if (other != None):
|
||||||
# lerp wrt other
|
# lerp wrt other
|
||||||
|
if (startHpr == None):
|
||||||
startHpr = node.getHpr(other)
|
startHpr = node.getHpr(other)
|
||||||
functor = HprLerpFunctor.HprLerpFunctor(
|
functor = HprLerpFunctor.HprLerpFunctor(
|
||||||
node, startHpr, hpr, other)
|
node, startHpr, hpr, other)
|
||||||
else:
|
else:
|
||||||
|
if (startHpr == None):
|
||||||
startHpr = node.getHpr()
|
startHpr = node.getHpr()
|
||||||
|
self.fhpr = startHpr
|
||||||
|
self.thpr = hpr
|
||||||
functor = HprLerpFunctor.HprLerpFunctor(
|
functor = HprLerpFunctor.HprLerpFunctor(
|
||||||
node, startHpr, hpr)
|
node, startHpr, hpr)
|
||||||
|
|
||||||
LerpInterval.__init__(self, name, duration, functor, t0,
|
LerpInterval.__init__(self, name, duration, functor, blendType)
|
||||||
type, blendType)
|
|
||||||
|
@ -8,23 +8,20 @@ class MopathInterval(Interval.Interval):
|
|||||||
|
|
||||||
# special methods
|
# special methods
|
||||||
|
|
||||||
def __init__(self, name, mopath, node, t0=0.0,
|
def __init__(self, name, mopath, node):
|
||||||
type=Interval.PREVIOUS_END):
|
"""__init__(name, mopath, node)
|
||||||
"""__init__(name, mopath, node, t0, type)
|
|
||||||
"""
|
"""
|
||||||
self.name = name
|
self.name = name
|
||||||
self.node = node
|
self.node = node
|
||||||
self.mopath = mopath
|
self.mopath = mopath
|
||||||
self.duration = self.mopath.getMaxT()
|
self.duration = self.mopath.getMaxT()
|
||||||
self.startTime = t0
|
|
||||||
self.type = type
|
|
||||||
|
|
||||||
def setT(self, t):
|
def setT(self, t, entry=0):
|
||||||
""" setT(t)
|
""" setT(t)
|
||||||
Go to time t
|
Go to time t
|
||||||
"""
|
"""
|
||||||
assert(t >= 0.0)
|
assert(t >= 0.0)
|
||||||
if (t > self.duration):
|
if (entry == 1) and (t > self.duration):
|
||||||
self.mopath.goTo(self.node, self.duration)
|
self.mopath.goTo(self.node, self.duration)
|
||||||
else:
|
else:
|
||||||
self.mopath.goTo(self.node, t)
|
self.mopath.goTo(self.node, t)
|
||||||
|
@ -21,8 +21,6 @@ class MultiTrack(Interval.Interval):
|
|||||||
self.name = name
|
self.name = name
|
||||||
self.tlist = trackList
|
self.tlist = trackList
|
||||||
self.duration = self.getDuration()
|
self.duration = self.getDuration()
|
||||||
self.startTime = 0.0
|
|
||||||
self.type = Interval.PREVIOUS_END
|
|
||||||
self.clock = ClockObject.ClockObject.getGlobalClock()
|
self.clock = ClockObject.ClockObject.getGlobalClock()
|
||||||
|
|
||||||
def getDuration(self):
|
def getDuration(self):
|
||||||
@ -36,7 +34,7 @@ class MultiTrack(Interval.Interval):
|
|||||||
duration = dur
|
duration = dur
|
||||||
return duration
|
return duration
|
||||||
|
|
||||||
def setT(self, t):
|
def setT(self, t, entry=0):
|
||||||
""" setT(t)
|
""" setT(t)
|
||||||
Go to time t
|
Go to time t
|
||||||
"""
|
"""
|
||||||
@ -44,7 +42,7 @@ class MultiTrack(Interval.Interval):
|
|||||||
Interval.notify.warning(
|
Interval.notify.warning(
|
||||||
'MultiTrack.setT(): t = %f > duration' % t)
|
'MultiTrack.setT(): t = %f > duration' % t)
|
||||||
for track in self.tlist:
|
for track in self.tlist:
|
||||||
track.setT(t)
|
track.setT(t, entry)
|
||||||
|
|
||||||
def play(self, t0=0.0, duration=0.0):
|
def play(self, t0=0.0, duration=0.0):
|
||||||
""" play(t0, duration)
|
""" play(t0, duration)
|
||||||
|
@ -8,62 +8,56 @@ class PosHprInterval(Interval.Interval):
|
|||||||
|
|
||||||
# special methods
|
# special methods
|
||||||
|
|
||||||
def __init__(self, name, node, pos, hpr, duration, t0=0.0,
|
def __init__(self, name, node, pos, hpr, duration):
|
||||||
type=Interval.PREVIOUS_END):
|
"""__init__(name, node, pos, hpr, duration)
|
||||||
"""__init__(name, node, pos, hpr, duration, t0, type)
|
|
||||||
"""
|
"""
|
||||||
self.name = name
|
self.name = name
|
||||||
self.node = node
|
self.node = node
|
||||||
self.pos = pos
|
self.pos = pos
|
||||||
self.hpr = hpr
|
self.hpr = hpr
|
||||||
self.duration = duration
|
self.duration = duration
|
||||||
self.startTime = t0
|
|
||||||
self.type = type
|
|
||||||
|
|
||||||
def setT(self, t):
|
def setT(self, t, entry=0):
|
||||||
""" setT(t)
|
""" setT(t)
|
||||||
Go to time t
|
Go to time t
|
||||||
"""
|
"""
|
||||||
|
if (entry == 1):
|
||||||
self.node.setPosHpr(self.pos, self.hpr)
|
self.node.setPosHpr(self.pos, self.hpr)
|
||||||
|
|
||||||
class PosInterval(Interval.Interval):
|
class PosInterval(Interval.Interval):
|
||||||
|
|
||||||
# special methods
|
# special methods
|
||||||
|
|
||||||
def __init__(self, name, node, pos, duration, t0=0.0,
|
def __init__(self, name, node, pos, duration):
|
||||||
type=Interval.PREVIOUS_END):
|
"""__init__(name, node, pos, duration)
|
||||||
"""__init__(name, node, pos, duration, t0, type)
|
|
||||||
"""
|
"""
|
||||||
self.name = name
|
self.name = name
|
||||||
self.node = node
|
self.node = node
|
||||||
self.pos = pos
|
self.pos = pos
|
||||||
self.duration = duration
|
self.duration = duration
|
||||||
self.startTime = t0
|
|
||||||
self.type = type
|
|
||||||
|
|
||||||
def setT(self, t):
|
def setT(self, t, entry=0):
|
||||||
""" setT(t)
|
""" setT(t)
|
||||||
Go to time t
|
Go to time t
|
||||||
"""
|
"""
|
||||||
|
if (entry == 1):
|
||||||
self.node.setPos(self.pos)
|
self.node.setPos(self.pos)
|
||||||
|
|
||||||
class HprInterval(Interval.Interval):
|
class HprInterval(Interval.Interval):
|
||||||
|
|
||||||
# special methods
|
# special methods
|
||||||
|
|
||||||
def __init__(self, name, node, hpr, duration, t0=0.0,
|
def __init__(self, name, node, hpr, duration):
|
||||||
type=Interval.PREVIOUS_END):
|
"""__init__(name, node, hpr, duration)
|
||||||
"""__init__(name, node, hpr, duration, t0, type)
|
|
||||||
"""
|
"""
|
||||||
self.name = name
|
self.name = name
|
||||||
self.node = node
|
self.node = node
|
||||||
self.hpr = hpr
|
self.hpr = hpr
|
||||||
self.duration = duration
|
self.duration = duration
|
||||||
self.startTime = t0
|
|
||||||
self.type = type
|
|
||||||
|
|
||||||
def setT(self, t):
|
def setT(self, t, entry=0):
|
||||||
""" setT(t)
|
""" setT(t)
|
||||||
Go to time t
|
Go to time t
|
||||||
"""
|
"""
|
||||||
|
if (entry == 1):
|
||||||
self.node.setHpr(self.hpr)
|
self.node.setHpr(self.hpr)
|
||||||
|
@ -9,9 +9,8 @@ class SoundInterval(Interval.Interval):
|
|||||||
|
|
||||||
# special methods
|
# special methods
|
||||||
|
|
||||||
def __init__(self, name, sound, loop=0, t0=0.0,
|
def __init__(self, name, sound, loop=0):
|
||||||
type=Interval.PREVIOUS_END):
|
"""__init__(name, sound, loop)
|
||||||
"""__init__(name, sound, loop, t0, type)
|
|
||||||
"""
|
"""
|
||||||
self.name = name
|
self.name = name
|
||||||
self.sound = sound
|
self.sound = sound
|
||||||
@ -22,10 +21,8 @@ class SoundInterval(Interval.Interval):
|
|||||||
self.duration = 1.0
|
self.duration = 1.0
|
||||||
self.loop = loop
|
self.loop = loop
|
||||||
self.isPlaying = 0
|
self.isPlaying = 0
|
||||||
self.startTime = t0
|
|
||||||
self.type = type
|
|
||||||
|
|
||||||
def setT(self, t):
|
def setT(self, t, entry=0):
|
||||||
""" setT(t)
|
""" setT(t)
|
||||||
Go to time t
|
Go to time t
|
||||||
"""
|
"""
|
||||||
@ -35,11 +32,8 @@ class SoundInterval(Interval.Interval):
|
|||||||
self.isPlaying = 0
|
self.isPlaying = 0
|
||||||
return
|
return
|
||||||
assert(t >= 0)
|
assert(t >= 0)
|
||||||
if (t == 0):
|
if (entry == 1):
|
||||||
|
self.isPlaying = 1
|
||||||
AudioManager.play(self.sound)
|
AudioManager.play(self.sound)
|
||||||
if (self.loop):
|
if (self.loop):
|
||||||
AudioManager.setLoop(self.sound, 1)
|
AudioManager.setLoop(self.sound, 1)
|
||||||
elif (self.loop) and (self.isPlaying == 0):
|
|
||||||
AudioManager.play(self.sound)
|
|
||||||
AudioManager.setLoop(self.sound, 1)
|
|
||||||
self.isPlaying = 1
|
|
||||||
|
@ -3,6 +3,10 @@
|
|||||||
import Interval
|
import Interval
|
||||||
import types
|
import types
|
||||||
|
|
||||||
|
PREVIOUS_END = 1
|
||||||
|
PREVIOUS_START = 2
|
||||||
|
TRACK_START = 3
|
||||||
|
|
||||||
class Track(Interval.Interval):
|
class Track(Interval.Interval):
|
||||||
|
|
||||||
trackNum = 1
|
trackNum = 1
|
||||||
@ -18,10 +22,14 @@ class Track(Interval.Interval):
|
|||||||
else:
|
else:
|
||||||
self.name = name
|
self.name = name
|
||||||
|
|
||||||
self.ilist = intervalList
|
self.__buildIlist(intervalList)
|
||||||
self.duration = self.__computeDuration(len(self.ilist))
|
self.duration = self.__computeDuration(len(self.ilist))
|
||||||
self.startTime = 0.0
|
self.currentInterval = None
|
||||||
self.type = Interval.PREVIOUS_END
|
|
||||||
|
def __buildIlist(self, intervalList):
|
||||||
|
self.ilist = []
|
||||||
|
for i in intervalList:
|
||||||
|
self.ilist.append((i, 0.0, PREVIOUS_END))
|
||||||
|
|
||||||
def __computeDuration(self, length):
|
def __computeDuration(self, length):
|
||||||
""" __computeDuration(length)
|
""" __computeDuration(length)
|
||||||
@ -30,16 +38,17 @@ class Track(Interval.Interval):
|
|||||||
duration = 0.0
|
duration = 0.0
|
||||||
prev = None
|
prev = None
|
||||||
for i in self.ilist[0:length]:
|
for i in self.ilist[0:length]:
|
||||||
type = i.getType()
|
ival = i[0]
|
||||||
t0 = i.getStartTime()
|
t0 = i[1]
|
||||||
|
type = i[2]
|
||||||
assert(t0 >= 0.0)
|
assert(t0 >= 0.0)
|
||||||
fillTime = t0
|
fillTime = t0
|
||||||
if (type == Interval.PREVIOUS_END):
|
if (type == PREVIOUS_END):
|
||||||
pass
|
pass
|
||||||
elif (type == Interval.PREVIOUS_START):
|
elif (type == PREVIOUS_START):
|
||||||
if (prev != None):
|
if (prev != None):
|
||||||
fillTime = t0 - prev.getDuration()
|
fillTime = t0 - prev.getDuration()
|
||||||
elif (type == Interval.TRACK_START):
|
elif (type == TRACK_START):
|
||||||
fillTime = t0 - duration
|
fillTime = t0 - duration
|
||||||
else:
|
else:
|
||||||
Interval.notify.error(
|
Interval.notify.error(
|
||||||
@ -47,16 +56,34 @@ class Track(Interval.Interval):
|
|||||||
if (fillTime < 0.0):
|
if (fillTime < 0.0):
|
||||||
Interval.notify.error(
|
Interval.notify.error(
|
||||||
'Track.__computeDuration(): overlap detected')
|
'Track.__computeDuration(): overlap detected')
|
||||||
duration = duration + fillTime + i.getDuration()
|
duration = duration + fillTime + ival.getDuration()
|
||||||
prev = i
|
prev = ival
|
||||||
return duration
|
return duration
|
||||||
|
|
||||||
|
def setIntervalStartTime(self, name, t0, type=TRACK_START):
|
||||||
|
""" setIntervalStartTime(name, t0, type)
|
||||||
|
"""
|
||||||
|
length = len(self.ilist)
|
||||||
|
found = 0
|
||||||
|
for i in range(length):
|
||||||
|
if (self.ilist[i][0].getName() == name):
|
||||||
|
newi = (self.ilist[i][0], t0, type)
|
||||||
|
self.ilist[i] = newi
|
||||||
|
found = 1
|
||||||
|
break;
|
||||||
|
if (found):
|
||||||
|
self.duration = self.__computeDuration(length)
|
||||||
|
else:
|
||||||
|
Interval.notify.warning(
|
||||||
|
'Track.setIntervalStartTime(): no Interval named: %s' % name)
|
||||||
|
|
||||||
def getIntervalStartTime(self, name):
|
def getIntervalStartTime(self, name):
|
||||||
""" getIntervalStartTime(name)
|
""" getIntervalStartTime(name)
|
||||||
"""
|
"""
|
||||||
for i in range(len(self.ilist)):
|
for i in range(len(self.ilist)):
|
||||||
if (self.ilist[i].getName() == name):
|
if (self.ilist[i][0].getName() == name):
|
||||||
return self.__computeDuration(i+1) - self.ilist[i].getDuration()
|
return (self.__computeDuration(i+1) -
|
||||||
|
self.ilist[i][0].getDuration())
|
||||||
Interval.notify.warning(
|
Interval.notify.warning(
|
||||||
'Track.getIntervalStartTime(): no Interval named: %s' % name)
|
'Track.getIntervalStartTime(): no Interval named: %s' % name)
|
||||||
return 0.0
|
return 0.0
|
||||||
@ -64,56 +91,71 @@ class Track(Interval.Interval):
|
|||||||
def __getIntervalStartTime(self, interval):
|
def __getIntervalStartTime(self, interval):
|
||||||
""" __getIntervalStartTime(interval)
|
""" __getIntervalStartTime(interval)
|
||||||
"""
|
"""
|
||||||
return (self.__computeDuration(self.ilist.index(interval)+1) -
|
for i in range(len(self.ilist)):
|
||||||
interval.getDuration())
|
if (self.ilist[i][0] == interval):
|
||||||
|
return (self.__computeDuration(i+1) - interval.getDuration())
|
||||||
|
Interval.notify.warning(
|
||||||
|
'Track.__getIntervalStartTime(): Interval not found')
|
||||||
|
return 0.0
|
||||||
|
|
||||||
def getIntervalEndTime(self, name):
|
def getIntervalEndTime(self, name):
|
||||||
""" getIntervalEndTime(name)
|
""" getIntervalEndTime(name)
|
||||||
"""
|
"""
|
||||||
for i in range(len(self.ilist)):
|
for i in range(len(self.ilist)):
|
||||||
if (self.ilist[i].getName() == name):
|
if (self.ilist[i][0].getName() == name):
|
||||||
return self.__computeDuration(i+1)
|
return self.__computeDuration(i+1)
|
||||||
Interval.notify.warning(
|
Interval.notify.warning(
|
||||||
'Track.getIntervalEndTime(): no Interval named: %s' % name)
|
'Track.getIntervalEndTime(): no Interval named: %s' % name)
|
||||||
return 0.0
|
return 0.0
|
||||||
|
|
||||||
def setT(self, t):
|
def setT(self, t, entry=0):
|
||||||
""" setT(t)
|
""" setT(t, entry)
|
||||||
Go to time t
|
Go to time t
|
||||||
"""
|
"""
|
||||||
|
if (entry == 1):
|
||||||
|
self.currentInterval = None
|
||||||
if (len(self.ilist) == 0):
|
if (len(self.ilist) == 0):
|
||||||
Interval.notify.warning('Track.setT(): track has no intervals')
|
Interval.notify.warning('Track.setT(): track has no intervals')
|
||||||
return
|
return
|
||||||
elif (t > self.duration):
|
elif (entry == 1) and (t > self.duration):
|
||||||
# Anything beyond the end of the track is assumed to be the
|
# Anything beyond the end of the track is assumed to be the
|
||||||
# final state of the last Interval on the track
|
# final state of the last Interval on the track
|
||||||
self.ilist[len(self.ilist)-1].setT(t)
|
self.ilist[len(self.ilist)-1][0].setT(t, entry=1)
|
||||||
else:
|
else:
|
||||||
# Find out which Interval applies
|
# Find out which Interval applies
|
||||||
prev = None
|
prev = None
|
||||||
for i in self.ilist:
|
for i in self.ilist:
|
||||||
# Calculate the track relative start time for the interval
|
# Calculate the track relative start time for the interval
|
||||||
t0 = self.__getIntervalStartTime(i)
|
ival = i[0]
|
||||||
|
t0 = self.__getIntervalStartTime(ival)
|
||||||
|
|
||||||
# Determine if the Interval is applicable
|
# Determine if the Interval is applicable
|
||||||
if (t < t0):
|
if (t < t0):
|
||||||
if (prev != None):
|
if (prev != None):
|
||||||
# Gaps between Intervals take the final state of
|
# Gaps between Intervals take the final state of
|
||||||
# the previous Interval
|
# the previous Interval
|
||||||
|
if (self.currentInterval != prev):
|
||||||
|
prev.setT(t, entry=1)
|
||||||
|
self.currentInterval = prev
|
||||||
|
else:
|
||||||
prev.setT(t)
|
prev.setT(t)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
#Interval.Interval.notify.warning(
|
#Interval.Interval.notify.warning(
|
||||||
# 'Track.setT(): state undefined at t: %f' % t)
|
# 'Track.setT(): state undefined at t: %f' % t)
|
||||||
return
|
return
|
||||||
elif (t0 <= t) and (t <= t0 + i.getDuration()):
|
elif (t0 <= t) and (t <= t0 + ival.getDuration()):
|
||||||
i.setT(t - t0)
|
if (self.currentInterval != ival):
|
||||||
|
ival.setT(t - t0, entry=1)
|
||||||
|
self.currentInterval = ival
|
||||||
|
else:
|
||||||
|
ival.setT(t - t0)
|
||||||
return
|
return
|
||||||
prev = i
|
prev = ival
|
||||||
|
|
||||||
def printParams(self, indent=0):
|
def printParams(self, indent=0):
|
||||||
""" printParams(indent)
|
""" printParams(indent)
|
||||||
"""
|
"""
|
||||||
Interval.Interval.printParams(self, indent)
|
Interval.Interval.printParams(self, indent)
|
||||||
for i in self.ilist:
|
for i in self.ilist:
|
||||||
i.printParams(indent+1)
|
i[0].printParams(indent+1)
|
||||||
|
@ -10,8 +10,7 @@ class Wait(Interval.Interval):
|
|||||||
|
|
||||||
# special methods
|
# special methods
|
||||||
|
|
||||||
def __init__(self, duration, name=None, t0=0.0,
|
def __init__(self, duration, name=None):
|
||||||
type=Interval.PREVIOUS_END):
|
|
||||||
"""__init__(duration, name, t0, type)
|
"""__init__(duration, name, t0, type)
|
||||||
"""
|
"""
|
||||||
if (name == None):
|
if (name == None):
|
||||||
@ -20,5 +19,3 @@ class Wait(Interval.Interval):
|
|||||||
else:
|
else:
|
||||||
self.name = name
|
self.name = name
|
||||||
self.duration = duration
|
self.duration = duration
|
||||||
self.startTime = 0.0
|
|
||||||
self.type = type
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user