Hi,
Thanks for the example code. I added 60 degrees to the roll and now it looks better. I did the same experiment with left upper arm, and I had to make a different correction to make it right.
My impression is that the lookat function makes the joint to look at a certain direction and the bone connected to the joint is not in 0 degrees relative to the joint. Am I right? Is it a way to find the exact corrections for each bone?
The code below is the modified code:
Code:
import viz
import vizact
viz.go()
viz.add('tut_ground.wrl')
#Create animating ball
ball = viz.add('white_ball.wrl')
ball.add(vizact.sequence(vizact.goto(1,1.3,2.5),vizact.goto(3,1.3,2.5),viz.FOREVER))
#Create male avatar
avatar1 = viz.add('vcc_male.cfg',pos=(-2,0,3),euler=(180,0,0))
avatar1.state(1)
head1 = avatar1.getBone('Bip01 Head')
head1.lock()
#Create female avatar
avatar2 = viz.add('vcc_female.cfg',pos=(2,0,3),euler=(180,0,0))
avatar2.state(1)
head2 = avatar2.getBone('Bip01 Head')
forearm = avatar2.getBone('Bip01 R Forearm')
arm = avatar2.getBone('Bip01 L UpperArm')
head2.lock()
def UpdateAvatarHead():
"""Update avatars to look at ball position"""
pos = ball.getPosition()
head1.lookat(pos,0,viz.AVATAR_WORLD)
head2.lookat(pos,0,viz.AVATAR_WORLD)
forearm.lookat(pos,0,viz.AVATAR_WORLD)
ori = forearm.getEuler(viz.AVATAR_WORLD)
forearm.setEuler([ori[0] - 90, ori[1], ori[2]+60], viz.AVATAR_WORLD)
arm.lookat(pos,0,viz.AVATAR_WORLD)
ori = arm.getEuler(viz.AVATAR_WORLD)
arm.setEuler([ori[0]+120, ori[1]+60, ori[2]+30], viz.AVATAR_WORLD)
vizact.ontimer(0,UpdateAvatarHead)
viz.MainView.move(2,0,-5)