0

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.

Peter O.
  • 32,158
  • 14
  • 82
  • 96
  • Try this question: http://stackoverflow.com/questions/15022630/how-to-calculate-the-angle-from-roational-matrix. Or google "euler angles from rotation matrix" – samgak May 24 '16 at 11:43
  • You could start by projecting the axis of the delta rotation onto the plane for which your control axis is the normal of and normalising it (making it orthagonal to the canceled axis). This would completely cancel out all rotation in that axis - you can easily start to interpolate -, but I haven't figured out yet how to relate that to torque (i.e. how to adjust the angular velocity based on the reprojection distance.) You'll have to do some math ;) – BeyelerStudios May 24 '16 at 12:33
  • @BeyelerStudios I realize now that what i was asking for is, in fact, more than i need. The flight computer doesn't need to know the rotational velocity, just the direction. The computer can only exert a fixed torque so it just needs to know if we are spinning clockwise or counter-clockwise in order to compensate accordingly. – Java_Jiant May 24 '16 at 13:09
  • @BeyelerStudios With regards to the rotational velocity (if I did need it). Would it not simply be the angle on that plane between the projected vector and camera.forward? Regardless, you have solved my problem, if you put it in an answer I will accept it, or I will add one later. – Java_Jiant May 24 '16 at 13:19

0 Answers0