Game Development Reference
In-Depth Information
The following sample code initializes the vertices:
function initBuffers() {
...
vertices = [
3.0, 3.0, 0.0, //Vertex 0
-3.0, 3.0, 0.0, //Vertex 1
3.0, -3.0, 0.0, //Vertex 2
-3.0, -3.0, 0.0 //Vertex 3
];
...
}
The question might pop up that if we had to draw the mesh of a mutated human, as
depicted in the following diagram, then there would have been many polygons and
each polygon would have many vertices; so, do we have to define an array with all
the vertices by hand?
Well, the mutated human displayed in the preceding screenshot is created using 3D
tools such as Maya and Blender. We will export the vertices of the model in a file that
is parsed by our JavaScript code, and our program will use the vertices from that file.
So, ultimately your code will require vertices, but you will not have to provide them
by hand.
 
Search WWH ::




Custom Search