I’m trying to get a set of normalized vectors ( forward, right, up ) from the current camera angles ( yaw, pitch, roll ) and am having some problems. I found some code to do this in the Quake I source code, but it doesn’t quite seem to work because the Y and Z axis are swapped in Quake ( Z is up ) relative to how they would be in OpenGL ( Y is up ) My math skills aren’t great, so perhaps the solution is easy??
Here’s the Quake code if that will help:
void AngleVectors( vec3_t ang, vec3_t fwd, vec3_t right, vec3_t up) {
float angle;
float sr, sp, sy, cr, cp, cy;
angle = ang[YAW] * (M_PI2/360);
sy = sin(angle);
cy = cos(angle);
angle = ang[PITCH] * (M_PI2/360);
sp = sin(angle);
cp = cos(angle);
angle = ang[ROLL] * (M_PI*2/360);
sr = sin(angle);
cr = cos(angle);
if( fwd ) {
forward[0] = cpcy;
forward[1] = cpsy;
forward[2] = -sp;
}
if( right ) {
right[0] = (-1srspcy±1cr*-sy);
right[1] = (-1srspsy±1crcy);
right[2] = -1srcp;
}
if( up ) {
up[0] = (crspcy±sr-sy);
up[1] = (crspsy±srcy);
up[2] = crcp;
}
}
Thanks in advance.