I have been having trouble with my camera, first encountering the roll tilt that is so many times asked... I fixed that issue by following the instructions at this link: Unwanted roll when rotating camera with pitch and yaw But now I find another issue, whenever I get close to my triangle, pitch becomes roll, and instead of moving up and down the triangle, the camera rotates around the plane of that triangle, see:
This is my code, I follow the same logic as the link above!
float spitch = pitch * camera.sensitivity, syaw = yaw * camera.sensitivity; float npitch = Math_Quaternion_GetPitch(camera.rotation) + spitch; if(npitch > Math_Degrees_ToRadians(85) || npitch < Math_Degrees_ToRadians(-85)) return; Math_Quaternion yaw_quat; Math_Quaternion pitch_quat; Math_Vec3 up = {0, 1, 0}; Math_Vec3 left = {1, 0, 0}; Math_Quaternion_RotationAroundAxis(yaw_quat, up, syaw); Math_Quaternion_MultiplyVec3(left, camera.rotation, \* this is out! *\ left); Math_Quaternion_RotationAroundAxis(pitch_quat, left, spitch); Math_Quaternion_Multiply(pitch_quat, camera.rotation, camera.rotation); Math_Quaternion_Multiply(yaw_quat, camera.rotation, camera.rotation); Math_Quaternion_Normalize(camera.rotation); Edit: Also, switching the quaternion multiplication order or just using a normal pitch yaw roll method fixes the problem, but then the roll problem comes back!
