static void setupRotationMatrix (float *matrix) { // This borrows heavily from the code in render.c float xRotMat[16], zRotMat[16]; // Storage for precalculated trig function results float sinX, cosX, sinY, cosY, sinZ, cosZ; glmatrix_identity(xRotMat); glmatrix_identity(zRotMat); // Calculate the trig functions cosX = cos(camera.angleRad[_X]); sinX = sin(camera.angleRad[_X]); /* sinY = sin(camera.angleRad[_Y]); cosY = cos(camera.angleRad[_Y]); */ cosZ = cos(camera.angleRad[_Z]); sinZ = sin(camera.angleRad[_Z]); // Build the x rotation matrix xRotMat[5] = cosX; xRotMat[6] = sinX; xRotMat[9] = -sinX; xRotMat[10] = cosX; // Build the Z rotation matrix zRotMat[0] = cosZ; zRotMat[1] = -sinZ; zRotMat[4] = sinZ; zRotMat[5] = -cosZ; multiplyMats16f(zRotMat, xRotMat, matrix); }
static void camera_init() { VectorClear(camera.position); VectorClear(camera.angles_deg); VectorClear(camera.angles_rad); glmatrix_identity(xRotMatrix); glmatrix_identity(yRotMatrix); glmatrix_identity(zRotMatrix); glmatrix_identity(translateMatrix); }