You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ImGuizmo provides an advanced immediate mode 3D gizmo for scene editing and other controls based on Dear ImGui.
Python bindings
Bindings status
gizmo: ported to python, works perfectly in python
ImCurveEdit: ported to python. Works well in python
ImZoomSlider: ported to python. Some rendering issues on high DPI screens under windows (in python and C++)
ImGradient: not ported
GraphEditor: not ported
ImSequencer: not ported
Technical notes about the python bindings
Writing the bindings for ImGuizmo required some adaptations on the API, under the form of wrappers.
Notably, the wrappers for the bindings of the 3D gizmo are here: ImGuizmoPure.h.
The final python binding are here: imguizmo.pyi.
If requested by Cédric Guillemet, part of those wrappers may be backported to ImGuizmo.
Using the python bindings
Using the python bindings works quite well: here are some examples. In those example, pyglm provides an easy way to calculate the camera matrices.
ImGuizmo fork
The ImGuizmo bindings are built on a fork of ImGuizmo on the imgui_bundle branch.
Note about DPI handling
Due to some hard coded sizes, some widgets do not render well with high dpi under windows and linux.
The only difference in this fork concerns some adaptations inside ImSequencer, in order to try to make it more dpi aware. I did not have time to do the same for the other widgets. A PR will be proposed to backport this to the main repository. See diff
Run a C++ ImGuizmo app with minimal boilerplate code
ImmApp or HelloImGui may provide an easy way to provide easy to setup example for ImGuizmo widgets.
For example:
The C++ demo of ImCurveEdit shown below can be compiled standalone by simply adding this CMakeLists.txt from the _example_integration folder
(alternatively, HelloImGui provides a similar quickstart example, which could be used to compile an application where ImGuizmo's code is provided manually)
#include"imgui.h"
#include"immapp/immapp.h"
#include"ImGuizmoPure/ImCurveEditPure.h"
#include<vector>
#include<deque>// This is an extract from ImGuizmo example:// https://github.com/CedricGuillemet/ImGuizmo/blob/master/vcpkg-example/main.cpp// (adapted to use the wrappers `DelegatePure`, but we could also use the bare C++ api)structRampEdit : publicImCurveEdit::DelegatePure
{
RampEdit()
{
mPts = {
{
ImVec2(-10.f, 0),
ImVec2(20.f, 0.6f),
ImVec2(25.f, 0.2f),
ImVec2(70.f, 0.4f),
ImVec2(120.f, 1.f),
},
{
ImVec2(-50.f, 0.2f),
ImVec2(33.f, 0.7f),
ImVec2(80.f, 0.2f),
ImVec2(82.f, 0.8f),
},
{
ImVec2(40.f, 0),
ImVec2(60.f, 0.1f),
ImVec2(90.f, 0.82f),
ImVec2(150.f, 0.24f),
ImVec2(200.f, 0.34f),
ImVec2(250.f, 0.12f),
}
};
mbVisible = {true, true, true};
mMax = ImVec2(1.f, 1.f);
mMin = ImVec2(0.f, 0.f);
}
size_tGetCurveCount() override
{
return3;
}
boolIsVisible(size_t curveIndex) override
{
return mbVisible[curveIndex];
}
std::vector<ImVec2>& GetPointsList(size_t curveIndex) override
{
returnmPts[curveIndex];
}
uint32_tGetCurveColor(size_t curveIndex) override
{
uint32_t cols[] = { 0xFF0000FF, 0xFF00FF00, 0xFFFF0000 };
return cols[curveIndex];
}
virtual ImCurveEdit::CurveType GetCurveType(size_t curveIndex) constoverride { return ImCurveEdit::CurveSmooth; }
virtualintEditPoint(size_t curveIndex, int pointIndex, ImVec2 value) override
{
mPts[curveIndex][pointIndex] = ImVec2(value.x, value.y);
SortValues(curveIndex);
for (size_t i = 0; i < GetPointCount(curveIndex); i++)
{
if (mPts[curveIndex][i].x == value.x)
return (int)i;
}
return pointIndex;
}
virtualvoidAddPoint(size_t curveIndex, ImVec2 value) override
{
mPts[curveIndex].push_back(value);
SortValues(curveIndex);
}
virtual ImVec2& GetMax() override { returnmMax; }
virtual ImVec2& GetMin() override { returnmMin; }
virtualunsignedintGetBackgroundColor() override { return0; }
std::vector<std::vector<ImVec2>> mPts;
std::deque<bool> mbVisible; // avoid vector<bool>!
ImVec2 mMin;
ImVec2 mMax;
private:voidSortValues(size_t curveIndex)
{
auto b = std::begin(mPts[curveIndex]);
auto e = std::begin(mPts[curveIndex]) + GetPointCount(curveIndex);
std::sort(b, e, [](ImVec2 a, ImVec2 b) { return a.x < b.x; });
}
};
voidgui()
{
staticbool wasInited = false;
static RampEdit rampEdit;
if (not wasInited)
{
rampEdit.mMin = ImVec2(-100.f, 0.f);
rampEdit.mMax = ImVec2(300.f, 1.f);
wasInited = true;
}
for (int i = 0; i < 3; i++)
{
std::string label = std::string("Visible " + std::to_string(i));
ImGui::Checkbox(label.c_str(), & rampEdit.mbVisible[i]);
ImGui::SameLine();
}
ImGui::NewLine();
ImVec2 rampEditSize(800.f, 400.f);
unsignedint rampEditId = 1;
ImCurveEdit::Edit(rampEdit, rampEditSize, rampEditId);
}
intmain()
{
HelloImGui::Run(gui);
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
ImGuizmo provides an advanced immediate mode 3D gizmo for scene editing and other controls based on Dear ImGui.
Python bindings
Bindings status
Technical notes about the python bindings
Writing the bindings for ImGuizmo required some adaptations on the API, under the form of wrappers.
Notably, the wrappers for the bindings of the 3D gizmo are here: ImGuizmoPure.h.
The final python binding are here: imguizmo.pyi.
If requested by Cédric Guillemet, part of those wrappers may be backported to ImGuizmo.
Using the python bindings
Using the python bindings works quite well: here are some examples. In those example, pyglm provides an easy way to calculate the camera matrices.
ImGuizmo fork
The ImGuizmo bindings are built on a fork of ImGuizmo on the imgui_bundle branch.
Note about DPI handling
Due to some hard coded sizes, some widgets do not render well with high dpi under windows and linux.
The only difference in this fork concerns some adaptations inside ImSequencer, in order to try to make it more dpi aware. I did not have time to do the same for the other widgets. A PR will be proposed to backport this to the main repository.
See diff
Run a C++ ImGuizmo app with minimal boilerplate code
ImmApp or HelloImGui may provide an easy way to provide easy to setup example for ImGuizmo widgets.
For example:
The C++ demo of ImCurveEdit shown below can be compiled standalone by simply adding this CMakeLists.txt from the _example_integration folder
(alternatively, HelloImGui provides a similar quickstart example, which could be used to compile an application where ImGuizmo's code is provided manually)
Beta Was this translation helpful? Give feedback.
All reactions