Basically, I’m trying to write my own mini engine of sorts and I’m sort of copying the way opengl does things. I’ve written my own gl function (I denote them al) and I’m keeping a model matrix, perspective matrix, and a view matrix. My alScale and alTranslate work perfectly but for some reason my alRotate seems to just translate as well as rotate.
I’ve only defined rotation around the x, y, and z axes and the matrix I multiply my model matrix by upon calling rotate is the following:
Matrix4x4 r = Matrix4x4();
if (axis == 'x') {
r[1][1] = cos(angle);
r[1][2] = -sin(angle);
r[2][1] = sin(angle);
r[2][2] = cos(angle);
}
else if (axis == 'y') {
r[0][0] = cos(angle);
r[0][2] = sin(angle);
r[2][0] = -sin(angle);
r[2][2] = cos(angle);
}
else if (axis == 'z') {
r[0][0] = cos(angle);
r[0][1] = -sin(angle);
r[1][0] = sin(angle);
r[1][1] = cos(angle);
}
return r;
I ‘think’ I have the math right so I’m not sure what’s going on. I notice that whenever I increase the rotation angle for the x-axis, the y value of the points seem to get smaller…any ideas?