View Single Post
  #1  
Old 01-22-2016, 03:02 PM
fivel_lab fivel_lab is offline
Member
 
Join Date: Mar 2011
Posts: 36
timing on a sequence of actions

Hi!
I am trying to animate an avatar using boneSpinTo driven by data coming in from FAAST. I've got this part working.

What I'd like to do now is to scale the speed with which the avatar's bones spin to the current state of the tracking data. So, if the left arm of the person being tracked moves 30cm/sec, then the left arm of the avatar would move k*30cm/sec (until the avatar's left arm was at the rotation that the tracked person's arm was at).

To do this I thought I'd use a sequence of actions, each of which covers a fraction of the total spin necessary to align the avatar and the tracking data:

Code:
for bone in myBones:
#find out where the bone needs to go
   targetEuler = trackerBones[bone].getEuler() 
#find where the bone was the last time it was moved
   tempEuler = bonesWereHere[bone]

   spinSequence = [];
   while True:
      #find discrepancy between where bone is and target
      diff = [x-y for x,y in izip(targetEuler, tempEuler)]
      #find amount by which to move bone towards target
      delta = [x*k for x in diff]  # k is a scaling factor < 1.0

      if delta != [0,0,0]:
         tempEuler = [sum(x) for x in izip(tempEuler, delta)]
      else:
         tempEuler = targetEuler
         break

      #make an action to spin the bone by the amount specified in delta
      spinIt = vizact.boneSpinTo(bone, mode = viz.ABS_GLOBAL, euler = tempEuler)
      spinSequence.append(spinIt)

   #now that all intermediate actions have been added, execute the sequence
   myAvatar.runAction(vizact.sequence(spinSequence))
However, this method doesn't seem to slow things down very much, unless the k is REALLY small (or maybe i'm just not noticing how much it is slowing down). I'm wondering how long each action in a sequence of actions takes to execute, and if vizard interpolates between a chain of related actions in a sequence to cut down on processing? If it does, is there a way to ensure that each action takes, say, at least 1 frame to execute before the sequence moves on to the next action?

Hope that makes sense! Any help is GREATLY appreciated!
Thanks..
Reply With Quote