glTF format questions - byte order and primitive index/attribute relationship

Hello,

I have two questions about glTF format:

  1. What is the byte order when reading short/int/float values from the buffer? I could not find any info on this online.

  2. What is the relationship between indices (in mesh/primitive) and attributes? If I have two attributes, say POSITION and NORMAL, how many indexes per vertex will there be, and what will be the order of those?

Thanks!

  • little endian, see glTF 2.0 spec, search for ‘endian’.
  • the format is intended to be straightforward to feed into graphics APIs and they all only support a single index per vertex that is used for all active vertex attributes.

Thank you for that info, I searched online for “endian” and “gltf” but nothing came up.

Just to clarify the second part, does that mean that all attribute lists (positions, normals, texture coordinates, etc.) are always of the same size in glTF meshes?

Thanks!

I wrote a test program and it looks like each attribute list has the same number of elements, so that’s that. But I’d like to find out what happens if index list is empty? It looks like that is allowed, at least according to glTF spec. Would it be safe to assume that (for the default primitive type = triangle) each attribute list (position, normal, etc.) would contain replicated data for each vertex, three vertices per face?

Thanks!

No indices is equivalent to having indices [0, N-1] where N is the length of the vertex attributes, so for triangle lists the first triangle consumes the first three elements from each vertex attribute, the second triangle the next three and so on.

Thank you for your help, I am now able to load gltf meshes and display them using LWJGL. Moving on to animation =)