Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example using ViewManipulate when game's view is represented with a Vector3 and a Quaternion? #304

Open
bryanedds opened this issue Jul 13, 2023 · 1 comment

Comments

@bryanedds
Copy link

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.

@bryanedds
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant