View Single Post
  #6  
Old 10-05-2020, 04:41 PM
kennethkarthik kennethkarthik is offline
Moderator
 
Join Date: Jul 2018
Posts: 7
Hey Roy,

Vizard does it's optimisation when it reuses objects. However if you do want to improve load time, I would suggest just changing the state of your characters on the same avatar instead of adding a new one for each animation state. Check out the code below

Code:
import viz
import random
import viztask

avatar_files = ['vcc_male.cfg', 'vcc_female.cfg']#2avatars
animation = range(0,16)  #default 15 animations

viz.go()

piazza = viz.addChild('piazza.osgb')


#make 30 stimuli list (2 avatars x 15 animations), and shuffle the order
avatars = []
for i in avatar_files:
	avatarAnim = viz.addAvatar(i, pos=(0,0,0), euler=(180,0,0))
	avatarAnim.visible(viz.OFF)
	avatars.append(avatarAnim)
	
def experiment():
	yield viztask.waitKeyDown(viz.KEY_RETURN)
	for i in avatars:
		i.visible(viz.ON)
		for state in animation:
			yield viztask.waitTime(0.5)
			i.state(state)
			yield viztask.waitKeyDown(viz.KEY_RETURN)
		i.visible(viz.OFF)

viztask.schedule(experiment())
Reply With Quote