Game Development Reference
In-Depth Information
"faces": [42,0,1,2,0,0,1,2,0,0,0,42,3,2,4,0,3,2,4,1,1,1,42,5,4,7,0,5,
4,6,2,2,2,42,1,0,6,0,7,8,9,3,3,3,42,1,6,4,0,1,10,11,4,4,4,42,7,0,5,0,
12,0,13,5,5,5,42,3,0,2,0,3,0,2,0,0,0,42,5,3,4,0,5,3,4,1,1,1,42,4,6,7,0
,4,9,6,2,2,2,42,0,7,6,0,8,6,9,3,3,3,42,2,1,4,0,2,1,11,4,4,4,42,0,3,5,0
,0,3,13,5,5,5]
}
We see three new entries in this JSON file. Apart from the regular vertices and
normals array, we notice a new uvs array. It is a simple one dimensional array with
each pair defining one texture or one UV coordinate. Also, notice the materials
array, which has one material defined, with a new entry of mapDiffuse that refers to
the diffuse map image, boxDiffuse.jpg .
The faces array looks a little different now from what we saw in Chapter 2 , Colors
and Shading Languages . It starts with a value of 42 . If we remember from Chapter 2 ,
Colors and Shading Languages , the first value of the array defines the structure of the
faces of each cube, so let's dive deep into it.
Let's first convert 42 into binary, which is 00101010. Starting from the last digit, we
have listed what each bit means:
Digit
Denotes
Meaning
0
isQuad
The digit value 0 means it is not a quad, but a triangle.
Three elements will give vertex indices of the face.
1
hasMaterial
The digit value 1 means we have a material associated
with the polygon. Hence, the fourth value would give
us the material index.
0
hasFaceUV
The JSON format stores the UV coordinate per face or
per vertex. If it is per face, we call it a face UV. This
essentially conveys that all the vertices of the face map
to the same UV coordinate.
1
hasFaceVertexUV
The digit value of 1 means that the next two values
will give the texture coordinates (UV).
0
hasFaceNormal
The digit value of 0 means that there is no face normal.
1
hasFaceVertexNormal The digit value of 1 means that the next three values
will give normal values for the vertices.
hasFaceColor
0
The digit value of 0 means that there is no face color.
0
hasFaceVertexColor
The digit value of 0 means that there is no face
vertex color.
So let's sum it up; three values for the vertex index, one value for the material index,
two values for the texture index, and three values for the normal index. A total of one
(to define the structure) plus nine values will define a face for this particular JSON file.
Search WWH ::




Custom Search