My code for rotating my 3D fps camera isn't working as expected.
I expect that the X-axis does rotate with the Y-axis, but it ain't so.
I made some pictures to explain it better, I think its doing global rotation instead of local rotation.
But I searched in the internet and used code for local rotation and it was still the same result.
- Normal Position
- Rotated on Y-Axis
- Rotated on X-Axis (how it is)
- Rotated on X-Axis (how it should be)
And this is my rotating code: X-Axis
float sx = sinf(x); float cx = cosf(x); up.y = up.y*cx - up.z*sx; up.z = up.y*sx + up.z*cx; center.y = center.y*cx - center.z*sx; center.z = center.y*sx + center.z*cx;
Math::Vector3f f = Normalise(center - eye); float sy = sinf(y); float cy = cosf(y); center.z = eye.z + f.z*cy - f.x*sy; center.x = eye.x + f.z*sy + f.x*cy;
It doesn't matter with which order I rotate, still the same.