JiggleBone

Name:  JiggleBone v.1.0. Author: Michael Cook (Fishypants) Date:  9-25-2011

Description
This script will add a secondary jiggle motion to bones. (bouncy breast dynamics, hair, etc) It uses a very crude physics model to approximate the rotation of the bones, with optional squash and stretch. I modified Pegorari's Rubber Simulation Script as the basis for the dynamics.

How it works
The implementation is very simple. Instead of trying to figure out angular velocity, and a bunch of other crazy math stuff we simply goal a dynamic point to a target point, then we orient the bone to the dynamic point. The screenshot above illustrates this.

So for the bone, we calculate the up axis (green). Then we calculate the forward axis (blue) with extra length based off "targetDistance". You will need to adjust the target distance if your bones keep flipping, and push it further away from the bone. Then we calculate the "target" (yellow).

All these values remain locked to the bone and do not change. They update their orientation based on the bone's orientation.

Then we calculate "dynamicPos". Using mass, acceleration, velocity, damping, we try to push this point to the target point. It's very similar to the "Lerp" command, but differs in the fact that we incorporate physics based values. So instead of just going from 1 point to another, "dynamicPos" has the ability to overshoot the target, then bounce back until finally it comes to rest.

If you notice that the red target is not in line with the yellow target, this is because of gravity. You can disable it if you like, but it helps to add some realism.

Once the "dynamicPos" has been established we simply use the "LookAt" function to orient the bone to the "dynamicPos" point.

Simple, eh? :)

End
Created by Michael Cook (Fishypants). If you have any questions just ask!