WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 01-22-2016, 04:02 PM
fivel_lab fivel_lab is offline
Member
 
Join Date: Mar 2011
Posts: 28
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
  #2  
Old 01-22-2016, 04:10 PM
fivel_lab fivel_lab is offline
Member
 
Join Date: Mar 2011
Posts: 28
I should also mention that the code above is from the update function of a custom action...
Reply With Quote
  #3  
Old 01-23-2016, 11:34 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,324
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.
Reply With Quote
  #4  
Old 02-29-2016, 05:35 PM
fivel_lab fivel_lab is offline
Member
 
Join Date: Mar 2011
Posts: 28
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..
Reply With Quote
  #5  
Old 03-01-2016, 09:33 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,324
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?
Reply With Quote
  #6  
Old 03-07-2016, 02:26 PM
fivel_lab fivel_lab is offline
Member
 
Join Date: Mar 2011
Posts: 28
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!!
Reply With Quote
  #7  
Old 03-07-2016, 09:27 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,324
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.
Reply With Quote
  #8  
Old 03-11-2016, 12:36 PM
fivel_lab fivel_lab is offline
Member
 
Join Date: Mar 2011
Posts: 28
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?
Reply With Quote
  #9  
Old 08-08-2017, 08:03 AM
krimble krimble is offline
Member
 
Join Date: Nov 2006
Location: Nijmegen
Posts: 59
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
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble Exporting OSGB Animations via Sequence Helper (3Ds Max) envi253 Vizard 1 06-05-2015 11:31 AM
osg Sequence TarkaDahl Vizard 4 09-01-2011 01:45 AM
how to freeze sequence of actions dwaik Vizard 1 04-05-2010 01:26 PM
stopping a sequence durf Vizard 1 04-14-2009 01:31 PM
Weird lagging/choppiness when avatars perform actions vjonshih Vizard 8 11-30-2004 05:08 PM


All times are GMT -7. The time now is 06:57 AM.


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