Lets say that you have two animation files: anim_run.dae
and anum_aim.dae
. The former holds a running animation and the latter holds an aiming animation where the skeleton has one of it's arms raised (as if it is aiming a gun). The two animations belong to a specific character. That character can run, aim, and aim while running. Combining the running animation and the aiming animation to create the third one is actually very simple. Allow me to explain:
Say that you have an skeleton whose bone structure looks like this:

In the run animation you are using all the bones of the skeleton to make the character run. In the aim animation, the only part of the skeleton that is animated is the right arm (i.e. r_arm0
and r_amr1
). At this point I should clarify that the same skeleton is used in both animations.
In order to create the 'run while aiming' animation you could use the run animation as a basis, and mark which bones need to be animated using the aim animation instead of the running animation. In the example above you would have to mark the r_arm0
and r_amr1
bones in order to achieve this.
This system is simple but has a very important catch: You need to be careful with the way you apply transformations to the bones that have the aiming animation. If you just use the transformations that are given in the collada file, then the resulting animation will look weird. The arm will be stationary and aiming while the rest of the body will be moving, and thus the arm will appear to be 'flying'. This obviously ruins the animation and looks terrible. You will have to apply some kind of transformation to the r_arm0
bone in order to make it follow the movement of the body. (since this transformation is applied to r_arm0
it will also be applied to all of its children, which in this can is r_arm1
).
You can make this even more advanced by adding an 'alpha' value to each bone. The 'alpha' value is simply a number between 0.0 and 1.0 that can be used to blend the two animations together. For example, if r_arm0
has a alpha value of 0.0 only the running animation will be applied to it, when its alpha value is 1.0 only the aiming animation will be applied to it, and when its alpha value is 0.5 both animations will be applied.