Game Development Reference
In-Depth Information
Vertex
Position
Vertex
Texture
Vertex
Normal
x, y, z
u, v
nx, ny, nz
Figure 4-17. Vertex data format
The cube 3D model with the Android Texture on it from our program in Chapter 3 has the following
mesh data in Listing 4-30:
Listing 4-30. Cube Mesh Data
static float CubeData[] =
{
// x, y, z, u, v nx, ny, nz
-0.5f, 0.5f, 0.5f, 0.0f, 0.0f, -1, 1, 1, // front top left
-0.5f, -0.5f, 0.5f, 0.0f, 1.0f, -1, -1, 1, // front bottom left
0.5f, -0.5f, 0.5f, 1.0f, 1.0f, 1, -1, 1, // front bottom right
0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 1, 1, 1, // front top right
-0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1, 1, -1, // back top left
-0.5f, -0.5f, -0.5f, 0.0f, 1.0f, -1, -1, -1, // back bottom left
0.5f, -0.5f, -0.5f, 1.0f, 1.0f, 1, -1, -1, // back bottom right
0.5f, 0.5f, -0.5f, 1.0f, 0.0f, 1, 1, -1 // back top right
};
In terms of vertex data, it has three coordinates for position, two coordinates for vertex texture
coordinates, as well as three coordinates for vertex normals. Position coordinates are the location
of the object's vertices in local model or object space coordinates. Texture coordinates allow you to
place an image on a 3D object and range from 0 to 1. Normal coordinates allow you to use diffuse
lighting effects to render the object and simulate the effects of a light and shadows.
The MeshEx Class
The MeshEx class holds the graphics data and related functions for a 3D object. Here, I give you an
overview of this class, as well as details on key class functions.
 
Search WWH ::




Custom Search