Search code examples
iosobjective-cmatrixopengl-esglkit

Multiply vertex data with a matrix iOS


I found a way to get the transformed vertextdata of an object they say I have to multiply the vertexdata with the matrix.But I dont know how to do it. I have

GLfloat gCubeVertexData[216] = 
{
0.5f, -0.5f, -1.0f,        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,

etc.
};

and the matrix

Thanks for your time :)


Solution

  • Assuming your matrix is an array of floats as well. Make a GLKMatrix4 object first.

    Then you multiply every vertex (x,y,z) from gCubeVertexData using one of the methods on Perform Mathematical Operations on Vectors