Thanks for the suggestion. It works for quad objects but not for the avatar's face.
The avatar's face becomes blacked out when the texture is applied. There seems to be a difference between applying a texture to an avatar's face and applying it to other objects. I am having a similar problem as in post
http://www.worldviz.com/forum/showthread.php?t=776
Using 'texture.wrap(viz.WRAP_S,viz.REPEAT), texture.wrap(viz.WRAP_T,viz.REPEAT),' applies the texture correctly to the avatar's face. Therefore, it is not blacked out when using 'wrap.'
How can I incorporate 'wrap' with the random texture application? An error message said "'ActionData' object has no attribute 'wrap'."
Thanks,
Karla
[/CODE]
Code:
#August 22nd, 2008
import viz
viz.go()
#Orient view to look at avatar
mv_x = 0; mv_y = 1.78; mv_z = -1.0; viz.MainView.setPosition(mv_x,mv_y,mv_z)
mv_euler_x = 180; mv_euler_y = 0; mv_euler_z = 0; viz.MainView.setEuler(mv_euler_x,mv_euler_y,mv_euler_z)
#Create avatar for displaying texture
character1 = viz.add('male.cfg'); character1.translate(0,0,-1.4572); character1.rotate(0,1,0,0); character1.state(1) #Neutral state of avatar
face1 = character1.face('M-0327.vzf') #add a face to the avatar
eyes_center = viz.add('M-0327_eyes_Center.jpg'); face1.texture(eyes_center); eyes_center.wrap(viz.WRAP_S,viz.REPEAT); eyes_center.wrap(viz.WRAP_T,viz.REPEAT)
#TRYING TO DEFINE A SEQUENCE THAT RANDOMLY CHANGES THE TEXTURE ON THE AVATAR'S FACE
#Intention: Make a Sequence that Waits 2-6sec., Randomly changes gaze, Repeats
#Use 4 positions (Left, Right, Center, and Up) to create different Eye Contact
#List of texture filenames
files = ['M-0327_eyes_Left.jpg','M-0327_eyes_Right.jpg','M-0327_eyes_Center.jpg','M-0327_eyes_Up.jpg']
#List of texture objects
textures = [ viz.addTexture(f) for f in files ]
#Create action that randomly waits between 2-6 seconds
waitTime = vizact.waittime( vizact.randfloat(2.0,6.0) )
#Create action that randomly applies texture from list above
randomTexture = vizact.texture_node( vizact.choice(textures,vizact.RANDOM) )
#Create sequence that repeats above actions indefinitely
my_action = vizact.sequence( waitTime, randomTexture, viz.FOREVER )
#Add action to avatar
face1.addAction(my_action)
#ERROR: Avatar's face is Blacked-out; need to set texture to repeating mode
#Try setting texture to repeating mode
#files = ['M-0327_eyes_Left.jpg','M-0327_eyes_Right.jpg','M-0327_eyes_Center.jpg','M-0327_eyes_Up.jpg']
#textures = [ viz.addTexture(f) for f in files ]
#waitTime = vizact.waittime( vizact.randfloat(2.0,6.0) )
#randomTexture = vizact.texture_node( vizact.choice(textures,vizact.RANDOM) )
#my_action = vizact.sequence( waitTime, randomTexture, randomTexture.wrap(viz.WRAP_S,viz.REPEAT), randomTexture.wrap(viz.WRAP_T,viz.REPEAT), viz.FOREVER )
#face1.addAction(my_action)
#ERROR: Message says 'ActionData' object has no attribute 'wrap'