WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 07-16-2008, 11:27 PM
orizo orizo is offline
Member
 
Join Date: Jul 2008
Posts: 2
animations - trim and blend

Hi,

I have a great animation I am using that was created using motion capture. Because of this I can only use the final CAF file. The thing is, I want to use only a portion of it. I am able to start the animation at different times using setAnimationTime and stopping it when I want using timers or vizact.waittime (is there a simpler way?).
All this is fine except that there is no blending between my cycled animation and the one I use as above.

Is there any way I can blend the beginning and the end of an animation when using setAnimationTime and stopAnimation to make them look smoother?

Thanks,
Ori
Reply With Quote
  #2  
Old 07-21-2008, 11:59 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
The best option is to export only the portion of the animation you want. If you can't do this then you can manually set the weight of the animation every frame by re-executing the animation. This means you would have to calculate the blending weight, but it is definitely possible. Here is a sample script that shows how to do this:
Code:
import viz
viz.go()

male = viz.add('vcc_male.cfg',pos=(0,0,5),euler=(180,0,0))
male.state(4)

ANIMATION = 5 #Animate to blend
BEGIN = 1.0 #Begin time of animation
END = 4.0 #End time of animatoin
BLEND = 0.5 #Blend time of animation

def setAnimation(p):
	
	#Determine absolute animation time
	t = vizmat.Interpolate(BEGIN,END,p)
	
	#Manually calculate weight
	if t < BEGIN + BLEND:
		weight = vizmat.Interpolate(0.0,1.0,(t-BEGIN)/BLEND)
	elif t > END-BLEND:
		weight = vizmat.Interpolate(0.0,1.0,(END-t)/BLEND)
	else:
		weight = 1.0
	
	#Stop previous animation
	male.stopAction(ANIMATION)
	#Re-execute animation at new weight
	male.execute(ANIMATION,weight=weight,delay_in=0,delay_out=0)
	
	#Pause the animatoin and set the time
	male.setAnimationTime(ANIMATION,t)
	male.setAnimationSpeed(ANIMATION,0)

slider = viz.addSlider(pos=(0.5,0.1,0))
vizact.onslider(slider,setAnimation)
Reply With Quote
  #3  
Old 07-27-2008, 01:30 AM
orizo orizo is offline
Member
 
Join Date: Jul 2008
Posts: 2
Thanks a lot! this code works great. I believe I can play with it and find a solution for my problem
Thanks again,
Ori.
Reply With Quote
Reply


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


All times are GMT -7. The time now is 02:50 AM.


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