ImGuizmo
ImGuizmo copied to clipboard
Example using ViewManipulate when game's view is represented with a Vector3 and a Quaternion?
The example in the repo seems to rely on the game's view being stored in a matrix, but this isn't how my engine represents it. Instead I use a Vector3 for camera position and Quaternion for camera rotation.
Here's some actual code to go with the question:
let eyeCenter = (Matrix4x4.CreateTranslation (World.getEyeCenter3d world)).ToArray ()
let eyeRotation = (Matrix4x4.CreateFromQuaternion (World.getEyeRotation3d world)).ToArray ()
let eyeScale = (Matrix4x4.CreateScale v3One).ToArray ()
let view = m4Identity.ToArray ()
ImGuizmo.RecomposeMatrixFromComponents (&eyeCenter.[0], &eyeRotation.[0], &eyeScale.[0], &view.[0])
ImGuizmo.ViewManipulate (&view.[0], 1.0f, v2 1400.0f 100.0f, v2 150.0f 150.0f, 0u)
ImGuizmo.DecomposeMatrixToComponents (&view.[0], &eyeCenter.[0], &eyeRotation.[0], &eyeScale.[0])
world <- World.setEyeCenter3d (Matrix4x4.CreateFromArray eyeCenter).Translation world
world <- World.setEyeRotation3d (Quaternion.CreateFromRotationMatrix (Matrix4x4.CreateFromArray eyeRotation)) world
Even without touching the view gizmo, this produces a rotation quaternion that screws up my keyboard camera controls.