WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-31-2008, 10:19 AM
Frank Verberne Frank Verberne is offline
Member
 
Join Date: Mar 2008
Location: Netherlands
Posts: 148
Looking through the eyes of an avatar

In my experiment, I want participants to see the world through the eyes of an avatar. Therefore, I linked het headbone of the avatar and the Mainview to the same tracker. This works great, but not perfect yet. The problem is that the MainView is inside the head of the avatar. When I update the position of the link MainView-tracker with the position of the headbone and I set that position 11 cm further on the X-axis, then it is solved when participants look one direction. However, when they turn their heads 180 degrees (look the other way), the view is translated to the back of the head of the avatar. So what I would like is the MainView to be in front of the eyes of the avatar (not INSIDE its head) no matter where the participant looks at. How can I do that? I hope my question is clear, the code below should make things clearer.
Code:
#Link all bones to trackers of pp1
def updateBones_pp1():
	for i in range(0, len(link_bones_pp1)):
		if link_bones_pp1[i] != 'None':
			bone = avatar.getBone(link_bones_pp1[i])
			euler = tracker[i].getEuler()
			bone.setEuler(euler,viz.AVATAR_WORLD)
			if link_bones_pp1[i] == 'skel_Head01':
				pos = tracker[i].getPosition()
				link.setPos([0,0,pos[2]+.11])

#Depending on the subjectnumber, create an avatar and set the position of the viewpoint.
if subject != '':
	condition = int(subject)%4
	if condition == 0 or condition == 1: 		     #Condition 4 or 1
		global link
		link = viz.link(tracker[19], viz.MainView)   #Link MainView to headtracker
		avatar = viz.add(avatarlist[condition])      #Avatar = Dutch for condition 4 and Moroccan for condition 1
		lock_all_bones(avatar)
		avatarLink(avatar, 1)
		vizact.ontimer(0,updateBones_pp1)			 #Update linkbones
	elif condition == 2 or condition == 3: 			 #Condition 2 or 3
		avatar = viz.add(avatarlist[condition-2])    #Avatar = Dutch for condition 2 and Moroccan for condition 3
		viz.MainView.setPosition(0,1.90,-5.5)		 #(Y,Z,X) third person perspective
	viz.MainView.getHeadLight().disable()
	light_avatar = viz.addLight()
else:
	print 'Geen proefpersoonnummer ingevuld! Dit is de testmode!'
	avatar = viz.add(avatarlist[0])
	lock_all_bones(avatar)
	avatarLink(avatar,1)
	vizact.ontimer(0,updateBones_pp1)
avatar.scale(0.33,0.33,0.33)
light_mirror = viz.addLight()
light_mirror.position(0,0,3,0)
Reply With Quote
  #2  
Old 03-31-2008, 12:27 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You will need to use the link.preTrans operator to offset the link position. For example, if the the eyes of the avatar are 4 centimeters forward from the head position then you would use the following code:
Code:
link = viz.link(headBone,viz.MainView)
link.preTrans([0,0,0.04])
Reply With Quote
  #3  
Old 04-01-2008, 05:52 AM
Frank Verberne Frank Verberne is offline
Member
 
Join Date: Mar 2008
Location: Netherlands
Posts: 148
Thanks again farshizzo! Now it works perfectly.
Reply With Quote
Reply

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
Heads with geometries for eyes and mouth Karla Vizard 2 03-14-2008 11:39 AM
avatar neck too short aa-chris Vizard 2 10-16-2007 09:28 AM
Avatars in an array and link/unlink betancourtb82 Vizard 7 09-05-2006 04:06 PM
avatar animations vduckie Vizard 12 02-27-2006 01:32 PM
Problems with 3DMeNow Avatar Heads kim_swinth Vizard 9 11-19-2003 02:14 PM


All times are GMT -7. The time now is 01:22 PM.


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