View Single Post
  #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