mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
*** empty log message ***
This commit is contained in:
parent
2b378c3dc4
commit
68d3a0e64f
48
direct/src/interval/IntervalPlayer.py
Normal file
48
direct/src/interval/IntervalPlayer.py
Normal file
@ -0,0 +1,48 @@
|
||||
"""IntervalPlayer module: contains the IntervalPlayer class"""
|
||||
|
||||
from DirectObject import *
|
||||
|
||||
import Interval
|
||||
import Task
|
||||
|
||||
class IntervalPlayer(DirectObject):
|
||||
"""IntervalPlayer class: Plays back Intervals (like a taskMgr)"""
|
||||
|
||||
# special methods
|
||||
|
||||
def __init__(self, clock):
|
||||
"""__init__(clock)
|
||||
"""
|
||||
self.clock = clock
|
||||
self.intervals = []
|
||||
|
||||
def addInterval(self, interval):
|
||||
""" addInterval(interval)
|
||||
"""
|
||||
self.intervals.append(interval)
|
||||
|
||||
def removeInterval(self, interval):
|
||||
""" removeInterval(interval)
|
||||
"""
|
||||
self.intervals.remove(interval)
|
||||
|
||||
def play(self):
|
||||
""" play()
|
||||
"""
|
||||
self.duration = 0.0
|
||||
for i in self.intervals:
|
||||
dur = i.getDuration()
|
||||
if (dur > self.duration):
|
||||
self.duration = dur
|
||||
self.startT = self.clock.getFrameTime()
|
||||
taskMgr.spawnMethodNamed(self.__playTask, 'interval-player')
|
||||
|
||||
def __playTask(self, task):
|
||||
t = self.clock.getFrameTime()
|
||||
te = t - self.startT
|
||||
if (te <= self.duration):
|
||||
for i in self.intervals:
|
||||
i.setT(te)
|
||||
return Task.cont
|
||||
else:
|
||||
return Task.done
|
@ -1,25 +1,43 @@
|
||||
from PandaModules import *
|
||||
from DirectSessionGlobal import *
|
||||
from LerpInterval import *
|
||||
from WaitInterval import *
|
||||
|
||||
import Mopath
|
||||
import MopathInterval
|
||||
import SoundInterval
|
||||
import Track
|
||||
import MultiTrack
|
||||
import IntervalPlayer
|
||||
|
||||
AudioManager.spawnUpdate()
|
||||
|
||||
smiley = loader.loadModel('models/directmodels/smiley')
|
||||
smiley.reparentTo(render)
|
||||
boat = loader.loadModel('models/directmodels/smiley')
|
||||
boat.reparentTo(render)
|
||||
|
||||
dock = loader.loadModel('models/directmodels/smiley')
|
||||
dock.reparentTo(render)
|
||||
|
||||
mp = Mopath.Mopath()
|
||||
mp.loadFile(Filename('phase_6/paths/dd-e-w'))
|
||||
|
||||
mpi = MopathInterval.MopathInterval('boatpath', mp, smiley)
|
||||
boatMopath = MopathInterval.MopathInterval('boatpath', mp, boat)
|
||||
|
||||
sound = loader.loadSound('phase_6/audio/sfx/SZ_DD_waterlap.mp3')
|
||||
si = SoundInterval.SoundInterval('watersound', sound)
|
||||
waterSound = SoundInterval.SoundInterval('watersound', sound)
|
||||
|
||||
pos = Point3(0, 0, -5)
|
||||
hpr = Vec3(0, 0, 0)
|
||||
li = LerpPosHprInterval('lerp', smiley, pos, hpr, 5.0)
|
||||
dockLerp = LerpPosHprInterval('lerp', dock, pos, hpr, 5.0)
|
||||
|
||||
boatTrack = Track.Track([boatMopath])
|
||||
dockWaitTime = boatMopath.getDuration() - dockLerp.getDuration()
|
||||
dockTrack = Track.Track([Wait(dockWaitTime), dockLerp])
|
||||
postSoundWaitTime = 3.0
|
||||
preSoundWaitTime = boatMopath.getDuration() - (waterSound.getDuration() + postSoundWaitTime)
|
||||
soundTrack = Track.Track([Wait(preSoundWaitTime), waterSound, Wait(postSoundWaitTime)])
|
||||
|
||||
mtrack = MultiTrack.MultiTrack([boatTrack, dockTrack, soundTrack])
|
||||
|
||||
player = IntervalPlayer.IntervalPlayer(globalClock)
|
||||
player.addInterval(mtrack)
|
||||
|
@ -5,24 +5,31 @@ import Track
|
||||
|
||||
class MultiTrack(Interval.Interval):
|
||||
|
||||
multiTrackNum = 1
|
||||
|
||||
# special methods
|
||||
|
||||
def __init__(self, name, trackList):
|
||||
"""__init__(name, trackList)
|
||||
def __init__(self, trackList, name = None):
|
||||
"""__init__(trackList, name)
|
||||
"""
|
||||
self.name = name
|
||||
if (name == None):
|
||||
self.name = 'MultiTrack-%d' % self.multiTrackNum
|
||||
self.multiTrackNum = self.multiTrackNum + 1
|
||||
else:
|
||||
self.name = name
|
||||
self.tlist = trackList
|
||||
self.getDuration()
|
||||
|
||||
def getDuration(self):
|
||||
""" getDuration()
|
||||
"""
|
||||
if (len(self.tlist == 0):
|
||||
Interval.notify.warning('MultiTrack.getDuration(): no Tracks')
|
||||
return 0.0
|
||||
#if (len(self.tlist == 0)):
|
||||
# Interval.notify.warning('MultiTrack.getDuration(): no Tracks')
|
||||
# return 0.0
|
||||
self.duration = self.tlist[0].getDuration()
|
||||
for t in self.tlist:
|
||||
assert(self.duration = t.getDuration())
|
||||
if (self.duration != t.getDuration()):
|
||||
Interval.Interval.notify.warning('MultiTrack.getDuration(): tracks not all same duration')
|
||||
return self.duration
|
||||
|
||||
def setT(self, t):
|
||||
|
27
direct/src/interval/PosHprInterval.py
Normal file
27
direct/src/interval/PosHprInterval.py
Normal file
@ -0,0 +1,27 @@
|
||||
"""PosHprInterval module: contains the PosHprInterval class"""
|
||||
|
||||
from PandaModules import *
|
||||
|
||||
import Interval
|
||||
|
||||
class PosHprInterval(Interval.Interval):
|
||||
|
||||
# special methods
|
||||
|
||||
def __init__(self, name, node, pos, hpr, duration):
|
||||
"""__init__(name, node, pos, hpr, duration)
|
||||
"""
|
||||
self.name = name
|
||||
self.node = node
|
||||
self.pos = pos
|
||||
self.hpr = hpr
|
||||
self.duration = duration
|
||||
|
||||
def setT(self, t):
|
||||
""" setT(t)
|
||||
Go to time t
|
||||
"""
|
||||
if (t > self.duration):
|
||||
return
|
||||
assert(t >= 0)
|
||||
self.node.setPosHpr(self.pos, self.hpr)
|
@ -4,25 +4,30 @@ import Interval
|
||||
|
||||
class Track(Interval.Interval):
|
||||
|
||||
trackNum = 1
|
||||
|
||||
# special methods
|
||||
|
||||
def __init__(self, name, intervalList):
|
||||
"""__init__(name, intervalList)
|
||||
def __init__(self, intervalList, name = None):
|
||||
"""__init__(intervalList, name)
|
||||
"""
|
||||
self.name = name
|
||||
if (name == None):
|
||||
self.name = 'Track-%d' % self.trackNum
|
||||
self.trackNum = self.trackNum + 1
|
||||
else:
|
||||
self.name = name
|
||||
self.ilist = intervalList
|
||||
self.dlist = []
|
||||
self.getDuration()
|
||||
self.computeDuration()
|
||||
|
||||
def getDuration(self):
|
||||
""" getDuration()
|
||||
def computeDuration(self):
|
||||
""" computeDuration()
|
||||
"""
|
||||
self.duration = 0.0
|
||||
for i in self.ilist:
|
||||
dur = i.getDuration()
|
||||
self.duration = self.duration + dur
|
||||
self.dlist.append(dur)
|
||||
return self.duration
|
||||
|
||||
def getStartTimeOf(self, name):
|
||||
""" getStartTimeOf(name)
|
||||
|
21
direct/src/interval/WaitInterval.py
Normal file
21
direct/src/interval/WaitInterval.py
Normal file
@ -0,0 +1,21 @@
|
||||
"""WaitInterval module: contains the Wait class"""
|
||||
|
||||
from PandaModules import *
|
||||
|
||||
import Interval
|
||||
|
||||
class Wait(Interval.Interval):
|
||||
|
||||
waitNum = 1
|
||||
|
||||
# special methods
|
||||
|
||||
def __init__(self, duration, name = None):
|
||||
"""__init__(duration, name)
|
||||
"""
|
||||
if (name == None):
|
||||
self.name = 'wait-%d' % self.waitNum
|
||||
self.waitNum = self.waitNum + 1
|
||||
else:
|
||||
self.name = name
|
||||
self.duration = duration
|
Loading…
x
Reference in New Issue
Block a user