# FPS camera: finding forward/right/up vectors?

This topic is 3717 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Okay, so I have a simple "camera" that uses Euler angles (only pitch and yaw for now). The problem is, I want to do some basic raycasting but I don't know how to get the forward/right/up vectors from those angles, without messing everything up. FYI, the nomenclature I use for my rotations/translations is this:
glRotatef(viewAngles.x,1.0f,0.0f,0.0f);
glRotatef(viewAngles.y,0.0f,1.0f,0.0f);
glTranslatef(-playerOrigin.x,-playerOrigin.y,-playerOrigin.z);

Any suggestions for my noobish question? Thanks in advance.

##### Share on other sites
FindViewVectors ( float yaw, float pitch )
{
float sinp = (float) sin(pitch);
float cosp = (float) cos(pitch);
float siny = (float) sin(yaw);
float cosy = (float) cos(yaw);

// apply yaw and pitch to get forward vector
m_vecForward.x = -siny * cosp;
m_vecForward.y = cosy * cosp;
m_vecForward.z = sinp;

// apply yaw and pitch to get right vector
m_vecRight.x = cosy;
m_vecRight.y = siny;
m_vecRight.z = 0;

// take cross product of yaw and pitch to get up vector
m_vecUp = CrossProduct(m_vecRight, m_vecForward);
}

Make sure your coordinate system is the same as mine.

##### Share on other sites
u can get the side/up/forward vectors from the modelview matrix

eg side = mv.00 mv.10 mv.20
though this maybe mv.00 mv.01 mv.02
depending on how u store the data

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5

• 14
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631431
• Total Posts
3000040
×