Before drawing some objects I am modifying the modelview matrix like so
gl.glTranslatef(tX, tY, tZ);
gl.glRotatef(angle, rX, rY, 0);
which produces the result I want. However my project requires to do these matrix modifications manually.
So modifying my vertices like this gives the desired translation (I am using vertex arrays)
vertice[i] = vertice[i] + tX;
vertice[i+1] = vertice[i+1] + tY;
vertice[i+2] = vertice[i+2] + tZ;
However the rotation seems to be troublesome…
I looked up the way glRotatef modifies the matrix
So I recreated it, leaving out the Z stuff as that is 0, will return 0 within the subcalculations and therefore is not of any matter.
[A B C]
[D E F]
[G H I]
float c = (float) Math.cos(angle);
float s = (float) Math.sin(angle);
float A = rXrX(1-c) + c;
float B = rXrY(1-c);
float C = rYs;
float D = rYrX*(1-c);
float E = rYrY(1-c) + c;
float F = -rXs;
float G = -rYs;
float H = rX*s;
float I = c;
Then I multiplied the current (normalized) vector [rX, rY, 0] with this matrix to create a new vector (again leaving out the Z as it is 0)
float nX = (float) (ArX + BrY);
float nY = (float) (DrX + ErY);
Now when I modify my vertices with this new vector, it does not give the same results as it would with glRotatef
vertice[i] = vertice[i] * nX;
vertice[i+1] = vertice[i+1] * nY;
I tried swapping the translations and rotations without any joy. As far as I know, no prior modifications are made to the current model matrix.
Am I overlooking something here?