1
\$\begingroup\$

I have been able to implement a pipeline in OpenGL which reads Collada files and can animate them through interpolating the keyframes. However, as somebody brand new to graphics, I don't quite know how one would go about doing individual joint animation.

For example, if I have a sprite and I would like to move just their arm joint, none of that animation information is stored in a Collada file. How would I go about making a system that can move each joint independently?

\$\endgroup\$
2
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ I'm currently in the same place as OP, when it comes to implementing skeletal animation. How could we mark which bones that should be a affected by a certain animation? \$\endgroup\$ – Daniel_1985 Dec 18 '18 at 6:12
  • 1
    \$\begingroup\$ @Naith You could specify which nodes are marked in the collada file using some kind of vertex attribute. However, I do not recommend it. What I would recommend is to put all the bones you want to mark in an array in your source code. There are a few advantages to doing it this way, one of which is that this way you can change which bones are marked depending on some condition. \$\endgroup\$ – JasonPh Dec 18 '18 at 11:15

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.