glTF – loading animation clips
To generate pose data at runtime, you need to be able to load animation clips. As with the rest pose, this requires a few helper functions.
The first helper function you need to implement, GetScalarValues, reads the floating-point values of a gltf accessor. This can be done with the cgltf_accessor_read_float helper function.
The next helper function, TrackFromChannel, does most of the heavy lifting. It converts a glTF animation channel into a VectorTrack or a QuaternionTrack. glTF animation channels are documented at https://github.com/KhronosGroup/glTF-Tutorials/blob/master/gltfTutorial/gltfTutorial_007_Animations.md.
The LoadAnimationClips function should return a vector of clips objects. This isn't optimal; it's done to make the loading API easier to use. If performance is a concern, consider passing the result vector as a reference.
Follow these steps to load animations from a glTF file:
- Implement the
GetScalarValues...