Thank you for sharing a project where this can be tested. Could you please also create a ticket on GitHub? Having a ticket on GitHub will mean that I can keep track of it and that others can help solve it.
Trying to use imgui to make debug menu for game.
Backspace not worked(
How can i understand that imgui capture input.
I have debug imgui window, and game.
When i click on imgui game also get input. I need to ignore input in game if this input is used in debug window?
I look at code for window. I see result and is_open
bool result = ImGui::Begin(title, is_open_ptr, flags);
lua_pushboolean(L, result);
lua_pushboolean(L, is_open);
result is true for every frame. So it is not input)
I don’t find ways to check input. But i can check is window is opened. So if debug window is opened i can ignore input in game
I am sure there is a way to figure out if imgui consumed an event or not. Your scenario should be very common. You can create a feature request on GitHub
Yes, it was easy) This feature already supported
local capture = imgui.want_mouse_input() or imgui.want_keyboard_input()
Hi! First of all, thanks for an awesome tool!
Is there any way to use сyrillic characters in imgui? I got “???” instead of my text.
The .ttf that i use contains cyrillic.
Looks similar to: Cyrillic fonts. ImGUI, OpenGL, SDL2, Python · Issue #5967 · ocornut/imgui · GitHub
I studied this doc: https://github.com/ocornut/imgui/blob/master/docs/FONTS.md#fonts-loading-instructions
Seems like i need to call something like:
io.Fonts->AddFontFromFileTTF(“font.ttf”, size_pixels, nullptr, io.Fonts->GetGlyphRangesCyrillic());
As i understand there’s no way for now to add custom glyphs range when adding font from lua
I tried to change this line
to:
ImFont* font = io.Fonts->AddFontFromFileTTF(ttf_filename, font_size, nullptr, io.Fonts->GetGlyphRangesCyrillic());
and it worked for me. However it would be better to have a possibility to select required range from lua
Please create a feature request on GitHub!
Done
Thanks for lua bindings . Imgui is awesome
This is example of level editor in imgui
Nice! I see that you are using ImGuizmo. I’ve wanted to try it out myself. Was it easy to get started with?
Yes it was easy. I just copy imgui in project. Add gizmo imguizmo.h and imguizmo.cpp.
Then add dirty binding:)
It take about one evening.
void Matrix4ToFloatArray(const dmVMath::Matrix4& matrix, float* outArray) {
// Retrieve the columns of the matrix
dmVMath::Vector4 col0 = matrix.getCol0();
dmVMath::Vector4 col1 = matrix.getCol1();
dmVMath::Vector4 col2 = matrix.getCol2();
dmVMath::Vector4 col3 = matrix.getCol3();
// Fill the output array in column-major order
outArray[0] = col0.getX();
outArray[1] = col0.getY();
outArray[2] = col0.getZ();
outArray[3] = col0.getW();
outArray[4] = col1.getX();
outArray[5] = col1.getY();
outArray[6] = col1.getZ();
outArray[7] = col1.getW();
outArray[8] = col2.getX();
outArray[9] = col2.getY();
outArray[10] = col2.getZ();
outArray[11] = col2.getW();
outArray[12] = col3.getX();
outArray[13] = col3.getY();
outArray[14] = col3.getZ();
outArray[15] = col3.getW();
}
static int imgui_Gizmo(lua_State* L) {
//DM_LUA_STACK_CHECK(L, 1);
int argc = lua_gettop(L);
const char* id = luaL_checkstring(L, 1);
uint32_t mode = luaL_checkinteger(L, 2);
uint32_t operation = luaL_checkinteger(L, 3);
// Extract the matrices from the Lua stack
dmVMath::Matrix4 view = *dmScript::CheckMatrix4(L, 4);
dmVMath::Matrix4 projection = *dmScript::CheckMatrix4(L, 5);
dmVMath::Matrix4* gizmoMatrix = dmScript::CheckMatrix4(L, 6);
// Convert the matrices to float arrays that ImGuizmo can use
float viewMatrix[16];
float projectionMatrix[16];
float modelMatrix[16];
Matrix4ToFloatArray(view, viewMatrix);
Matrix4ToFloatArray(projection, projectionMatrix);
Matrix4ToFloatArray(*gizmoMatrix, modelMatrix);
// Set up gizmo operation, mode, and snapping settings
ImGuizmo::OPERATION mCurrentGizmoOperation = static_cast<ImGuizmo::OPERATION>(operation);
ImGuizmo::MODE mCurrentGizmoMode = static_cast<ImGuizmo::MODE>(mode);
bool snap = false;
float snap_values[3] = {0.1f, 0.1f, 0.01f};
ImGuizmo::PushID(id);
imgui_NewFrame();
ImGuizmo::BeginFrame();
// Set the size of the gizmo manipulation area to the entire screen
ImGuiIO& io = ImGui::GetIO();
ImGuizmo::SetRect(0, 0, io.DisplaySize.x, io.DisplaySize.y);
float deltaMatrix[16];
// Apply the gizmo to the model matrix
bool manipulate = ImGuizmo::Manipulate(viewMatrix, projectionMatrix, mCurrentGizmoOperation, mCurrentGizmoMode, modelMatrix, deltaMatrix, snap ? snap_values : NULL);
// Copy the manipulated model matrix back to the Matrix4 type
//gizmoMatrix->setCol0(dmVMath::Vector4(modelMatrix[0], modelMatrix[1], modelMatrix[2], modelMatrix[3]));
// gizmoMatrix->setCol1(dmVMath::Vector4(modelMatrix[4], modelMatrix[5], modelMatrix[6], modelMatrix[7]));
// gizmoMatrix->setCol2(dmVMath::Vector4(modelMatrix[8], modelMatrix[9], modelMatrix[10], modelMatrix[11]));
// gizmoMatrix->setCol3(dmVMath::Vector4(modelMatrix[12], modelMatrix[13], modelMatrix[14], modelMatrix[15]));
lua_pushboolean(L, manipulate);
if(manipulate){
// Convert the delta matrix to vmath.matrix4
dmVMath::Matrix4 delta_matrix = dmVMath::Matrix4(
dmVMath::Vector4(deltaMatrix[0], deltaMatrix[1], deltaMatrix[2], deltaMatrix[3]),
dmVMath::Vector4(deltaMatrix[4], deltaMatrix[5], deltaMatrix[6], deltaMatrix[7]),
dmVMath::Vector4(deltaMatrix[8], deltaMatrix[9], deltaMatrix[10], deltaMatrix[11]),
dmVMath::Vector4(deltaMatrix[12], deltaMatrix[13], deltaMatrix[14], deltaMatrix[15])
);
// Push the delta matrix to the Lua stack
dmScript::PushMatrix4(L, delta_matrix);
}
ImGuizmo::PopID();
return manipulate ? 2 : 1;
}
local delta_matrix
changed, delta_matrix = imgui.gizmo("selected_gizmo#selected_gizmo", self.gizmo.mode, self.gizmo.operation, RENDER.view, RENDER.proj,
transformation_matrix)
if changed then
local delta_position = vmath.vector3()
local delta_rotation = vmath.quat()
local delta_scale = vmath.vector3()
xmath.matrix_get_transforms(delta_matrix, delta_position, delta_scale, delta_rotation)
if self.gizmo.operation == imgui.ImGuiGizmo_OPERATION_TRANSLATE then
self:execute_command(ChangePositionObjectCommand.new(self, self.selected_object, object_cfg.position + delta_position))
elseif self.gizmo.operation == imgui.ImGuiGizmo_OPERATION_ROTATE then
self:execute_command(ChangeRotationObjectCommand.new(self, self.selected_object, delta_rotation * object_cfg.rotation))
elseif self.gizmo.operation == imgui.ImGuiGizmo_OPERATION_SCALE then
self:execute_command(ChangeScaleObjectCommand.new(self, self.selected_object, vmath.mul_per_elem(object_cfg.scale, delta_scale)))
end
self:selected_changed()
end