Game Development Reference
In-Depth Information
The first element can be one of the elements present in the following table:
Value
Binary format
Description
0
00000000
This face is a triangle, and the next three values will be
its vertices.
1
00000001
This is a quad. Hence, the next four elements will be
vertices of a quad.
2
00000010
As the last bit is 0, it is a triangle, and the second bit
is 1 which means it will face the material index. The
first three values will denote the vertex indices (of
the earlier vertex array), and the next value will give
the material index of the material array ( v1 , v2 , v3 ,
materialIndex ). Each element of the material array
has information (specular, diffuse, ambient, and so on)
of the material used on the object.
3
00000011
As the last bit is 1, it is a quad, and the second bit is
1 which means it will face the material index. Hence,
we will read the next five elements ( v1 , v2 , v3 , v4 ,
materialIndex ).
4
00000100
As the last bit is 0, it is a triangle. The second bit is 0
(no material) and the third bit is 1, which means it has
a face UV. Hence, we will read the next four elements
( v1 , v2 , v3 , faceUVIndex ).
The following code snippet is taken from a .json file. It shows different data
elements and their corresponding meanings:
"faces": [
// triangle
// 00 00 00 00 = 0
// 0, [vertex_index, vertex_index, vertex_index]
0, 0,1,2,
// quad
// 00 00 00 01 = 1
// 1, [vertex_index, vertex_index, vertex_index, vertex_index]
1, 0,1,2,3,
// triangle with material
// 00 00 00 10 = 2
// 2, [vertex_index, vertex_index, vertex_index],
// [material_index]
2, 0,1,2, 0,
// triangle with material, vertex uvs and face normal
// 00 10 01 10 = 38
// 38, [vertex_index, vertex_index, vertex_index],
Search WWH ::




Custom Search