WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   timing on a sequence of actions (https://forum.worldviz.com/showthread.php?t=5612)

fivel_lab 01-22-2016 03:02 PM

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..

fivel_lab 01-22-2016 03:10 PM

I should also mention that the code above is from the update function of a custom action...

Jeff 01-23-2016 10:34 PM

The vizact.boneSpinTo command accepts a time or speed argument to control the speed of the animation. If you want to manually set the orientation of the bone each frame, you could use one of the set commands on the bone.

Perhaps there's an easier way to accomplish this. Vizconnect supports avatar IK. You can apply a scale factor to position movements of the trackers that are mapped to the avatar.

fivel_lab 02-29-2016 04:35 PM

Hi Jeff, this is a lab account and our team has been unable to return to this problem recently but we now have the time to explore it further.

thanks for your input. We are using Vizard 4.0 and do not have access to vizconnect. Would you mind telling us more about the speed parameter in boneSpinTo? the documentation says only that it is the speed to spin at in degrees/sec.

If we were to calculate the difference in euler angle between the bone at the last update and at the present update, and divide that by the update time, would that give us the speed? we could then scale that and use it as the speed parameter in bonespinto.

If that is a good method, would you mind giving us a few pointers on how to go about calculating it? We're not super familiar with euler geometry around here.

Thanks..

Jeff 03-01-2016 08:33 PM

Are you updating the avatar each frame based on tracking data? Or is the avatar in a different state than the tracked user and animated for some period of time to match up?

fivel_lab 03-07-2016 01:26 PM

Well, I'm not quite sure. That's sort of what I was asking in my original question. I was hoping to do the latter of your suggestions. The update function I wrote in the OP is called every frame. What I can't figure out is whether the sequence of actions strung together in the update function are executed individually (at a rate of 1/frame or some such) or whether the entire sequence is combined so that the end point of the sequence is achieved before the next frame. Thanks!!

Jeff 03-07-2016 08:27 PM

The vizact.boneSpinTo command is designed to animate the bone over a period of time, not per frame. If you don't specify a time or speed value in the vizact.boneSpinTo command then the change will be instantaneous, whether there is one or more actions in sequence.

fivel_lab 03-11-2016 11:36 AM

OK, thanks for that info, Jeff. That helps a lot. Can you think of any alternatives to using boneSpinTo that you think might fit with what we're trying to do? Are there particular advantages to using boneSpinTo that we might not be able to utilize if we go with, for example, setEuler on each frame?

krimble 08-08-2017 08:03 AM

Hi Jeff,
I'm using vizact.boneSpinTo as well and I'm experiencing problems with it as well.

I would like to have an avatar pointing at a certain location.

Code:

import viz
viz.go()

point = vizact.boneSpinTo('Bip01 R UpperArm',mode=viz.AVATAR_LOCAL,point=viz.MainView.getPosition(),speed=90)

#Add avatar
model = viz.add('vcc_female.cfg',euler=(180,0,0))

def mykeyboard(key):
        if key == " " :
                model.runAction(point)
               
viz.callback(viz.KEYBOARD_EVENT,mykeyboard)


Troubles:
1: The avatar is not pointing at the correct location
2: The avatar is pointing at a different positions while the position of the mainview not changes.

Could you please help me with this?

Best, Jeroen
Max Planck Institute Nijmegen


All times are GMT -7. The time now is 01:23 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC