I am playing around with the OpenGL ES template in Xcode 4.5. I draw a cube in Google Sketchup and exported into collada. I copied the vertex and normal data into the open gl template in Xcode as below:
GLfloat gCubeVertexData[] =
{
// Data layout for each line below is:
// positionX, positionY, positionZ, normalX, normalY, normalZ,
// 0.5f, -0.5f, -0.5f, 1.0f, 0.0f, 0.0f,
// 0.5f, 0.5f, -0.5f, 1.0f, 0.0f, 0.0f,
// 0.5f, -0.5f, 0.5f, 1.0f, 0.0f, 0.0f,
// 0.5f, -0.5f, 0.5f, 1.0f, 0.0f, 0.0f,
// 0.5f, 0.5f, -0.5f, 1.0f, 0.0f, 0.0f,
// 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 0.0f,
//
// 0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f,
// -0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f,
// 0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f,
// 0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f,
// -0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f,
// -0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f,
//
// -0.5f, 0.5f, -0.5f, -1.0f, 0.0f, 0.0f,
// -0.5f, -0.5f, -0.5f, -1.0f, 0.0f, 0.0f,
// -0.5f, 0.5f, 0.5f, -1.0f, 0.0f, 0.0f,
// -0.5f, 0.5f, 0.5f, -1.0f, 0.0f, 0.0f,
// -0.5f, -0.5f, -0.5f, -1.0f, 0.0f, 0.0f,
// -0.5f, -0.5f, 0.5f, -1.0f, 0.0f, 0.0f,
//
// -0.5f, -0.5f, -0.5f, 0.0f, -1.0f, 0.0f,
// 0.5f, -0.5f, -0.5f, 0.0f, -1.0f, 0.0f,
// -0.5f, -0.5f, 0.5f, 0.0f, -1.0f, 0.0f,
// -0.5f, -0.5f, 0.5f, 0.0f, -1.0f, 0.0f,
// 0.5f, -0.5f, -0.5f, 0.0f, -1.0f, 0.0f,
// 0.5f, -0.5f, 0.5f, 0.0f, -1.0f, 0.0f,
//
// 0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f,
// -0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f,
// 0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f,
// 0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f,
// -0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f,
// -0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f,
//
// 0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f,
// -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f,
// 0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f,
// 0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f,
// -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f,
// -0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f
9.8425197/9.8425197, 9.8425197/9.8425197, 0.0000000/9.8425197, 0.0000000, 0.0000000, -1.0000000,
0.0000000/9.8425197, 0.0000000/9.8425197, 0.0000000/9.8425197, 0.0000000, 0.0000000, -1.0000000,
0.0000000/9.8425197, 9.8425197/9.8425197, 0.0000000/9.8425197, 0.0000000, 0.0000000, -1.0000000,
9.8425197/9.8425197, 0.0000000/9.8425197, 0.0000000/9.8425197, 0.0000000, 0.0000000, -1.0000000,
0.0000000/9.8425197, 9.8425197/9.8425197, 8.2677165/9.8425197, -1.0000000, 0.0000000, 0.0000000,
0.0000000/9.8425197, 0.0000000/9.8425197, 0.0000000/9.8425197, -1.0000000, 0.0000000, 0.0000000,
0.0000000/9.8425197, 0.0000000/9.8425197, 8.2677165/9.8425197, -1.0000000, 0.0000000, 0.0000000,
0.0000000/9.8425197, 9.8425197/9.8425197, 0.0000000/9.8425197, -1.0000000, 0.0000000, 0.0000000,
0.0000000/9.8425197, 9.8425197/9.8425197, 8.2677165/9.8425197, -0.0000000, 1.0000000, 0.0000000,
9.8425197/9.8425197, 9.8425197/9.8425197, 0.0000000/9.8425197, -0.0000000, 1.0000000, 0.0000000,
0.0000000/9.8425197, 9.8425197/9.8425197, 0.0000000/9.8425197, -0.0000000, 1.0000000, 0.0000000,
9.8425197/9.8425197, 9.8425197/9.8425197, 8.2677165/9.8425197, -0.0000000, 1.0000000, 0.0000000,
9.8425197/9.8425197, 9.8425197/9.8425197, 0.0000000/9.8425197, 1.0000000, 0.0000000, 0.0000000,
9.8425197/9.8425197, 0.0000000/9.8425197, 8.2677165/9.8425197, 1.0000000, 0.0000000, 0.0000000,
9.8425197/9.8425197, 0.0000000/9.8425197, 0.0000000/9.8425197, 1.0000000, 0.0000000, 0.0000000,
9.8425197/9.8425197, 9.8425197/9.8425197, 8.2677165/9.8425197, 1.0000000, 0.0000000, 0.0000000,
9.8425197/9.8425197, 0.0000000/9.8425197, 8.2677165/9.8425197, -0.0000000, -1.0000000, -0.0000000,
0.0000000/9.8425197, 0.0000000/9.8425197, 0.0000000/9.8425197, -0.0000000, -1.0000000, -0.0000000,
9.8425197/9.8425197, 0.0000000/9.8425197, 0.0000000/9.8425197, -0.0000000, -1.0000000, -0.0000000,
0.0000000/9.8425197, 0.0000000/9.8425197, 8.2677165/9.8425197, -0.0000000, -1.0000000, -0.0000000,
9.8425197/9.8425197, 0.0000000/9.8425197, 8.2677165/9.8425197, 0.0000000, 0.0000000, 1.0000000,
0.0000000/9.8425197, 9.8425197/9.8425197, 8.2677165/9.8425197, 0.0000000, 0.0000000, 1.0000000,
0.0000000/9.8425197, 0.0000000/9.8425197, 8.2677165/9.8425197, 0.0000000, 0.0000000, 1.0000000,
9.8425197/9.8425197, 9.8425197/9.8425197, 8.2677165/9.8425197, 0.0000000, 0.0000000, 1.0000000
};
When I run, I have the rendered cube below, so something is not right.
=======
It looks like if I am using normals, I don't need to provide the indices to render a 3D object. But in my case there seems to be something out of order either in the vertex data or normal... Does any one know how in collada this two data are arranged? I read through the documentation but I couldn't find an answer... Thanks