View Single Post
  #2  
Old 03-14-2008, 11:31 AM
Karla Karla is offline
Member
 
Join Date: May 2007
Posts: 12
bailenson suggested a texture solution.
I made the below arbitrary example (edited .jpg file attached) after following this thread:
<http://www.worldviz.com/forum/showthread.php?t=776&highlight=texture+avatar>

I see now how different textures can be put on the avatars to look like the eyes are moving (if the .jpg on the head has eyes that are looking left/right/etc. from edits using image software like Paint/Photoshop/etc.).

If anyone has answers to may first post above, I welcome them.

Thanks,
Karla

Code:
#March 14th, 2008
import viz
import vizinfo	#For info box
import viztask 	#For wait time

viz.go()

#Add a female face
female = viz.add('female.cfg')
female.translate(0,0,2)
female.rotate(0,1,0,180)
female.state(1) #Neutral state of the female avatar 
#To control the eyes, the name of the left and right eyes are geom_0 and geom_1
face = female.face('biohead_eyes.vzf')
l_eye = face.getchild('geom_0')
r_eye = face.getchild('geom_1')

#Add a male face
male1 = viz.add('male.cfg')
male1.translate(-0.65,0,2)
male1.rotate(0,1,0,180)
male1.state(1) #Neutral state of the female avatar 
Mface1 = male1.face('biohead_talk.vzf')#Add a face to the avatar
texture1 = viz.add('bioexample_0.jpg')	#regular face, eyes front and center
texture2 = viz.add('bioexample_0_changeEyes.jpg') #modified face, 'eyes' to left


#We have control of the eyes we need to have them look at something.
#Add a ball that moves around.
ball = viz.add('ball.wrl')
ball.translate(0.5,1.7,1.5) 
ball.scale(0.2,0.2,0.2)

#Simply create an infinite timer that updates the rotation of the eyes
#so that they are looking at the balls position.
def mytimer(num):
  pos = ball.get(viz.POSITION)
  r_eye.lookat(pos,0,viz.ABSOLUTE_WORLD)
  l_eye.lookat(pos,0,viz.ABSOLUTE_WORLD)
 
viz.callback(viz.TIMER_EVENT,mytimer)
viz.starttimer(0,0.01,viz.FOREVER)

def moveBall():
	yield viztask.waitTime(3)		#Wait 3 seconds
	ball.translate(-0.5,1.7,1.5) 
	ball.scale(0.2,0.2,0.2)
	Mface1.texture(texture2)
	texture2.wrap(viz.WRAP_S,viz.REPEAT)
	texture2.wrap(viz.WRAP_T,viz.REPEAT)
	yield viztask.waitTime(3)		#Wait 3 seconds
	ball.translate(-0.5,1.5,1.5) 
	ball.scale(0.2,0.2,0.2)
	Mface1.texture(texture1)
	texture1.wrap(viz.WRAP_S,viz.REPEAT)
	texture1.wrap(viz.WRAP_T,viz.REPEAT)
	yield viztask.waitTime(5)		#Wait 5 seconds
	ball.translate(0,1.5,1.25) 
	ball.scale(0.2,0.2,0.2)
	Mface1.texture(texture2)
	texture2.wrap(viz.WRAP_S,viz.REPEAT)
	texture2.wrap(viz.WRAP_T,viz.REPEAT)
		
viztask.schedule( moveBall() )
Attached Thumbnails
Click image for larger version

Name:	bioexample_0_changeEyes.JPG
Views:	1256
Size:	42.6 KB
ID:	226  
Reply With Quote