|
@@ -16,7 +16,8 @@ class ActorInterval(Interval):
|
|
|
# Note: if loop == 0 and duration > anim duration then the animation
|
|
# Note: if loop == 0 and duration > anim duration then the animation
|
|
|
# will play once and then nothing will happen for the remainder of the
|
|
# will play once and then nothing will happen for the remainder of the
|
|
|
# interval
|
|
# interval
|
|
|
- def __init__(self, actor, animName, loop=0, duration=0.0, name=None):
|
|
|
|
|
|
|
+ def __init__(self, actor, animName, loop=0, duration=0.0,
|
|
|
|
|
+ startTime = 0.0, name=None):
|
|
|
"""__init__(name)
|
|
"""__init__(name)
|
|
|
"""
|
|
"""
|
|
|
# Generate unique id
|
|
# Generate unique id
|
|
@@ -27,12 +28,15 @@ class ActorInterval(Interval):
|
|
|
self.animName = animName
|
|
self.animName = animName
|
|
|
self.loop = loop
|
|
self.loop = loop
|
|
|
self.numFrames = self.actor.getNumFrames(self.animName)
|
|
self.numFrames = self.actor.getNumFrames(self.animName)
|
|
|
|
|
+ # Compute start time
|
|
|
|
|
+ self.startTime = startTime
|
|
|
# If no name specified, use id as name
|
|
# If no name specified, use id as name
|
|
|
if (name == None):
|
|
if (name == None):
|
|
|
name = id
|
|
name = id
|
|
|
# Compute duration if no duration specified
|
|
# Compute duration if no duration specified
|
|
|
if duration == 0.0:
|
|
if duration == 0.0:
|
|
|
- duration = self.actor.getDuration(self.animName)
|
|
|
|
|
|
|
+ duration = max(self.actor.getDuration(self.animName) - startTime,
|
|
|
|
|
+ 0.0)
|
|
|
# Initialize superclass
|
|
# Initialize superclass
|
|
|
Interval.__init__(self, name, duration)
|
|
Interval.__init__(self, name, duration)
|
|
|
# Update stopEvent
|
|
# Update stopEvent
|
|
@@ -53,8 +57,11 @@ class ActorInterval(Interval):
|
|
|
elif self.loop == 1:
|
|
elif self.loop == 1:
|
|
|
if event == IVAL_INIT:
|
|
if event == IVAL_INIT:
|
|
|
# Determine the current frame
|
|
# Determine the current frame
|
|
|
- frame = (int(self.actor.getFrameRate(self.animName) * t) %
|
|
|
|
|
- self.numFrames)
|
|
|
|
|
|
|
+ currT = (self.actor.getFrameRate(self.animName) *
|
|
|
|
|
+ (self.startTime + t))
|
|
|
|
|
+ print t, currT
|
|
|
|
|
+ frame = int(currT) % self.numFrames
|
|
|
|
|
+ print frame
|
|
|
# Pose anim
|
|
# Pose anim
|
|
|
self.actor.pose(self.animName, frame)
|
|
self.actor.pose(self.animName, frame)
|
|
|
# And start loop, restart flag says continue from current frame
|
|
# And start loop, restart flag says continue from current frame
|
|
@@ -62,8 +69,9 @@ class ActorInterval(Interval):
|
|
|
self.accept(self.stopEvent, self.actor.stop)
|
|
self.accept(self.stopEvent, self.actor.stop)
|
|
|
else:
|
|
else:
|
|
|
# Determine the current frame
|
|
# Determine the current frame
|
|
|
- frame = (int(self.actor.getFrameRate(self.animName) * t) %
|
|
|
|
|
- self.numFrames)
|
|
|
|
|
|
|
+ currT = (self.actor.getFrameRate(self.animName) *
|
|
|
|
|
+ (self.startTime + t))
|
|
|
|
|
+ frame = int(currT) % self.numFrames
|
|
|
# Pose anim
|
|
# Pose anim
|
|
|
self.actor.pose(self.animName, frame)
|
|
self.actor.pose(self.animName, frame)
|
|
|
|
|
|