tinygizmo
This project is a lightweight, self-contained library for gizmo editing commonly found in many game engines. It includes mechanisms for manipulating 3d position, rotation, and scale. Implemented in C++11, the library does not perform rendering directly and instead provides a per-frame buffer of world-space triangles.
An included example is built on top of GLFW (with an OpenGL 3.3 context). Known limitations include hardcoded assumptions about a right-handed, Y-up coordinate system. While the gizmos are provided with vertex normals, the example does not perform any fancy shading. Furthermore, mouse-drag input with certain gizmos at extreme interaction grazing angles is known to produce anomalous output.
Motivation
This project was born out of mild frustration with other immediate-mode gizmo libraries. Instead of 4x4 matrices and euler angles, the library exposes a rigid_transform
consisting of a 3d position, rotation quaternion, and scale. The library is implemented in around 1200 lines of code, which also includes a complete 3d math library in ~400 LoC - linalg.h. Alternatives include ImGuizmo and Im3D. Tinygizmo fits in-between these projects by being fully self-contained (no dependency on Dear ImGui), and by being provided in the public domain.
Features
- Both axis-aligned global and object-local transform modes for translational and rotational gizmos
- Optional ability draw the gizmos with a constant screen-space scale
- Snap-to-unit (both linear and angular)
- Set any of the
snap_
values in thegizmo_application_state
struct.
- Set any of the
- VR ready (the user must call
update(...)
anddraw()
for each eye) - Hotkeys for transitioning between translation, rotation, and scaling:
ctrl-t
to activate the translation gizmoctrl-r
to activate the rotation gizmoctrl-s
to activate the scale gizmoctrl-l
to toggle between global and local transform modes
Attribution
This project would not have been possible without reference implementations in the public-domain workbench project.
License
This is free and unencumbered software released into the public domain. For more information, please refer to http://unlicense.org