# Trying to implement an FPS-like camera.

Hi everyone,

I am trying to implement an FPS-like camera. [See code below.]
It is an home made math librairy, but I think it should be easy to understand.

The problem is that instead of having the camera pivoting, it is the model that looks like it is rotating around an arbitrary point in space (probably the origin…)
My camera is stored as 3 vectors, target, eye and up.

Does anyone would be able to help me solve this problem?

Proksima

/***/

Matrix<4, 4> Camera::getViewMatrix(void) const {
Vector<3> front = target - eye;
front.normalize();
Vector<3> left = up^front; // Denotes a cross product.
left.normalize();

``````    Matrix&lt;4, 4&gt; view_matrix;
view_matrix[0] = Vector&lt;4&gt;(left, 0.0);
view_matrix[1] = Vector&lt;4&gt;(up, 0.0);
view_matrix[2] = Vector&lt;4&gt;(front, 0.0);
view_matrix[3] = Vector&lt;4&gt;(eye, 1.0);

return view_matrix;
``````

}

void Camera::rotate(float const delta_latitude, float const delta_longitude) {
Vector<3> front = target - eye;
front.normalize();
Vector<3> left = up^front;
left.normalize();

``````    Quaternion&lt;&gt; y_rotation(delta_longitude, up);
Quaternion&lt;&gt; x_rotation(delta_latitude, left);

front = x_rotation.matrix()*y_rotation.matrix()*front;
target = eye + front;

up = x_rotation.matrix()*up;
``````

}

void Camera::move(Vector<3> const &displacement) {
eye += displacement;
target += displacement;
}

= = personally I think gluLookAt() is easier.

I usually use GLFrame to create a camera.GLFrame is a class discribed in OpenGLSuperBible (4th).