Are gltf animations of type vec4 ever not quaternions?

Viewed 103

I am trying to make my own gltf loader, and I am dealing with animations.

I have the first basic triangle example that makes it rotate. One thing I noticed is that these are the defined types for a gltf file:


#define TINYGLTF_TYPE_VEC2 (2)
#define TINYGLTF_TYPE_VEC3 (3)
#define TINYGLTF_TYPE_VEC4 (4)
#define TINYGLTF_TYPE_MAT2 (32 + 2)
#define TINYGLTF_TYPE_MAT3 (32 + 3)
#define TINYGLTF_TYPE_MAT4 (32 + 4)
#define TINYGLTF_TYPE_SCALAR (64 + 1)
#define TINYGLTF_TYPE_VECTOR (64 + 4)
#define TINYGLTF_TYPE_MATRIX (64 + 16)

More importantly, since all the data is stored as raw buffers, the only information you get about a given model is whether it has animations or not, there doesn;t seem to be afield that explains "this data over here is for rotating the mesh, this one over here is for translating it".

This leads me to the question. Is there any circumstances where a primitive in a mesh has declared an animation, the output animation buffer is of type vec4 but it is not representing quaternion rotations?

And if it is possible to have non quaternion types for an animation buffer, how do I know when the buffer is a rotation and when it is a different type?

1 Answers

A glTF file does specify which properties are affected by each animation channel, but you would need to look it up in the reverse order. In pseudocode:

for anim of gltf.animations
  for channel of anim.channels
    sampler = anim.samplers[channel.sampler]
    print "Accessor #" + sampler.output + " modifies " + channel.path
    # → "Accessor #123 modifies rotation"

According to the channel.path table in the glTF specification, there are no animation types except rotation that currently use the VEC4 type, but it would be better to use the channel.path information, in case other types of animation are supported in the future.

Related