WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Thread Tools Rate Thread Display Modes
Old 05-07-2008, 09:05 AM
Frank Verberne Frank Verberne is offline
Join Date: Mar 2008
Location: Netherlands
Posts: 148
Eyes that keep looking at the mirror

Hi all,

I'm trying to adjust my experiment so that the avatar that will be animated by a participant will keep looking at the mirror with its eyes. For testing purposes, I tried the 'biohead_eyes.vzf' file for a head with eyes that can move but I just can't seem to get the reflection right (so that the eyes in the mirror are looking at the participant when the participant looks in the mirror). So what I want is that the eyes will keep looking at the mirror even when the head is turned. With the Live Character plugin, the height of the eyes will be automatically adjusted to the height of the head I presume (I'm not sure)? See below for the code so far.
import viz


def addMirror(mirror,mat=None):
	#If mirror matrix is not specifed, get matrix of mirror object
	if mat is None:
		mat = mirror.getMatrix()
	#Position of mirror
	pos = viz.Vector(mat.getPosition())
	#Direction mirror is pointing
	dir = viz.Vector(mat.getForward())
	#Quaternion rotation of mirror
	quat = mat.getQuat()
	#Create render texture
	tex = viz.addRenderTexture()
	#Create render node for rendering reflection
	lens = viz.addRenderNode(size=[1024, 1024]) #set to [1024,1024] in the lab!
	#Setup reflection matrix
	rot = viz.Matrix.quat(quat)
	invRot = rot.inverse()
	#Setup reflection clip plane
	s = -viz.sign(viz.Vector(dir) * viz.Vector(pos))
	plane = vizmat.Plane(pos=pos,normal=dir)
	dist = plane.distance([0,0,0])
	#Project reflection texture onto mirror

gallery = viz.add('gallery.ive')
avatar = viz.add('vcc_female.cfg')
light_avatar = viz.addLight()
face = avatar.face('biohead_eyes.vzf')
l_eye = face.getchild('geom_0')
r_eye = face.getchild('geom_1')

#Mirror surface
mirrorsurface = viz.addTexQuad()
mirrorsurfaceposition = [0, 1.25, .5] #Y,Z,X
mirrorsurfacerotation = [0,0,0] #Z,Y,X
light_mirror = viz.addLight()
light_mirror.direction(mirrorsurfacerotation[0]/180, mirrorsurfacerotation[1]/180, mirrorsurfacerotation[2]/180)
#Apply reflection to mirrorsurface
m = viz.Matrix()
m.setEuler(mirrorsurfacerotation[0]-180,-mirrorsurfacerotation[1], mirrorsurfacerotation[2]) #Z,X,Y

def mytimer(num):
	bone = avatar.getBone('Bip01 Head')
	pos = bone.getPosition()
	r_eye.lookat(1,pos[1],3 ,0,viz.ABSOLUTE_WORLD)
	l_eye.lookat(1,pos[1],3 ,0,viz.ABSOLUTE_WORLD)

Reply With Quote
Old 05-07-2008, 03:42 PM
Jerry Jerry is offline
Join Date: Jun 2004
Posts: 105
I just happen to have worked on that and here's what I
came up with.
Attached Files
File Type: zip (332.7 KB, 1772 views)
Reply With Quote
Old 05-07-2008, 04:38 PM
Jerry Jerry is offline
Join Date: Jun 2004
Posts: 105
Or if you like that other way of reflecting things here's version 2.
Attached Files
File Type: zip (82.0 KB, 1803 views)
Reply With Quote
Old 05-13-2008, 05:39 AM
Frank Verberne Frank Verberne is offline
Join Date: Mar 2008
Location: Netherlands
Posts: 148
Thanks for your scripts, that was what I was looking for. Btw I like te way of mirroring in you first script, but that kind is impossible if the mirror is not on the edge of the environment. That's why I use the other method. Thanks!
Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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
Mirror issues Frank Verberne Vizard 2 04-08-2008 10:37 AM
Looking through the eyes of an avatar Frank Verberne Vizard 2 04-01-2008 05:52 AM
Getting a mirror to work in any environment Frank Verberne Vizard 5 03-27-2008 08:21 AM
Heads with geometries for eyes and mouth Karla Vizard 2 03-14-2008 11:39 AM
Getting access to the eyes of CFG avatars bailenson Vizard 1 06-18-2004 04:55 PM

All times are GMT -7. The time now is 07:46 AM.

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