I know that NaN means Not a number but I dont understand how Im getting the error. What im doing is referencing the values of the vertices of my shape object that are from my shape class and using them here in my renderer class. When I print out the values for the vertices on the logcat I see that it returns the first 5 vertices and then every other vertice is NaN. If you look at my logcat is shows that before the call to matrix.multiplyMM() the vertices (vertex1) are printed fine. But after the call, the vertices (shapeverts) start becoming NaN.
for (int i = 0; i < Shape.vertices.length; i += Shape.COORDS_PER_VERTEX) {//only checking one vertex
Log.i("vertex1", String.valueOf(Shape.vertices[i] + ", " + Shape.vertices[i+1] + ", " + Shape.vertices[i+2] + ", " + Shape.vertices[i+3]));
Matrix.multiplyMM(shapeVerts, 0, mvp, 0, Shape.vertices, 0);//vertices multiplied by model view projection matrix
Log.i("shapevertBf", String.valueOf(shapeVerts[i] + ", " + shapeVerts[i+1] + ", " + shapeVerts[i+2] + ", " + shapeVerts[i+3]));
shapeVerts[i] = shapeVerts[i] / shapeVerts[i + 3]; //clip.x divided by clip.w
shapeVerts[i + 1] = shapeVerts[i + 1] / shapeVerts[i + 3];//clip.y divided by clip.w
shapeVerts[i + 2] = shapeVerts[i + 2] / shapeVerts[i + 3];//clip.y divided by clip.w
Log.i("shapevertAf", String.valueOf(shapeVerts[i] + ", " + shapeVerts[i+1] + ", " + shapeVerts[i+2] + ", " + shapeVerts[i+3]));
LogCat
06-10 13:59:27.983 13121-13189/com.example.james.rollingsphere I/vertex1﹕ 0.0, 0.0, 9.0, 1.0
06-10 13:59:27.993 13121-13189/com.example.james.rollingsphere I/shapevertBf﹕ 0.0, 0.0, 19.5, 12.0
06-10 13:59:27.993 13121-13189/com.example.james.rollingsphere I/shapevertAf﹕ 0.0, 0.0, 1.625, 12.0
06-10 13:59:27.993 13121-13189/com.example.james.rollingsphere I/vertex1﹕ 0.0, 0.0, 9.0, 1.0
06-10 13:59:27.993 13121-13189/com.example.james.rollingsphere I/shapevertBf﹕ 0.0, 0.0, 19.5, 12.0
06-10 13:59:27.993 13121-13189/com.example.james.rollingsphere I/shapevertAf﹕ 0.0, 0.0, 1.625, 12.0
06-10 13:59:27.993 13121-13189/com.example.james.rollingsphere I/vertex1﹕ 0.0, 0.0, 9.0, 1.0
06-10 13:59:27.993 13121-13189/com.example.james.rollingsphere I/shapevertBf﹕ 0.0, 0.0, 19.5, 12.0
06-10 13:59:27.993 13121-13189/com.example.james.rollingsphere I/shapevertAf﹕ 0.0, 0.0, 1.625, 12.0
06-10 13:59:27.993 13121-13189/com.example.james.rollingsphere I/vertex1﹕ 0.0, 0.0, 9.0, 1.0
06-10 13:59:27.993 13121-13189/com.example.james.rollingsphere I/shapevertBf﹕ 0.0, 0.0, 19.5, 12.0
06-10 13:59:27.993 13121-13189/com.example.james.rollingsphere I/shapevertAf﹕ 0.0, 0.0, 1.625, 12.0
06-10 13:59:28.003 13121-13189/com.example.james.rollingsphere I/vertex1﹕ 0.0, 0.0, 9.0, 1.0
06-10 13:59:28.003 13121-13189/com.example.james.rollingsphere I/shapevertBf﹕ 0.0, 0.0, 0.0, 0.0
06-10 13:59:28.003 13121-13189/com.example.james.rollingsphere I/shapevertAf﹕ NaN, NaN, NaN, 0.0
06-10 13:59:28.003 13121-13189/com.example.james.rollingsphere I/vertex1﹕ 5.290067, 0.0, 7.281153, 1.0
06-10 13:59:28.003 13121-13189/com.example.james.rollingsphere I/shapevertBf﹕ 0.0, 0.0, 0.0, 0.0
06-10 13:59:28.003 13121-13189/com.example.james.rollingsphere I/shapevertAf﹕ NaN, NaN, NaN, 0.0
06-10 13:59:28.003 13121-13189/com.example.james.rollingsphere I/vertex1﹕ 1.634721, 5.031153, 7.281153, 1.0
06-10 13:59:28.003 13121-13189/com.example.james.rollingsphere I/shapevertBf﹕ 0.0, 0.0, 0.0, 0.0
06-10 13:59:28.003 13121-13189/com.example.james.rollingsphere I/shapevertAf﹕ NaN, NaN, NaN, 0.0
06-10 13:59:28.003 13121-13189/com.example.james.rollingsphere I/vertex1﹕ -4.279755, 3.109423, 7.281153, 1.0
06-10 13:59:28.013 13121-13189/com.example.james.rollingsphere I/shapevertBf﹕ 0.0, 0.0, 0.0, 0.0
06-10 13:59:28.013 13121-13189/com.example.james.rollingsphere I/shapevertAf﹕ NaN, NaN, NaN, 0.0
Edit I updated the code and the logcat. Interestly the w component starts off as 12 after the Matrix.multiply but then becomes 0.