WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rating: Thread Rating: 8 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-14-2008, 11:08 AM
TrashcanPatrol TrashcanPatrol is offline
Member
 
Join Date: Aug 2008
Posts: 43
Avatar w/ hat cannot look at viewpoint

Hello, I was trying a combination of scripts from tutorials... the first one was the one to bind the hat to an avatar, and the second was to make the avatar look at the viewpoint. My problem is, I can't get them to work at the same time for some reason. :/
Here is the hat code I am using:

Code:
patient=viz.add('vcc_male.cfg')
patient.translate(-5.1,0,8.9)
patient.rotate(0,1,0,180)
patient.state(1)
hat = viz.add('tophat.3ds')
head2 = patient.getBone('Bip01 Head')
HatLink = viz.link(head2,hat)
HatLink.preTrans( [0,0.150,0.01] )
HatLink.preEuler( [0,-10,0] )

toon = viz.add('toon.dlm')
patient.modify(toon)
And here is the look code that I am using:

Code:
#Get a handle to the Neck bone
head = patient.getBone('Bip01 Neck')
head.lock() #Disable automatic bone animation so that we can manually animate it

#Lock the head bone so that manual movement of the neck bone also moves the child head bone
patient.getBone('Bip01 Head').lock()

#Used to rotate the torso when the viewpoint moves to the side of the avatar
torso = patient.getBone('Bip01 Spine1')
torso.lock()


def ontimer(num):
  #Make head look at viewpoint
  viewPOS = viz.MainView.getPosition()
  head.lookat( viewPOS, 0, viz.AVATAR_WORLD ) #points the head and neck at the viewpoint
  #Get neck orientation to see if we need to translate torso
  headOrientation = head.getEuler( viz.AVATAR_LOCAL )


  #Move torso so that the neck does not twist too much
  
  if headOrientation[0] < -90 and headOrientation[0] > -180: # -90 to -180
#Viewpoint in avatar's left-back yaw quadrant
	torso.setEuler( headOrientation[0] + 90, 0, 0, viz.AVATAR_LOCAL )
	#Point head back at view because it is child object and was moved by torso rotation
	head.lookat( viewPOS, 0, viz.AVATAR_WORLD )

  elif headOrientation[0] > 90 and headOrientation[0] < 180: #90 to 180
#Viewpoint in avatar's right-back yaw quadrant
	torso.setEuler( headOrientation[0] - 90, 0, 0, viz.AVATAR_LOCAL )
	#Point head back at view because it is child object and was moved by torso rotation
	head.lookat( viewPOS, 0, viz.AVATAR_WORLD )

	
viz.callback( viz.TIMER_EVENT, ontimer )
viz.starttimer( 1, 0, viz.PERPETUAL )
I hope there's something I can do to fix it... thanks in advance for any advice/tips
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
Collision of an avatar with a quad Frank Verberne Vizard 8 06-04-2008 09:44 AM
Looking through the eyes of an avatar Frank Verberne Vizard 2 04-01-2008 05:52 AM
How to make avatar's eyes to blink when speaking michelcm3 Vizard 12 01-15-2008 08:48 AM
Avatars in an array and link/unlink betancourtb82 Vizard 7 09-05-2006 04:06 PM
VRML Viewpoint error bstankie Vizard 1 03-11-2003 02:10 PM


All times are GMT -7. The time now is 04:16 AM.


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