WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 09-28-2020, 11:54 PM
kennethkarthik kennethkarthik is offline
Moderator
 
Join Date: Jul 2018
Posts: 8
Hi Roy,

There was just a bug in your code. You were setting "avatarAnim" to visible off and on states in your experiment function instead of using "trial" which would iterate between your shuffled states.

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
stimulus = []
for i in avatar_files:
	for j in animation:
		avatarAnim = viz.addAvatar(i, pos=(0,0,0), euler=(180,0,0))
		avatarAnim.state(j)
		avatarAnim.visible(viz.OFF)
		stimulus.append(avatarAnim)
print(stimulus)
random.shuffle(stimulus)
print(stimulus)

def experiment():
	yield viztask.waitKeyDown(viz.KEY_RETURN)
	for trial in stimulus:
		yield viztask.waitTime(1)
		trial.visible(viz.ON)
		yield viztask.waitKeyDown(viz.KEY_RETURN)
		trial.visible(viz.OFF)

viztask.schedule(experiment())
Check this and let us know if this was your intended experiment. Thanks
Reply With Quote
  #2  
Old 10-04-2020, 02:36 AM
Roy Roy is offline
Member
 
Join Date: Dec 2019
Posts: 12
Hi kennethkarthik,

Thank you, it works!
But I'm wondering any other way to add avatars.
In this program, 2 avatars are loaded 15 times, causing long time to run the program.
Any ideas?

Thanks
Reply With Quote
  #3  
Old 10-05-2020, 03:41 PM
kennethkarthik kennethkarthik is offline
Moderator
 
Join Date: Jul 2018
Posts: 8
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
Reply

Tags
avatars, avatars animation


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Regarding the visibility of avatars SivaKartheek Vizard 2 01-13-2016 07:48 AM
Randomly and Continuously Change Avatar's Face Texture Karla Vizard 4 08-22-2008 12:14 PM
avatars dig Vizard 4 09-20-2007 03:29 PM
adding heads to custom avatars vAlexia Vizard 5 02-13-2007 11:14 AM
Avatars in an array and link/unlink betancourtb82 Vizard 7 09-05-2006 04:06 PM


All times are GMT -7. The time now is 03:43 PM.


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