/** * Function: rotateCamera * Description: Rotate this camera by the given 3 angle of rotations with respect * to its current orientation. Rotation is done by changing the lookVector, upVector * and rightVector of this camera. **/ void WZ_Camera::rotateCamera(float rollDegree, float pitchDegree, float yawDegree) { // Calculate transformation matrix Matrix4By4<float> rotationMatrix_along_look = makeRotationMatrix(rollDegree, lookVector); Matrix4By4<float> rotationMatrix_along_right = makeRotationMatrix(pitchDegree, rightVector); Matrix4By4<float> rotationMatrix_along_up = makeRotationMatrix(yawDegree, upVector); Matrix4By4<float> rotationMatrix = rotationMatrix_along_look * rotationMatrix_along_right * rotationMatrix_along_up; //transform the 3 vertex upVector = applyMatrix(rotationMatrix, upVector); lookVector = applyMatrix(rotationMatrix, lookVector); rightVector = applyMatrix(rotationMatrix, rightVector); }
Matrix<T> makeRotationMatrix_deg(T degX, T degY, T degZ, RotationOrder order) { T radX = degX / 180.0 * MathUtils::PI; T radY = degY / 180.0 * MathUtils::PI; T radZ = degZ / 180.0 * MathUtils::PI; return makeRotationMatrix( radX, radY, radZ, order ); }