View Single Post
  #4  
Old 10-16-2013, 01:26 AM
Frank Verberne Frank Verberne is offline
Member
 
Join Date: Mar 2008
Location: Netherlands
Posts: 148
Okay, I'm pretty sure the eyelids are not moved by bones. I've tried recording a little piece of one of the standard animations of the sample HD character, with blinking included. Uncomment vizact.onexit(saveTrackingData) to enable saving. Warning: the resulting file gets big (for a .log file) fast:
Code:
import viz
import vizact
import cPickle

viz.go()

avatar = viz.add('vcc_male2.cfg', pos = [0,.15,.25], euler = [180,0,0])
avatar.state(1)
boneList = []
boneNameList = []

for bone in avatar.getBoneList():
	boneList.append(bone)
	boneNameList.append(bone.getName())

global bone_info, total_info
bone_info = []
total_info = []

def updateBoneInfo():
	global bone_info, total_info
	for bone in boneList:
		bone_info.append(bone.getName())
		bone_info.append(bone.getEuler())
	total_info.append(bone_info)
	bone_info = []

vizact.ontimer(viz.FASTEST_EXPIRATION, updateBoneInfo)

BONE_DATA = open("Recording_of_bones.log", 'w+') 

def saveTrackingData(): 
	global total_info
	cPickle.dump(total_info, BONE_DATA) 
	BONE_DATA.flush() 
	BONE_DATA.close() 

#vizact.onexit(saveTrackingData)
Then, I played back the recordings on the same avatar, and the whole animation is played back, EXCEPT for the blinking (press the b-key for playback if the previous code is used to create a short recording):
Code:
import viz
import vizact
import viztask
import cPickle
from collections import deque 

viz.go()

avatar = viz.add('vcc_male2.cfg', pos = [0,.15,.25], euler = [180,0,0])
boneList = []
boneNameList = []

for bone in avatar.getBoneList():
	boneList.append(bone)
	boneNameList.append(bone.getName())

for bone in boneList:
	bone.lock()
	
BONE_DATA = open("Recording_of_bones.log", 'r') 

def setBones():
	total_info = deque(cPickle.load(BONE_DATA)) 
	yield viztask.waitDraw()
	while len(total_info) > 0:
		line = line = deque(total_info.popleft())
		while len(line) > 0:
			boneName = line.popleft()
			boneOrientation = line.popleft()
			if boneName in boneNameList:
				index = boneNameList.index(boneName)
				boneList[index].setEuler(boneOrientation)
			else:
				print 'bone not found on character!'
		yield viztask.waitDraw()

def onKeyDown(key):
	if key in 'bB':
		viztask.schedule(setBones)

viz.callback(viz.KEYDOWN_EVENT,onKeyDown)
So that would rule out any bone involvement in blinking of the eyes. Any other suggestions?
Reply With Quote