I'm playing around with creating a space sim, and ran into the usual gimbal lock when using euler angles to rotate the camera around.
And, I've gone nearly blind reading about quaternions and trying to apply them to a Camera. I'm utterly failing to actually understand them (apparently, that's rather normal), but worse, I'm failing to implement them properly either. Normally, I would post the code I've written, but, especially since I'm stuck on the generalities rather than the specifics(and I've tried numerous approaches to this), it may be less distracting to refrain from posting it.
My camera is a 3rd person camera (currently using glm::lookAt as my view matrix) that follows behind the ship in whatever direction the ship heads. Controlling via euler angles mostly works via this method, minus the gimbal lock. I'm currently rotating the first value "location" of glm::lookAt round the second value "position" using basic trigonometry before feeding it into that function and setting it as my view matrix (this may be an entirely dumb way to be going about it, but it's a moot point since I won't be using this method:)).
In trying to get away from using euler angles, what I feel like should work(and isn't), is to (after cutting out all of my trigonometry) translate my view matrix to the position of the ship, rotate it using a quaternion, then translate it back along the same direction(which should now put the camera in the rotated position around the ship, if my brain is doing this correctly).
I've also tried using this http://www.gamedev.net/page/resources/_/technical/math-and-physics/a-simple-quaternion-based-camera-r1997
but adapting it to a third person camera by translating before and after the rotation to keep the camera at a distance.
I've hit several roadblocks. So, first question I suppose is, am I going about this entirely wrong by still trying to use glm::lookAt, and if so, what should I do instead?
Secondly, is that so many examples I've come across on this forum and others, convert euler angles to a quaternion to rotate. I guess my next question is whether this is going to result in the same problems (since it's still using euler angles to decide the rotation) and if so, what ought I be doing instead? Most other examples of quaternion rotation I have found all rotate to a desired end point (which I don't have, I just want to rotate the view a few degrees from it's current position) or match one quaternion's rotation to another's, etc.
Additionally (and this is also a two part question), do I want to be applying these rotations to the view matrix, or beforehand to the "direction" value of the lookAt function (assuming I should still use this), and if so, will my attempt at translating to the ship, rotating, then translating back work, or am I thinking about this incorrectly?
And lastly, I've come across several comments in various threads about quaternions being unnecessary to solve gimbal lock. Some have suggested the use of axis-angles or various other methods. Are these simply lone disagreeable opinions or is this something I should devote time looking into as an alternative?
My apologies for the many, many questions, and for the fact that this question has been asked before. I'm just a little overwhelmed by it at the moment, and every forum and tutorial I read seems to give rather conflicting information on how to go about implementing this. Feel free to answer any small part of this (I've obviously asked several questions), and as always, if you know of a solid resource with reliable information, I'm happy to simply be pointed in that direction instead. Also, I've gone light on specifics, so if there's any pertinent information I've left out, I'll gladly supply it.
Thanks in advance for any advice, I genuinely appreciate it