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

Coordinate system requirements #22

Open
shadeMe opened this issue Feb 21, 2017 · 4 comments
Open

Coordinate system requirements #22

shadeMe opened this issue Feb 21, 2017 · 4 comments

Comments

@shadeMe
Copy link

shadeMe commented Feb 21, 2017

Is ImGuizmo depend on a particular coordinate system? I'm trying to retrofit a 3D editor with ImGuizmo, one that is based on Dx9+Gamebryo. Gamebryo's coordinate system, for some reason, is different from the usual left-hand/right-hand systems :

  • The Up vector is in +Y
  • The Right vector is in +Z
  • The Forward vector is in +X

Unfortunately, using the view/perspective matrices of that coordinate system renders the gizmo incorrectly (it appears along the negative vertical axis and gets culled on the slightest movement of the camera). How would I go about resolving this issue? The gizmo does work with a regular LH coordinate system (tested it in a demo DirectX project).

@CedricGuillemet
Copy link
Owner

CedricGuillemet commented Feb 21, 2017 via email

@rokups
Copy link
Contributor

rokups commented Sep 13, 2017

Hey @CedricGuillemet, i am also facing same issue trying to integrate ImGuizmo into AtomicGameEngine. Engine uses following coordinate system:

Left-handed coordinates. Positive X, Y & Z axes point to the right, up, and forward, and positive rotation is clockwise.

I have a self-contained testcase, although it is pretty fat as repository pulls in entire engine. If offer still stands you may take a look: https://github.com/rokups/CSGBoolOpsTest (do not forget to clone submodules). Engine has all dependencies bundled and you should not need to do anything else than running plain cmake && make on cloned folder.

In "Debug" window try adjusting z component of translation. Gizmo can be visible right in the center although it looks weird. Holding right mouse button and moving camera tiny bit makes gizmo move to opposite direction. Besides, shouldnt gizmo be always visible as long as ImGuizmo::Manipulate() is called?

@rokups
Copy link
Contributor

rokups commented Sep 14, 2017

After some thought it occurred to me that there may be several different matrix conventions and actually that is the case. ImGuizmo is using row convention where opengl uses column convention. So matrix has to be converted using these:

    void ToImGuizmo(float* dest, const Matrix4& src)
    {
        for (auto row = 0; row < 4; row++)
        {
            for (auto col = 0; col < 4; col++)
                dest[row * 4 + col] = src.Data()[col * 4 + row];
        }
    }

    void FromImGuizmo(Matrix4& dest, float* src)
    {
        for (auto row = 0; row < 4; row++)
        {
            for (auto col = 0; col < 4; col++)
                (&dest.m00_)[col * 4 + row] = src[row * 4 + col];
        }
    }

@shadeMe
Copy link
Author

shadeMe commented Sep 15, 2017

@rokups Thanks for the code. Unfortunately, switching between row-major and column-major matrices doesn't help in my setup.
@CedricGuillemet Sorry about not getting back to you until now. I'm afraid my application has multiple dependencies, some of which I'm not at the liberty to distribute.

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

3 participants