2
$\begingroup$

I've read the reference guide about the file but I am really confused. Why the hell are there "min" and "max" values ?? A single vertex has only one coordinate array not min and max..

Also in the structure of the meshes why is there an "indices" reference to the "accessors" if we already put the indices to the "attributes" like "NORMAL: 2"?

$\endgroup$
1
$\begingroup$

The min and max values provide an outer bounding box for all POSITION data within a given accessor. Accessors typically contain multiple vertices, for example all of the vertices of a particular primitive, and then min: [x, y, z] and max: [x, y, z] will offer the bounding box for that primitive.

For your second question, let's look at the mesh structure from BoxTextured.gltf:

"meshes": [
    {
        "primitives": [
            {
                "attributes": {
                    "NORMAL": 1,
                    "POSITION": 2,
                    "TEXCOORD_0": 3
                },
                "indices": 0,
                "mode": 4,
                "material": 0
            }
        ],
        "name": "Mesh"
    }
],

In the above example, mode: 4 is an enum, where 4 means TRIANGLES. The indices are stored in accessor 0, and the POSITION data is stored in accessor 2. So, accessor 2 will contain a list of vertex positions, but each vertex is allowed to be referenced by multiple triangles. The indices in accessor 0 declare the triangles by indexing into the list of vertices.

Here's a sample of the start of accessor 0 from this model:

0 
1 
2 

3 
2 
1 

4 
5 
6 

7 
6 
5 
...

And this is a sample of the contents from the start of accessor 2 in this model:

-0.50000    -0.50000     0.50000 
 0.50000    -0.50000     0.50000 
-0.50000     0.50000     0.50000 
 0.50000     0.50000     0.50000 
 0.50000     0.50000     0.50000 
 0.50000    -0.50000     0.50000 
 0.50000     0.50000    -0.50000 
 0.50000    -0.50000    -0.50000 
 ...

In this manner, the sample model builds a cube by winding triangles around vertices at the corners.

For a more graphical explanation of this, check out the glTF Overview Card.

$\endgroup$
  • $\begingroup$ Thank you for your answer ! But now I would like to ask if the min and max values are just bounding boxes, where the actual coords of the vertices ? $\endgroup$ – Vettel.Sebastian Apr 17 '18 at 20:43
  • $\begingroup$ glTF stores the actual mesh data in a binary chunk. This can be delivered a number of ways: As a separate .bin file, as a base64-encoded blob inside the JSON, or as a binary section of a .glb file. Each accessor points to a bufferView, and typically each bufferView references a buffer with a single binary data blob. So, the accessors and bufferViews act to slice portions of data out of the binary blob. $\endgroup$ – emackey Apr 17 '18 at 21:24
  • $\begingroup$ Thanks again, so I need to look for the coordinates in the binary file somehow. $\endgroup$ – Vettel.Sebastian Apr 18 '18 at 5:17
  • $\begingroup$ How did you get the values from the acessors ? $\endgroup$ – Vettel.Sebastian Apr 18 '18 at 9:46
  • $\begingroup$ I'm using the glTF Extension for VSCode (Disclaimer, I'm a contributor). Place the cursor inside an accessor block and press ALT+D to decode the binary. $\endgroup$ – emackey Apr 18 '18 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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