I am building a simple game engine in Java using LWJGL 3 (GLFW for input / windowing, OpenGL for rendering) and JOML for some of the maths (very useful). As I build the engine I am naturally building a game to utilize it which in its current form is a very simplistic space flight simulator [think Elite (1984)].
Situation: I am currently working on a first person camera system where the camera is the ship [cockpit view without headlook]. I have 3 systems:
- Direct - the camera moves with input, stops without. No acceleration, feels very much like a debugging tool (which it is). working
- Un-stabilized - Input adds force / torque along / about a local axis (forward, up, right). This works and feels very much like Elite Dangerous with flight-assist off [or the equivalent in Star Citizen because I'm impartial]. working
- Stabilized - works like Un-stabilized when input is given but when there is no input (on a given axis) the "computer" will apply the necessary force / torque to stop movement along / about that axis. This works [read: will work] like Elite Dangerous with Flight-assist on. not working*
*edit: working for translation, I am struggling with rotation.
Question: Given a matrix (or quaternion if that's easier / better) representing the camera's rotation (obtained by subtracting the orientation in the last from from the current orientation) I need to find a number representing the current speed of rotation about a given axis (e.g., camera.right for pitch) so that the "computer" can apply a torque in the opposite direction until movement about that axis is zero.
I.e., when I stop providing pitch input (mouse.y inside dead-zone) the computer will provide pitch input (acting like a player) to reduce rotation about the lateral axis (local x or camera right) to zero.