jkuhlmann / cgltf

:diamond_shape_with_a_dot_inside: Single-file glTF 2.0 loader and writer written in C99
MIT License
1.42k stars 135 forks source link

Based on the current node, how to find out the bufferView number? #251

Open native-engine opened 4 months ago

native-engine commented 4 months ago

In a function that takes the current node as input argument, how can I find out the number of the "bufferView" belonging to it? In the gltf file the number is simply specified: «"accessors":[ { "bufferView":0» but the parser already refers to the "bufferView" itself (node->mesh->primitives->indices->buffer_view) and does not allow to find out its number in order to correctly refer to other data, e.g. "accessor", by this number. So far, I've done this: int iBufferView = (node - data->scene->nodes[0]) * 4; but I doubt it's fair to the children.

native-engine commented 4 months ago

That's kind of more correct: int iBufferView = node->mesh->primitives->indices->buffer_view - data->accessors->buffer_view - 3;