View Full Version : Camera FirstPerson Vector

10-17-2002, 07:13 PM
Here is a short presentation of my class.

class CCamFirstPerson
protected :
CVector m_Right,
public :
// constructor, destructor...

// Rotate cam around X axis
void RotationX( float Angle )


// Rotate cam around Y axis
void RotationY( float Angle )


Here is my problem, I'm unable to well apply the rotation on each vector to get a right FirstPerson camera. When I look down and I rotate left/right, the camera doesn't keep the view vector on (0.0, 0.0, 1.0), so it's make an effect like a 6DOF camera.

So to try another thing, I decided to work without my vector. Just take the Angle and set up a matrix with it. The inconveniant of that : I can get the vector inside the final matrix, but they will not be updated into the rotation function... So not very practical...

Ex :

void RotationX( float Angle )
m_Pitch += m_Pitch - Angle;

void UpdateCam()
// Create rotation matrix
CMatrix MatRotY;
CMatrix MatRotX;

CMatrix MatRot = MatRotY * MatRotX;

// Create Translation Matrix
CMatrix MatTrans;
MatTrans.CreateTranslation( -m_Pos.X, -m_Pos.Y, -m_Pos.Z );

// Create the final matrix
CMatrix MatCam = MatRot * MatTrans;

// Update de modelview matrix
glMatrixMode( GL_MODELVIEW );
glLoadMatrixf( &MatCam );

This method works well but I don't want to use it and you know why... I want to apply the rotation directly on the vector, into the rotation function. Anyone could help me ?

[This message has been edited by Erakis (edited 10-17-2002).]