#1
|
|||
|
|||
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) 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 ) |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Collision of an avatar with a quad | Frank Verberne | Vizard | 8 | 06-04-2008 10:44 AM |
Looking through the eyes of an avatar | Frank Verberne | Vizard | 2 | 04-01-2008 06:52 AM |
How to make avatar's eyes to blink when speaking | michelcm3 | Vizard | 12 | 01-15-2008 09:48 AM |
Avatars in an array and link/unlink | betancourtb82 | Vizard | 7 | 09-05-2006 05:06 PM |
VRML Viewpoint error | bstankie | Vizard | 1 | 03-11-2003 03:10 PM |