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
f099c4e7e3
commit
3f5e894d14
@ -20,6 +20,7 @@ class Interval(DirectObject):
|
||||
"""
|
||||
self.name = name
|
||||
self.duration = duration
|
||||
assert(t >= 0.0)
|
||||
self.startTime = t0
|
||||
self.type = type
|
||||
|
||||
@ -38,6 +39,13 @@ class Interval(DirectObject):
|
||||
"""
|
||||
return self.startTime
|
||||
|
||||
def setStartTime(self, t, rel=PrevEndRelative):
|
||||
""" setStartTime()
|
||||
"""
|
||||
assert(t >= 0.0)
|
||||
self.startTime = t
|
||||
self.type = rel
|
||||
|
||||
def getType(self):
|
||||
""" getType()
|
||||
"""
|
||||
|
@ -5,7 +5,7 @@ from IntervalGlobal import *
|
||||
import Mopath
|
||||
import IntervalPlayer
|
||||
|
||||
AudioManager.spawnUpdate()
|
||||
#AudioManager.spawnUpdate()
|
||||
|
||||
boat = loader.loadModel('models/directmodels/smiley')
|
||||
boat.reparentTo(render)
|
||||
@ -13,24 +13,29 @@ boat.reparentTo(render)
|
||||
dock = loader.loadModel('models/directmodels/smiley')
|
||||
dock.reparentTo(render)
|
||||
|
||||
sound = loader.loadSound('phase_6/audio/sfx/SZ_DD_waterlap.mp3')
|
||||
|
||||
mp = Mopath.Mopath()
|
||||
mp.loadFile(Filename('phase_6/paths/dd-e-w'))
|
||||
|
||||
boatMopath = MopathInterval('boatpath', mp, boat)
|
||||
|
||||
sound = loader.loadSound('phase_6/audio/sfx/SZ_DD_waterlap.mp3')
|
||||
waterSound = SoundInterval('watersound', sound)
|
||||
boatTrack = Track.Track([boatMopath], 'boattrack')
|
||||
|
||||
# Make the dock lerp up so that it's up when the boat reaches the end of
|
||||
# its mopath
|
||||
pos = Point3(0, 0, -5)
|
||||
hpr = Vec3(0, 0, 0)
|
||||
dockLerp = LerpPosHprInterval('lerp', dock, pos, hpr, 5.0)
|
||||
dockUpTime = boatTrack.getTrackRelativeEndTime('boatpath') - dockLerp.getDuration()
|
||||
dockLerp.setStartTime(dockUpTime, Interval.Interval.TrackStartRelative)
|
||||
dockTrack = Track.Track([dockLerp], 'docktrack')
|
||||
|
||||
boatTrack = Track.Track([boatMopath], 'boattrack')
|
||||
dockWaitTime = boatMopath.getDuration() - dockLerp.getDuration()
|
||||
dockTrack = Track.Track([Wait(dockWaitTime), dockLerp], 'docktrack')
|
||||
postSoundWaitTime = 3.0
|
||||
preSoundWaitTime = boatMopath.getDuration() - (waterSound.getDuration() + postSoundWaitTime)
|
||||
soundTrack = Track.Track([Wait(preSoundWaitTime), waterSound, Wait(postSoundWaitTime)], 'soundtrack')
|
||||
# Start the water sound 5 seconds after the boat starts moving
|
||||
waterStartTime = boatTrack.getTrackRelativeStartTime('boatpath') + 5.0
|
||||
waterSound = SoundInterval('watersound', sound, loop=1)
|
||||
waterSound.setStartTime(waterStartTime, Interval.Interval.TrackStartRelative)
|
||||
soundTrack = Track.Track([waterSound], 'soundtrack')
|
||||
|
||||
mtrack = MultiTrack.MultiTrack([boatTrack, dockTrack, soundTrack])
|
||||
|
||||
|
@ -16,6 +16,10 @@ class SoundInterval(Interval.Interval):
|
||||
self.name = name
|
||||
self.sound = sound
|
||||
self.duration = self.sound.length()
|
||||
if (self.duration == 0.0):
|
||||
Interval.Interval.notify.warning(
|
||||
'SoundInterval(): zero length sound - setting duration = 1.0')
|
||||
self.duration = 1.0
|
||||
self.loop = loop
|
||||
self.isPlaying = 0
|
||||
self.startTime = t0
|
||||
@ -25,8 +29,9 @@ class SoundInterval(Interval.Interval):
|
||||
""" setT(t)
|
||||
Go to time t
|
||||
"""
|
||||
print 'SoundInterval.setT(): t: %f' % t
|
||||
if (t > self.duration):
|
||||
if (self.isPlaying == 1):
|
||||
AudioManager.stop(self.sound)
|
||||
return
|
||||
assert(t >= 0)
|
||||
if (t == 0):
|
||||
|
@ -56,7 +56,7 @@ class Track(Interval.Interval):
|
||||
"""
|
||||
for i in range(len(self.ilist)):
|
||||
if (self.ilist[i].getName() == name):
|
||||
return self.__computeDuration(i) - self.ilist[i].getDuration()
|
||||
return self.__computeDuration(i+1) - self.ilist[i].getDuration()
|
||||
Interval.notify.warning(
|
||||
'Track.getRelativeStartTime(): no Interval named: %s' % name)
|
||||
return 0.0
|
||||
@ -72,7 +72,7 @@ class Track(Interval.Interval):
|
||||
"""
|
||||
for i in range(len(self.ilist)):
|
||||
if (self.ilist[i].getName() == name):
|
||||
return self.__computeDuration(i)
|
||||
return self.__computeDuration(i+1)
|
||||
Interval.notify.warning(
|
||||
'Track.getRelativeEndTime(): no Interval named: %s' % name)
|
||||
return 0.0
|
||||
@ -88,11 +88,9 @@ class Track(Interval.Interval):
|
||||
# Anything beyond the end of the track is assumed to be the
|
||||
# final state of the last Interval on the track
|
||||
self.ilist[len(self.ilist)-1].setT(t)
|
||||
print self.name + ': t > self.duration'
|
||||
else:
|
||||
# Find out which Interval applies
|
||||
prev = None
|
||||
print self.name
|
||||
for i in self.ilist:
|
||||
# Calculate the track relative start time for the interval
|
||||
t0 = self.__getTrackRelativeStartTime(i)
|
||||
@ -100,7 +98,6 @@ class Track(Interval.Interval):
|
||||
# Determine if the Interval is applicable
|
||||
if (t < t0):
|
||||
if (prev != None):
|
||||
print 'in a gap at t: %f' % t
|
||||
# Gaps between Intervals take the final state of
|
||||
# the previous Interval
|
||||
prev.setT(t)
|
||||
@ -110,8 +107,6 @@ class Track(Interval.Interval):
|
||||
'Track.setT(): state undefined at t: %f' % t)
|
||||
return
|
||||
elif (t0 <= t) and (t <= t0 + i.getDuration()):
|
||||
print 'in interval: ' + i.getName() + ' at t: %f' % t
|
||||
i.setT(t - t0)
|
||||
return
|
||||
prev = i
|
||||
print 'no intervals apply at t: %f' % t
|
||||
|
Loading…
x
Reference in New Issue
Block a user