PDA

View Full Version : Smooth transitions back to animations when unlocking bones


Enlil
03-26-2009, 06:32 AM
Hello,

I am locking the head bone to have an avatar look at an object, but I have run into an issue - when I unlock the bone, the head immediately jumps to an animation position, with no smooth transition. Is there some parameter or function I should be calling to get a smooth transition back into the animation when unlocking a locked bone?

Thanks,
Christian

Jeff
03-26-2009, 01:12 PM
If you find out the head orientation at the start of the animation cycle, for example, then when you want the avatar to stop looking at an object, use vizact.headto to smoothly move the head to the starting position. Once its reached that position wait until the start of the next cycle and unlock it.

Enlil
04-01-2009, 07:44 AM
Thanks.

Is there a good way to find the head orientation at the start of an animation cycle?

Christian

Gladsomebeast
04-01-2009, 07:24 PM
To find out what orientation the animation has the head at unlock the bone, then call bone.getEuler(), then lock the bone again.

Also, I think it might be a bit more complicated than getting the bone orientation then calling vizact.headto(). This is because the head orientation will have changed by the time the headto action is done.

You could manually blend the head back. The vizmat.interpolate fuction will come in handy. It could go something like the following fake code:


while not isDone:
currentEuler = bone.getEuler()
bone.unlock()
targetEuler = bone.getEuler()
bone.lock()
eulerBlendy = vizmat.interpolate(currentEuler, targetEuler, percentDone)
bone.setEuler(eulerBlendy)