View Single Post
  #1  
Old 04-23-2009, 10:56 AM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
Vizard tech tip: Blinking Avatars

Vizard's vcc avatars come with morph targets for blinking, eyebrow raising, and talking. Check out the following snippet of code to get your avatars to blink.

Code:
import viz
viz.go()

female = viz.add('vcc_female.cfg', pos = [0,.3,1], euler = [180,0,0])
female.state(1)

#Blink morph ID of avatar
BLINK_MORPH = 0

#Action that will animate blink closing
close_eye = vizact.morph(BLINK_MORPH,1,.1)

#Action that will animate blink opening
open_eye = vizact.morph(BLINK_MORPH,0,0.1)

#Action that will wait 1-5 seconds
wait_blink = vizact.waittime(vizact.randfloat(1,5))

#Action that will blink indefinitely
blinkAction = vizact.sequence( wait_blink, close_eye, open_eye, viz.FOREVER )

female.addAction(blinkAction)
Try changing this code to move the eyebrows. The morph targets are listed in the vcc_avatars .cfg files. When specifying the morph id use the number order it appears in the list of morphs, beginning with 0. So to use the eyebrow morph in Vizard you would set
Code:
EYEBROW_MORPH = 1
In order to run two actions in parallel, like blinking and eyebrow raising make sure you add the actions to different action pools. The documentation explains how action pools work. In the following line of code the blink action is added to action pool 1. If the pool is not specified, by default, the action will be added to pool 0.
Code:
female.addAction(blinkAction, pool = 1)
Reply With Quote