Skip to content
New issue

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

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

Already on GitHub? # to your account

Direction vector/rotation widget #2811

Closed
DiligentGraphics opened this issue Sep 27, 2019 · 8 comments
Closed

Direction vector/rotation widget #2811

DiligentGraphics opened this issue Sep 27, 2019 · 8 comments

Comments

@DiligentGraphics
Copy link
Contributor

Hello!

I am trying to find a way to input normalized direction vector (such as light direction) as well as rotation. My current solution for direction is as follows:

if (ImGui::SliderFloat3("Light Direction", &m_LightDirection.x, -1, +1))
{
    if(m_LightDirection == float3(0, 0, 0))
        m_LightDirection = float3(0, -1, 0);
    else
        m_LightDirection = normalize(m_LightDirection);
}

This however does not work really well as it is hard to control and understand. My old UI library that I am currently getting rid of has nice widgets for both direction and rotation data:

image
image

Is there any way to get something similar with dear imgui?

@ocornut
Copy link
Owner

ocornut commented Sep 27, 2019 via email

@BrutPitt
Copy link

BrutPitt commented Sep 27, 2019

Hi, @DiligentGraphics
Similar to that old GIU, I developed a more evolved widget/widgets for ImGui.

imGuIZMO.quat

You can manipulate an object/light, in your ImGui window, adding only 4 code lines!.

It uses quaternions algebra, internally, to manage rotations, but offers the possibility also to interfacing with vec3, vec4 or mat4x4 (rotation).
It uses virtualGizmo3D: my header only 3D GIZMO screen manipulator tool (in Immediate Mode without pan and dolly functions) and glm mathematics library (0.9.9 or higher), also it an header only tool.

There are also two live WebGL demo to test widgets in main page: imGuIZMO.quat

I use it also in my project: glChAoS.P: was developed for it.

Here some widgets examples:
ImGuIZMO_collage

@DiligentGraphics
Copy link
Contributor Author

@BrutPitt That looks fantastic, thanks for sharing! I will certainly take a look later today.

@DiligentGraphics
Copy link
Contributor Author

@BrutPitt Thanks again, your widget works really well!
image

@ocornut It was certainly little unexpected that dear imgui has so many cool advanced UI features, but does not provide this really basic widget. Do you have a list of extension widgets developed by community? I think this one should definitely be in such list.

@BrutPitt
Copy link

BrutPitt commented Sep 29, 2019

@DiligentGraphics Thank you and thanks for the appreciation, I'm glad it's useful to you.

imGuIZMO.quat was born of a personal need, so currently some settings/features were not designed/thought with the needs of third parties in mind.
In this context is placed the glm use (that I use everywhere) but I understand also that this can be restrictive for a standalone ImGui widget. (though glm is practically a standard)

But it could be also thought making it totally standalone, rewriting just the sub-set of vectors / quaternions operations used .

Anyway I am open to constructive dialogue and new ideas

@DiligentGraphics
Copy link
Contributor Author

@BrutPitt It took me a couple of hours to replace glm and remove dependencies on other headers. Making this widget a standalone component will not require a lot of work.

@ocornut
Copy link
Owner

ocornut commented Sep 30, 2019

Do you have a list of extension widgets developed by community? I think this one should definitely be in such list.

There's a list in the wiki:
https://github.com/ocornut/imgui/wiki

It was certainly little unexpected that dear imgui has so many cool advanced UI features, but does not provide this really basic widget.

I wouldn't mind if we had an official widget for that if someone submitted, perhaps in the imgui_club repo if it's big? But requires a certain extra workload to promote code from "working in my codebase, with my dependencies" to "everyone can use it". It's also healthy to push toward moving less responsability off me and sharing that work with many third parties such as Michelle and Cedric so I'm happy with the current situation. If anything we could improve discovery of those widgets through better doc/wiki pages.

I think https://github.com/CedricGuillemet/ImGuizmo doesn't rely on glm, I however don't know how ImGuizmo and imGUiZMO.quat compares in term of features.

glm: very adequate for many tasks but I think most mid-scale console gamedevs wouldn't touch it because of how template-heavy it is (compile-time issues etc.), so my gut feeling is that anything using glm would drop plenty of users, but there's hardly a better solution other than using lower-level types made yourself. Note that ImVec2/ImVec4 are designed to be configured in imconfig.h so we could imagine using more of use in imGUiZMO.quat and let the user setup the ImVec<>glm connections, but I also guess the codebase uses more than just those simple types...

@DiligentGraphics
Copy link
Contributor Author

@ocornut thank you!
Closing the issue.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants