*** empty log message ***
This commit is contained in:
parent
21c4a03c16
commit
af7d856efc
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
from PandaModules import *
|
||||
from Interval import *
|
||||
import math
|
||||
|
||||
import DirectNotifyGlobal
|
||||
|
||||
|
|
@ -32,6 +33,7 @@ class ActorInterval(Interval):
|
|||
self.actor = actor
|
||||
self.animName = animName
|
||||
self.loop = loop
|
||||
self.frameRate = self.actor.getFrameRate(self.animName)
|
||||
self.numFrames = self.actor.getNumFrames(self.animName)
|
||||
# Compute start time
|
||||
self.startTime = startTime
|
||||
|
|
@ -49,6 +51,23 @@ class ActorInterval(Interval):
|
|||
self.stopEvent = id + '_stopEvent'
|
||||
self.stopEventList = [self.stopEvent]
|
||||
|
||||
def calcFrame(self, t):
|
||||
# Compute current frame based upon current time
|
||||
floatFrame = self.frameRate * (self.startTime + t)
|
||||
# Need max to avoid frame = -1 when t = 0
|
||||
frame = max(0, int(math.ceil(floatFrame)) - 1)
|
||||
# Modulo in case of looping anim
|
||||
return frame % self.numFrames
|
||||
|
||||
def goToT(self, t):
|
||||
# Calc integer frame number
|
||||
frame = self.calcFrame(t)
|
||||
# Pose anim
|
||||
self.actor.pose(self.animName, frame)
|
||||
# Print debug information
|
||||
self.notify.debug('goToT() - pose to frame: %d' % frame)
|
||||
return frame
|
||||
|
||||
def updateFunc(self, t, event = IVAL_NONE):
|
||||
""" updateFunc(t, event)
|
||||
Go to time t
|
||||
|
|
@ -60,33 +79,23 @@ class ActorInterval(Interval):
|
|||
# Pose or stop anim
|
||||
if (t >= (self.startTime + self.getDuration())):
|
||||
self.actor.stop()
|
||||
currT = (self.actor.getFrameRate(self.animName) *
|
||||
(self.startTime + self.getDuration()))
|
||||
frame = int(round(currT)) % self.numFrames
|
||||
# Pose anim
|
||||
self.notify.debug('updateFunc() - stopping at frame: %d of %d' \
|
||||
% (frame, self.numFrames))
|
||||
self.actor.pose(self.animName, frame)
|
||||
frame = self.goToT(self.getDuration())
|
||||
if self.loop:
|
||||
self.ignore(self.stopEvent)
|
||||
# Print debug information
|
||||
self.notify.debug(
|
||||
'updateFunc() - stoping at frame: ' +
|
||||
'%d Num frames: %d' % (frame, self.numFrames))
|
||||
elif self.loop == 1:
|
||||
if event == IVAL_INIT:
|
||||
# Determine the current frame
|
||||
currT = (self.actor.getFrameRate(self.animName) *
|
||||
(self.startTime + t))
|
||||
frame = int(round(currT)) % self.numFrames
|
||||
# Pose anim
|
||||
self.actor.pose(self.animName, frame)
|
||||
self.goToT(t)
|
||||
# And start loop, restart flag says continue from current frame
|
||||
self.actor.loop(self.animName, restart=0)
|
||||
self.accept(self.stopEvent, self.actor.stop)
|
||||
# Print debug information
|
||||
self.notify.debug('updateFunc() - IVAL_INIT looping anim')
|
||||
else:
|
||||
# Determine the current frame
|
||||
currT = (self.actor.getFrameRate(self.animName) *
|
||||
(self.startTime + t))
|
||||
frame = int(round(currT)) % self.numFrames
|
||||
# Pose anim
|
||||
self.actor.pose(self.animName, frame)
|
||||
|
||||
|
||||
self.goToT(t)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue