Game Development Reference
In-Depth Information
v[4].x = 100.0f; v[4].y = -100.0f; v[4].z = 100.0f;
v[5].x = 100.0f; v[5].y = -100.0f; v[5].z = -100.0f;
v[6].x = 100.0f; v[6].y = 100.0f; v[6].z = 100.0f;
v[7].x = 100.0f; v[7].y = 100.0f; v[7].z = -100.0f;
v[8].x = 100.0f; v[8].y = -100.0f; v[8].z = 100.0f;
v[9].x = 100.0f; v[9].y = 100.0f; v[9].z = 100.0f;
v[10].x = -100.0f; v[10].y = -100.0f; v[10].z = 100.0f;
v[11].x = -100.0f; v[11].y = 100.0f; v[11].z = 100.0f;
v[12].x = -100.0f; v[12].y = -100.0f; v[12].z = 100.0f;
v[13].x = -100.0f; v[13].y = 100.0f; v[13].z = 100.0f;
v[14].x = -100.0f; v[14].y = -100.0f; v[14].z = -100.0f;
v[15].x = -100.0f; v[15].y = 100.0f; v[15].z = -100.0f;
v[16].x = -100.0f; v[16].y = 100.0f; v[16].z = -100.0f;
v[17].x = -100.0f; v[17].y = 100.0f; v[17].z = 100.0f;
v[18].x = 100.0f; v[18].y = 100.0f; v[18].z = -100.0f;
v[19].x = 100.0f; v[19].y = 100.0f; v[19].z = 100.0f;
v[20].x = -100.0f; v[20].y = -100.0f; v[20].z = -100.0f;
v[21].x = -100.0f; v[21].y = -100.0f; v[21].z = 100.0f;
v[22].x = 100.0f; v[22].y = -100.0f; v[22].z = -100.0f;
v[23].x = 100.0f; v[23].y = -100.0f; v[23].z = 100.0f;
The vertices have been ordered a face at a time, so the first four vertices form the
front of the cube, the next four the right hand face, and so on. You are free to specify
the order however you see it, since ultimately it will be the index stream that
determines how the individual triangles will be rendered.
Now we'll create the normal stream. Normals in Marmalade are also specified as
instances of CIwFVec3 , and they are expected to have unit length. This means that
the magnitude of the vector should be one. Here's a code snippet that will do the job:
CIwFVec3* n = new CIwFVec3[lVertexCount];
n[0].x = 0.0f; n[0].y = 0.0f; n[0].z = -1.0f;
n[1].x = 0.0f; n[1].y = 0.0f; n[1].z = -1.0f;
n[2].x = 0.0f; n[2].y = 0.0f; n[2].z = -1.0f;
n[3].x = 0.0f; n[3].y = 0.0f; n[3].z = -1.0f;
n[4].x = 1.0f; n[4].y = 0.0f; n[4].z = 0.0f;
n[5].x = 1.0f; n[5].y = 0.0f; n[5].z = 0.0f;
n[6].x = 1.0f; n[6].y = 0.0f; n[6].z = 0.0f;
n[7].x = 1.0f; n[7].y = 0.0f; n[7].z = 0.0f;
n[8].x = 0.0f; n[8].y = 0.0f; n[8].z = 1.0f;
n[9].x = 0.0f; n[9].y = 0.0f; n[9].z = 1.0f;
n[10].x = 0.0f; n[10].y = 0.0f; n[10].z = 1.0f;
n[11].x = 0.0f; n[11].y = 0.0f; n[11].z = 1.0f;
n[12].x = -1.0f; n[12].y = 0.0f; n[12].z = 0.0f;
 
Search WWH ::




Custom Search