Hi all, I’m a bit confused on how to manage my camera class and was hoping that someone could set me straight.
At the moment I have a camera class that has an array of 16 floats that I feed into a floatbuffer and multiply with the current modelview matrix in order to perform transformations. Whenever I want to perform a translation I add the forward vector of the matrix to the origin (position of the camera) multiplied by an arbitrary value and when I want to perform a rotation around the Y axis I create a new matrix and set the fields as follows:
rotMat[0] = Math.toRadians(Math.cos(yRot));
rotMat[1] = 0.0f;
rotMat[2] = Math.toRadians(Math.sin(yRot));
rotMat[3] = 0.0f;
rotMat[4] = 0.0f;
rotMat[5] = 1.0f;
rotMat[6] = 0.0f;
rotMat[7] = 0.0f;
rotMat[8] = -Math.toRadians(Math.sin(yRot));
rotMat[9] = 0.0f;
rotMat[10] = Math.toRadians(Math.cos(yRot));
rotMat[11] = 0.0f;
rotMat[12] = 0.0f;
rotMat[13] = 0.0f;
rotMat[14] = 0.0f;
rotMat[15] = 1.0f;
Then I multiply this by the float array containing the current camera transformation and then multiply that by the modelview matrix with glMultMatrix. I’m not really sure if this is correct and I’m just making a silly mistake somewhere or this is completely wrong. Can anyone give me an explanation of how I would do this?
Thanks,
Paul